por Rolin33 » Mar Mar 22, 2011 7:28 pm
Hola a todos nuevamente, logre hacer un source code que me captura lo que hay en el portapaleles y lo pasa a excel. Ahora estoy en otro source code que me graba mi grid al portapapeles, pero al compilar me sale el siguiente error:
D:\APP600\LOC600\BKGEN\CTCIAMUI.CPP(1807) : error C2065: 'colCount' : undeclared identifier
D:\APP600\LOC600\BKGEN\CTCIAMUI.CPP(1811) : error C2374: 'i' : redefinition; multiple initialization
D:\APP600\LOC600\BKGEN\CTCIAMUI.CPP(1799) : see declaration of 'i'
Error executing cl.exe.
El source code es el siguiente:
{
HWND hwndGrid=ObPanelAPI::GetControlHandleByName(&(1:));
if (hwndGrid)
{
CString text;
//Send message to select all the loaded Rows
//Get the number of rows loaded on the Grid
int iRows = SendMessage(hwndGrid, HGM_GETROWCOUNT, 0, 0L);
for(int i=0;i<iRows;i++)
{
//Send message to select the gridrow
SendMessage(hwndGrid,HGM_TURNONROW,i,0);
}
//Create a array of int values to hold the Columns and set to lpMap
int *lpMap = new int[colCount];
SendMessage(hwndGrid,HGM_GETCOLMAP,0,((LPARAM)lpMap));
for(int i=0;i<colCount;i++)
{
CString str1;
int m;
for(m=0;m<colCount;m++)
{
if(lpMap[m] == i)
{
break;
}
}
WORD wState = SendMessage(hwndGrid,HGFM_GETSTATE,m,0L);
if(wState != 5) //If state is not hidden
{
char* str = new char[100];
if((int)SendMessage(hwndGrid,HGFM_GETNAME,m,(LPARAM)str)) //Get the name of the Column
{
str1 = CString(str);
if(text.GetLength() > 0)
text += "\t"+str1; //Append the column name to the exisiting set with tab as delimiter
else
text = str1;
}
else
break;
delete str; //delete the memory allocated before.
}
}
delete lpMap; //delete the memory allocated before
text += "\r\n"; //delimit the header with the carriage return.
//Send message to select all the loaded Rows in the Grid CNTRL+SHIFT+END
SendMessage( hwndGrid, WM_KEYDOWN, VK_CONTROL, 1L);
SendMessage( hwndGrid, WM_KEYDOWN, VK_SHIFT, 1L);
SendMessage( hwndGrid, WM_KEYDOWN, VK_END, 1L);
SendMessage( hwndGrid, WM_COPY, NULL, NULL ); //Process the CNTR+C to get the values to clipboard for the grid
HGLOBAL hMem;
char * MemStr;
CWnd *pWnd = ObPanelAPI::GetPanelCWndByName("*Current");
if (pWnd)
{
if ( pWnd -> OpenClipboard() )
{
char* buffer = (char*)GetClipboardData(CF_TEXT);
CString temp(buffer);
text += temp;
if ( EmptyClipboard() )
{
// Allocate global memory for string
hMem = GlobalAlloc(GMEM_DDESHARE, text.GetLength()+1);
MemStr = (char*)GlobalLock(hMem);
strcpy(MemStr, text);
GlobalUnlock ( hMem);
// The Clipboard now owns the allocated memory
// and will delete this data object
// when new data is put on the Clipboard
if ( !SetClipboardData(CF_TEXT, hMem) )
GlobalFree( hMem);
}
else
MessageBox (0, text, "Clipboard Empty Error", MB_OK);
CloseClipboard();
}
}
}
}
Ojala alguien pueda ayudarme, saludos.