Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID


We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dialog Boxes

bambinohbambinoh Posts: 1Member

I've been trying to get a Dialog box working all day now, and I've had it. I'm working with dev c++ on Windows Vista. Throughout my search on the net I've encountered my problem here and there, but nothing they suggested even came close to solving the problem. The code I'm about to copy is not my own, it's largely taken from one of the sites I stumbled across today. I've tried every source I found, and NONE (that's right, NONE) of them compiled.

My project is linked with libcommctrl32.a.
#include "resource.h"

HWND hwnd;
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);

int main()
int about = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ABOUT), hwnd, AboutDlgProc); //Call Our Dialog

if(about == IDOK) //If Out Dialog Returns With Our 'IDOK' Value
MessageBox(hwnd, "Dialog exited with IDOK.", "Notice", MB_OK | MB_ICONINFORMATION);
else if(about == IDCANCEL) //Else If Our Dialog Returns With Our 'IDCANCEL' Value
MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice", MB_OK | MB_ICONINFORMATION);
else if(about == -1) //Else If Our Dialog Returns '-1', It Means It Didnt Work
MessageBox(hwnd, "Dialog failed!", "Error", MB_OK | MB_ICONINFORMATION);

//The Dialogs Window Control
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)

return TRUE;
case IDOK: //If our dialog returns IDOK
EndDialog(hwnd, IDOK); //Close The Dialog
case IDCANCEL: //If our dialog returns IDCANCEL
EndDialog(hwnd, IDCANCEL); //Close The Dialog
return FALSE;
return TRUE;

[code="resource.h"]//Define Our Dialogs Name
#define ID_ABOUT 101[/code]

#include "resource.h" //Include our file

DLG_About DIALOG 20, 20, 400, 400
CAPTION "Just an ordinary dialogbox"
FONT 8, "MS Sans Serif"

CTEXT "Some text lines", -1, 0, 0, 300, 8
CTEXT "Some more text lines", -1, 0, 8, 300, 8
CTEXT "And even more text lines.", -1, 0, 16, 300, 8

DEFPUSHBUTTON "OK", IDOK, 130, 152, 32, 14,

I ALWAYS get following errors :
Line 5 in file resource.rc : syntax error

Any help? Please?
Sign In or Register to comment.