Howdy, Stranger!

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

Categories

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
Hi,

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.
main.cpp
[code="main.cpp"]
#include
#include "resource.h"
#include

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

int main()
{
InitCommonControls();
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)
{
switch(Message)
{
case WM_INITDIALOG:

return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK: //If our dialog returns IDOK
EndDialog(hwnd, IDOK); //Close The Dialog
break;
case IDCANCEL: //If our dialog returns IDCANCEL
EndDialog(hwnd, IDCANCEL); //Close The Dialog
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
[/code]

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

resource.rc
[code="resource.rc"]#include
#include "resource.h" //Include our file

DLG_About DIALOG 20, 20, 400, 400
STYLE WS_POPUP | WS_DLGFRAME
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,
WS_GROUP
}[/code]

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

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