Quote:Original post by yadango
You appear to be ignoring WM_KEYDOWN messages as well as not using IsDialogMessage(), which is why you are having input problems. I personally would choose a different design, one that doesn't use modeless dialogs in this case, but if you absolutely have to use dialog templates, I do believe it is possible to cook something up. Got a dialog resource template code sample to post too?
P.S.
Also, modeless dialogs don't use EndDialog.
WM_INITDIALOG's return value also has special meaning, and should return TRUE if you don't want to override the default focus. There are a few dialog messages that don't follow the general rule of TRUE (processed), FALSE (do default); WM_INITDIALOG is one of them.
Thank you yadango for that informative problem analysis. I believe the reason I skipped that message type in the first place was that in an earlier application it was causing error sounds to be played whenever I was pressing keys without having focused a tree view within the window. I can see how IsDialogMessage() could be useful here to avoid some faulty message handling, although I'm not sure how this could be applied when messages are being passed as unsigned ints (I've stitched together several code samples I've found, hence the somewhat incoherent program structure). Can I somehow cast this UINT into a LPMSG or do I need to pass in the actual MSG structure as an argument for the window procedure?
Also, I wonder what would be another alternative to using modeless dialogs? The reason I chose to do it like this was simply because it's the only way I know that utilizes resource templates that can be constructed graphically.
Here's what the entire resource file looks like, I suspect there might be some excessive information in there as a result of my experiments :P
// Microsoft Visual C++ generated resource script.//#include "resource.h"#define APSTUDIO_READONLY_SYMBOLS///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 2 resource.//#include "afxres.h"/////////////////////////////////////////////////////////////////////////////#undef APSTUDIO_READONLY_SYMBOLS/////////////////////////////////////////////////////////////////////////////// Swedish resources#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE)#ifdef _WIN32LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT#pragma code_page(1252)#endif //_WIN32#ifdef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// TEXTINCLUDE//1 TEXTINCLUDE BEGIN "resource.h\0"END2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0"END3 TEXTINCLUDE BEGIN "\r\n" "\0"END#endif // APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// Menu//IDR_MENU1 MENU BEGIN POPUP "File" BEGIN MENUITEM "Exit", ID_FILE_EXIT ENDEND///////////////////////////////////////////////////////////////////////////////// Dialog//IDD_DIALOG1 DIALOGEX 0, 0, 316, 180STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENUCAPTION "Dialog"FONT 8, "MS Shell Dlg", 400, 0, 0x1BEGIN DEFPUSHBUTTON "OK",IDOK,205,159,50,14 PUSHBUTTON "Cancel",IDCANCEL,259,159,50,14 EDITTEXT IDC_EDIT1,21,20,66,12,ES_AUTOHSCROLL EDITTEXT IDC_EDIT2,142,68,83,28,ES_AUTOHSCROLL EDITTEXT IDC_EDIT3,14,129,152,26,ES_AUTOHSCROLL LTEXT "Static",IDC_STATIC,165,22,63,16 LTEXT "Static",IDC_STATIC,35,67,68,18 LTEXT "Static",IDC_STATIC,187,140,63,7END///////////////////////////////////////////////////////////////////////////////// DESIGNINFO//#ifdef APSTUDIO_INVOKEDGUIDELINES DESIGNINFO BEGIN IDD_DIALOG1, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 309 TOPMARGIN, 7 BOTTOMMARGIN, 173 ENDEND#endif // APSTUDIO_INVOKED#endif // Swedish resources/////////////////////////////////////////////////////////////////////////////#ifndef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 3 resource.///////////////////////////////////////////////////////////////////////////////#endif // not APSTUDIO_INVOKED
Again, thanks ever so much for taking the time to help me. This feels like an important programming aspect to really understand.