Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Author |
Message |
Bob Soete #1 / 5
|
 Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Hello All, I've been searching for the correct way to program an application so that it's main window will be a dialog box which I created using the resource editor. My problem is: how can I accomplish this ? The help of MSVC isn't exactly clear about this, IMHO. Any help would be greatly appreciated, I'm going nuts :)). Kind regards, Bob Soeters
|
Wed, 15 Nov 2000 03:00:00 GMT |
|
 |
Roger #2 / 5
|
 Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Quote: Soeters) writes: >I've been searching for the correct way to program an application so >that it's main window will be a dialog box which I created using the >resource editor. >My problem is: how can I accomplish this ? >The help of MSVC isn't exactly clear about this, IMHO. >Any help would be greatly appreciated, I'm going nuts :)).
Basically you just call DialogBox() directly from WinMain(). int Pascal WinMain(HINSTANCE hiCurrent, HINSTANCE hiPrevious, LPSTR lpszCmdLine, int nCmdShow ) { DialogBox( hiCurrent, "DialogName", NULL, (DLGPROC)DialogProc); return 0; Quote: }
Roger Abbott, RHA (Minisystems) Ltd http://users.aol.com/rogerha DDE tools, Algol60 downloads
|
Thu, 16 Nov 2000 03:00:00 GMT |
|
 |
Bob Soete #3 / 5
|
 Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Quote: >Basically you just call DialogBox() directly from WinMain(). >int PASCAL WinMain(HINSTANCE hiCurrent, HINSTANCE hiPrevious, > LPSTR lpszCmdLine, int nCmdShow ) >{ > DialogBox( hiCurrent, "DialogName", NULL, (DLGPROC)DialogProc); > return 0; >} >Roger Abbott, >RHA (Minisystems) Ltd >http://users.aol.com/rogerha DDE tools, Algol60 downloads
Hello Roger, Your solution makes sense, but what if I want to register a window class on my own for dialog boxes and then use that class for my dialog box, so I can add an icon ? I've already tried several approaches, done everything exactly as the help and KB of MicroSoft suggested, and it still doesn't work. I don't know if or what I'm doing wrong. Kind regards, Bob Soeters
|
Fri, 17 Nov 2000 03:00:00 GMT |
|
 |
J. Bosche #4 / 5
|
 Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Quote: >Your solution makes sense, but what if I want to register a window >class on my own for dialog boxes and then use that class for my dialog >box, so I can add an icon ?
So then register it: -add a CLASS "MyDialogClass" line to your dialog script resource -register your private dialog class using DefDialogProc as the lpfnWndProc member and DLGWINDOWEXTRA for the cbWndExtra member -use CreateDialog to create the dialog -call IsDialogMessage in your message pump like so: while ( GetMessage(&msg, NULL, 0, 0) > 0 ) { if ( !hwndDialog || !IsDialogMessage(hwndDialog, &msg) ) { TranslateMessage(&msg); DispatchMessage(&msg); } } - return either TRUE or FALSE from your DialogFunc passed to CreateDialog as the lpDialogFunc parameter You need to call IsDialogMessage to get the functionality offered by Windows for dialogs, otherwise it pretty much behaves like a standard window. Jeremy
|
Fri, 17 Nov 2000 03:00:00 GMT |
|
 |
Bob Soete #5 / 5
|
 Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)
Quote: >>Your solution makes sense, but what if I want to register a window >>class on my own for dialog boxes and then use that class for my dialog >>box, so I can add an icon ? >So then register it: >-add a CLASS "MyDialogClass" line to your dialog script resource >-register your private dialog class using DefDialogProc as the lpfnWndProc >member and DLGWINDOWEXTRA for the cbWndExtra member >-use CreateDialog to create the dialog >-call IsDialogMessage in your message pump like so: > while ( GetMessage(&msg, NULL, 0, 0) > 0 ) { > if ( !hwndDialog || !IsDialogMessage(hwndDialog, &msg) ) { > TranslateMessage(&msg); > DispatchMessage(&msg); > } > } >- return either TRUE or FALSE from your DialogFunc passed to CreateDialog as >the lpDialogFunc parameter >You need to call IsDialogMessage to get the functionality offered by Windows >for dialogs, otherwise it pretty much behaves like a standard window. >Jeremy
Hello Jeremy, Thank you for this reply. I tried to do it like you suggested, and I still not able to accomplish the wanted result. Perhaps someone can send me some working example of a program which consists of only one dialog box ? I'd be very pleased... Kind Regards, Bob Soeters
|
Sat, 18 Nov 2000 03:00:00 GMT |
|
|
|