1st sorry for my english. 2nd - I have a big problem, which I cannot solve. I have this simple
code:
I create one DialogBox as main application window and second (Intro), which appears at the start as well in WM_INITDIALOG case. The problem is, that the main window, although it's under the Intro window - is focused. I was trying to set focus into Intro window, as I found in other thread (by SetForeground and SendMessage) but it's still not working. ICode:#include <windows.h>#include <windowsx.h> #include <commctrl.h> #include "main.h" BOOL CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM); HINSTANCE hInst; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { hInst = hInstance; INITCOMMONCONTROLSEX icc; icc.dwICC = ICC_WIN95_CLASSES; icc.dwSize = sizeof( icc ); InitCommonControlsEx( &icc ); WNDCLASSEX wcx; wcx.cbSize = sizeof( wcx ); if ( !GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx) ) { MessageBox( NULL, "Error creating class.", "Error", MB_OK | MB_ICONERROR ); return 0; } wcx.hInstance = hInstance; wcx.hIcon = LoadIcon( hInstance, IDI_APPLICATION ); wcx.lpszClassName = "VantSnake"; if ( !RegisterClassEx(&wcx) ) { MessageBox( NULL, "Error creating application.", "Error", MB_OK | MB_ICONERROR ); return 0; } return DialogBox( hInstance, MAKEINTRESOURCE(VNTH_MAIN), NULL, (DLGPROC) DlgProc ); } BOOL CALLBACK DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_COMMAND: switch ( GET_WM_COMMAND_ID(wParam, lParam) ) { case IDOK: EndDialog( hWnd, 0 ); break; } break; case WM_CLOSE: EndDialog( hWnd, 0 ); break; case WM_INITDIALOG: if ( !FindWindow(NULL, "Intro") ) { // creates Intro dialog box CreateDialog( GetModuleHandle(NULL), MAKEINTRESOURCE(VNTH_START), hWnd, (DLGPROC) DlgProc ); } else { // here i'm trying to set focus on it, but it doesnt't works SetForegroundWindow( hWnd ); SendMessage( hWnd, WM_NEXTDLGCTL, (WPARAM) GetDlgItem(hWnd, VNTH_START), TRUE ); } return 1; } return 0; }
m little bit frustrating, because I'm trying to solve it for hours with no effect. Please, if anyone has solution for that, help. The link for Pelles C project: http://www.filolozka.pl/C/VantSnake.zip
Of course VNTH_MAIN and VNTH_START are resource linkages to Main and Intro windows.



LinkBack URL
About LinkBacks



any other idea?