-
Dialog Boxes
I use Bloodshed Dev C++, and I created a C windows file. I can not get dialog boxes to work. I enter the code into the resource file (.rc) and it pops out a parse error. I dont understand. The code is generated from the program, but it doesnt work.
Josh
http://www.xp-users.com
-
Hi there Josh;
I have never used Bloodshed but does it come with a Resource Editor? if it does just make a new resource and be sure to include its header file. after that is done you need to create the dialog box from your program. its hard for me to see where your going wrong with no info on the prase error or any code that your using so i will show you how to make a dialog from sratch.
case IDM_WHATEVER:
DialogBox(g_hInst, (LPCTSTR)IDD_NAME, hWnd, (DLGPROC)DlgNameProc);
break;
LRESULT CALLBACK DlgNameProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK )
{
EndDialog(hDlg, LOWOR (wParam));
return TRUE;
}
if (LOWORD(wParam) = IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
anyway that will load a dlg for you. if you still get errors then please show us some code, it helps...
-
yes, it does have a resource editor, but it doesnt work to put it in there, that is where I am getting the parse error.
here is what I type in:
100 DIALOG 0, 0, 200, 200
<b>STYLE WS_VISIBLE | WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME<b>
the bold is the line the puter tells me is the problem
if you need the rest of it, just tell me.
Josh
-
Ok, I get a load of errors when I do that:
g_hinst undeclared
hWnd undeclared
DlgNameProc undeclared
parse error before '_attribute_'
hDlg undeclared
parse error before 'break'
some error written all messed up (dont know what it says)
DlgNameProc undeclared
and another one I cant read
lots of errors.
all I did was type the code in, where it is supposed to go, and push compile. should I have done something else?
Josh
-
Oh, I really object to Dev-C++'s resource builder. I use lcc's resource editor and use Dev-C++ to compile.
Okay, this is a simple problem.. which in my opinion I think Dev-C++ should do for you - it confused me for ages.
Simply add:
#include <windows.h>
At the top of the resource file and click Compile Resource. Worked fine for me.. This is a quick resource file I made:
#include <windows.h>
100 DIALOG 0, 0, 200, 200
STYLE WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | DS_MODALFRAME
CAPTION "My Dialog Box"
FONT 8,"Helv"
BEGIN
END
Hope all goes well, good luck! :p
-
OK, now I got the resource file to work, but when I compile it using theforger's tuturial, I go to the menu item, click the one that goes to my dialog, and it exits. :( What do I do now?
Josh
http://www.xp-users.com