Archived

This topic is now archived and is closed to further replies.

Jacob84

Win32 developing question on VS .NET

Recommended Posts

Hi everybody :D ... Just another question ''bout Win32 API developing with Visual Studio .NET. I will put an example, very simple I think, wich can be generated auto with the Win32 app wizard. It makes a window, with a menu, File , help & Info (ADDED, The last was mine :D). Then I build a dialog, very simple too, a window with and edit box and two buttons. Then I link the menu item(Info) with the dialog -> case IDM_INFO: DialogBox(hInst, (LPCTSTR)IDD_DIALOG1, hWnd, (DLGPROC)Info); The only problem is, that on the main app window, appears my dialog, but without window!!!, just two buttons and the edit over the main window!!!... I hope you understand... Thanks for reading, even if the question is stupid Jacob.

Share this post


Link to post
Share on other sites
Of course!...thanks for this fast answer...

Here is the code form the About Dialog, that is generated auto by the wizard->


// This is how it''s called->

case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
//==================================

LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}


As you can see, no WM_PAINT code is included, and it works ok... Let''s see now the function Info, but it''s almost "clean"


LRESULT CALLBACK Info(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
EndDialog(hDlg,LOWORD(wParam));
return TRUE;
break;
}


Thanks a lot...

Share this post


Link to post
Share on other sites
I''m not sure about how dialog procs work, but it seems your message handler is missing the ''default'' case.

Try to call this in your message switch as default case:

LRESULT DefDlgProc(HWND hDlg,UINT Msg,WPARAM wParam,LPARAM lParam);

Look up on MSDN for more info

Share this post


Link to post
Share on other sites
Thanks Nik02:

It''s curious, with DefDlgProc, app exits automatically, but with DefWindowProc it appears correctly, but it''s impossible to move :D.

It''s a step... I will look on MSDN,

Thanks!!!

Share this post


Link to post
Share on other sites