![]() |
| | #1 |
| Yah. Join Date: Feb 2005
Posts: 109
| Dialog Box Problems Here is all my dialog box code: Resourse (dialogs.rc) Code: #include "hdandn.hpp"
IDD_DLGJOIN DIALOG 260, 200, 188, 95
STYLE DS_MODALFRAME | WS_CHILD | WS_CAPTION | WS_TOPMOST | WS_SETFOREGROUND | WS_VISIBLE
CAPTION "Join a Game"
FONT 8, "Courier New"
BEGIN
DEFPUSHBUTTON "OK", ID_DLGOK, 130, 10, 50, 14
END
Code: DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DLGJOIN), dlghwnd, reinterpret_cast<DLGPROC>(DlgProc)); Code: LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CREATE:
break;
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
EndDialog(hWndDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
Predifinition (forget word): Code: LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // Dialog Box Code: #define IDD_DLGJOIN 100 #define ID_DLGOK 101 I am using Dev-C++ 4.9.9.2 Thanks in advance for all help and suggestions .
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. |
| Morgul is offline | |
| | #2 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| I'm guessing the problem is that you are giving your dialog the WS_CHILD style. You probably dont want your dialog box as a child window. |
| bithub is offline | |
| | #3 |
| Yah. Join Date: Feb 2005
Posts: 109
| Thanks. I got rid of that, and it didn't help. I added in WS_POPUP instead, and that didn't help either
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. |
| Morgul is offline | |
| | #4 |
| Registered User Join Date: Dec 2001 Location: The most peaks over 10,000 feet!
Posts: 388
| Could someone please explain the reason for the 'reinterpret_cast' in the dialog box call? I don't understand why it would be neccessary.
__________________ "A government big enough to give you everything you want, is big enough to take away everything you have." - Thomas Jefferson MSVS 2008 Pro / DevPartner / CB NightlyBuilds / MinGW / Cygwin |
| Bajanine is offline | |
| | #5 |
| Yah. Join Date: Feb 2005
Posts: 109
| That is just how the tutorial i read told me to do it. I've seen it work with and without. I just put in a regular typecast and it doesnt change a thing
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. Last edited by Morgul; 05-28-2005 at 10:39 PM. |
| Morgul is offline | |
| | #6 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,359
| try... a normal cast to (DLGPROC)DlgProc. Looks a bad mix of C++ and C. and return FALSE to the Init msg. Put a break point in the DlgProcs WM_INITDIALOG case. This will tell if the dialog is being created. If not the error is in the DialogBox() call (probably in the resource script).
__________________ "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter." Friedrich Nietzsche "I spent a lot of my money on booze, birds and fast cars......the rest I squandered." George Best "If you are going through hell....keep going." Winston Churchill |
| novacain is offline | |
| | #7 |
| Yah. Join Date: Feb 2005
Posts: 109
| I changed the return true to a break, and have a normal cast now. Still, nothing happens. Here is my resource code currently: Code: #include "hdandn.hpp"
IDD_DLGJOIN DIALOG 260, 200, 188, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_TOPMOST | WS_SETFOREGROUND | WS_VISIBLE
CAPTION "Join a Game"
FONT 8, "Courier New"
BEGIN
DEFPUSHBUTTON "OK", ID_DLGOK, 130, 10, 50, 14
END
Also: would it be better just to use those custom templates where i program the buttons and so on myself? If I did that, would that allow me to change settings about like background color and transperancy?
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. |
| Morgul is offline | |
| | #8 |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| >>Still, nothing happens<< Is the return value of your DialogBox call zero? If it is, have you tried to find out why with GetLastError?
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. |
| Ken Fitlike is offline | |
| | #9 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| There is no such thing as WS_TOPMOST or WS_SETFOREGROUND - unless you've difined them yourself. I don't recommend casting any function parameters. The correct signature will be BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM) or INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM) depending on your version of the SDK. Get rid of WS_CHILD and WS_POPUP and the 3rd parameter to DialogBox() should be 0. For WM_COMMAND, you need to switch on LOWORD(wParam) and case on ID_DLGOK, not IDOK. gg |
| Codeplug is offline | |
| | #10 |
| Yah. Join Date: Feb 2005
Posts: 109
| I changed the Dlgproc to INT_PTR (bool wasn't accepted), I got rid of WS_POPUP, I changed the third parameter of DialogBox() to 0, I fixed the WM_COMMAND in Dlgproc (I was going to eventually anyway), and none of this helped. It still doesn't work. Also, I got WS_TOPMOST and WS_SETFOREGROUND off of msdn, I have used them before and they work fine. Could the problems be because my program uses OpenGL? Could there be something I have to set first so that it will let me use a Dialogbox?
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. Last edited by Morgul; 05-29-2005 at 11:11 AM. |
| Morgul is offline | |
| | #11 | |
| Registered User Join Date: Mar 2003
Posts: 3,844
| >> Also, I got WS_TOPMOST and WS_SETFOREGROUND off of msdn No you didn't, because they do not exist - unless you have defined them in your own source. I doubt that your resrouce script even compiles. Quote:
Last edited by Codeplug; 05-29-2005 at 01:43 PM. | |
| Codeplug is offline | |
| | #12 | ||
| Yah. Join Date: Feb 2005
Posts: 109
| Yes I did: Quote:
Everything compiles, I have even rebuilt the project. I go to make the dialog box appears, and nothing happens. I'm going to test GetLastError, ill edit with my results... --------- edit---------- I got an error code of 1812. This is: Quote:
Resource (just to make sure I have the most up-to-date version here): Code: #include "hdandn.hpp"
IDD_DLGJOIN DIALOG 260, 200, 188, 95
STYLE DS_MODALFRAME | WS_CAPTION | WS_TOPMOST | WS_SETFOREGROUND | WS_VISIBLE
CAPTION "Join a Game"
FONT 8, "Courier New"
BEGIN
DEFPUSHBUTTON "OK", ID_DLGOK, 130, 10, 50, 14
END
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. Last edited by Morgul; 05-29-2005 at 02:50 PM. | ||
| Morgul is offline | |
| | #13 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| >> Do cntrl+f (find) on this page and search for WS_TOPMOST and WS_SETFOREGROUND And yet the're nowhere to be found within your quote. Trust in your own ctrl-f skillz - they don't exist. This works as expected in VC++ 6.0 and Dev-C++ 4.9.8.0: Code: IDD_DLGJOIN DIALOG 260, 200, 188, 95
STYLE DS_MODALFRAME | WS_CAPTION | WS_VISIBLE
CAPTION "Join a Game"
FONT 8, "Courier New"
BEGIN
DEFPUSHBUTTON "OK", ID_DLGOK, 130, 10, 50, 14
END
gg |
| Codeplug is offline | |
| | #14 | |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| >>Yes I did:<< That looks to be the msdn description for the MessageBox function. I searched through what you've posted and didn't find either WS_TOPMOST nor WS_SETFOREGROUND styles. I also searched through the linked CreateWindow page you provided and didn't find anything there either. There is an extended window style (see CreateWindowEx, dwExStyle parameter description) of WS_EX_TOPMOST, though, which is maybe where you're getting confused. But to use extended styles in resource generated dialogs you need to use the DIALOGEX resource definition statement in your resource script and not DIALOG as you have done. There's also MB_SETFOREGROUND and MB_TOPMOST flags listed for the MessageBox function but neither of these are window styles. Although MessageBoxes are essentially dialog boxes it's probably best not to mix them up in the way you are implying. Since you seem to be using undefined constants in your project and that project compiles without error, it may be that the resource script is somehow not being included in the build; if it was windres, the resource compiler used by Dev-Cpp, would be emitting its legendary and ambiguous 'parse' errors. Did you try this? Quote:
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. | |
| Ken Fitlike is offline | |
| | #15 | ||
| Yah. Join Date: Feb 2005
Posts: 109
| Well, you have proven me wrong. I now see my error. I am thinking of MB_TOPMOST and MB_SETFOREGROUND. This however proves that the resource is not being included in compilation. If you read my above edit, I did get the last error: Quote:
----------- edit----------------- I copied the stuff into a new resource file and named it something else. It doesn't compile now. I get this error: Quote:
__________________ Sic vis pacum para bellum. If you want peace, prepare for war. Last edited by Morgul; 05-29-2005 at 09:10 PM. | ||
| Morgul is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Display text in a Dialog Box | Dark_Phoenix | Windows Programming | 9 | 01-02-2009 06:30 AM |
| Dialog Box (Compile Problem) | Vicious | Windows Programming | 6 | 08-31-2004 03:29 PM |
| problem with the open dialog box | stallion | Windows Programming | 13 | 02-19-2003 08:28 AM |
| Context Menu & Dialog Box :: MFC | kuphryn | Windows Programming | 4 | 08-11-2002 10:01 AM |
| Tab Controls - API | -KEN- | Windows Programming | 7 | 06-02-2002 09:44 AM |