|
-
October 15th, 2007, 09:50 AM
#6
Re: Get filename from context menu
 Originally Posted by juanpast
I try to do this obtaining the title of the explorer and searching selected file but crasshes:
Code:
void myDlg::OnButtonSearch()
{
char szWindow[1000];
EnumWindows(SearchWin,(LPARAM)szWindow);
}
BOOL CALLBACK SearchWin(HWND hWnd,LPARAM lpParam) {
SendMessage(hWnd, WM_GETTEXT, 1000, (LPARAM) lpParam);
char sText[1000];
strcpy(sText,(char*)lpParam);
if(strcmp(sText,"Title of explorer") == 0) {
EnumChildWindows(hWnd,SearchChildWin,NULL);
}
return TRUE;
}
BOOL CALLBACK SearchChildWin(HWND hWnd,LPARAM lpParam) {
char sClass[1000];
GetClassName(hWnd,sClass,1000);
if(strcmp(sClass,"SysListView32") == 0) {
LVITEM *iItem = new LVITEM;
iItem->iSubItem = 0;
iItem->cchTextMax = 255;
iItem->pszText = new char[iItem->cchTextMax + 1];
int nItem = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);
bool bFound = false;
int i=0;
while(!bFound && i < nItem) {
int nStatus = SendMessage(hWnd,LVM_GETITEMSTATE,i,LVIS_SELECTED);
if(nStatus == LVIS_SELECTED) {
SendMessage(hWnd,LVM_GETITEMTEXT, i, (LPARAM)iItem);
bFound = true;
} else i++;
}
}
return TRUE;
}
Someone know what this code crasshes in the red line??
Notice the bold part of the code.
Regards,
Usman.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|