Enumwindows hangs (freezing) application any idea?
-
Hi I have using MFC dialog application. in that it is calling another dialog. in 2nd dialog i am enumerating the windows using enumwindows api. after calling the enumwindows application is freezing or hanging. any idea about this.
Does your callback get called at all?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
Hi I have using MFC dialog application. in that it is calling another dialog. in 2nd dialog i am enumerating the windows using enumwindows api. after calling the enumwindows application is freezing or hanging. any idea about this.
-
Please post the code snippet where the application hangs. APIs never hang application, only the way of using it. Something might went wrong in the callback.
-- "Programming is an art that fights back!"
Dialog1 ::Onok()
{HWND hShareWnd = NULL; UpdateData(); bDesktopShareStarted = !bDesktopShareStarted ; if(bDesktopShareStarted) { int width = GetSystemMetrics(SM\_CXSCREEN); int height = GetSystemMetrics(SM\_CYSCREEN); int x = 0; int y =0; CVariableRegion VariableRgnDlg; ////dialog 2 if(VariableRgnDlg.DoModal() ==IDOK) { hShareWnd = VariableRgnDlg.GetShareWindow(); width = VariableRgnDlg.GetShareWidth(); height = VariableRgnDlg.GetShareHeight(); x = VariableRgnDlg.GetShareXPosition(); y= VariableRgnDlg.GetShareYPosition(); if(m\_bEnableAVIRecording) EnableAVIRecording(); else EnableAVIRecording(FALSE); //Session ZeroMemory(szBuffer,sizeof(szBuffer)); GetDlgItemText(IDC\_EDIT\_CODE,szBuffer,sizeof(szBuffer)); lLength = \_tcslen(szBuffer) + 1 ; //reusing the same variable SetRegInfo(LASTUSED\_SESSION,szBuffer,REG\_SZ,&lLength); //Session pass ZeroMemory(szBuffer,sizeof(szBuffer)); GetDlgItemText(IDC\_EDIT\_PASS,szBuffer,sizeof(szBuffer)); lLength = \_tcslen(szBuffer); //reusing the same variable SetRegInfo(LASTUSED\_SESSION\_PASS,szBuffer,REG\_SZ,&lLength); //Client Name ZeroMemory(szBuffer,sizeof(szBuffer)); GetDlgItemText(IDC\_EDIT\_CLIENT\_NAME,szBuffer,sizeof(szBuffer)); lLength = \_tcslen(szBuffer); //reusing the same variable SetRegInfo(LASTUSED\_USERNAME,szBuffer,REG\_SZ,&lLength); //Record AVI lLength = sizeof(m\_bEnableAVIRecording); //reusing the same variable m\_bEnableAVIRecording = IsDlgButtonChecked(IDC\_CHECK\_AVI\_REC); SetRegInfo(LASTOPTION\_AVI,(LPTSTR)&m\_bEnableAVIRecording,REG\_DWORD,&lLength); StartDesktopShare(hShareWnd,width,height,x,y,GetDlgItem(IDC\_TARGETWND)->m\_hWnd); GetDlgItem(IDC\_BUTTON\_DSK\_SHARE)->SetWindowText(TEXT("Stop Share")); } else { StopDesktopShare(); GetDlgItem(IDC\_BUTTON\_DSK\_SHARE)->SetWindowText(TEXT("Start Share")); bDesktopShareStarted = !bDesktopShareStarted ; } } else { StopDesktopShare(); GetDlgItem(IDC\_BUTTON\_DSK\_SHARE)->SetWindowText(TEXT("Start Share")); }
}
dialog 2 code//
in dialog 2 on button click this function is called.
long CVariableRegion::GetWindowsList()
{
HWND hListBox = NULL;
TCHAR sWindowCount[100] = {0};
int nWindowsCount = 0;
CWnd *hDeskopWnd = NULL;
TCHAR szWindowCountTitle[MAX_PATH]={0};hListBox = GetDlgItem(IDC\_WIN\_LIST)-&g