Windows Vista

Moderators: None (Apply to moderate this forum)
Number of threads: 5
Number of posts: 10

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dialog Boxes Posted by bambinoh on 3 Apr 2008 at 8:11 AM
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
#include <windows.h>
#include "resource.h" 
#include <commctrl.h>

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;
}


resource.h
//Define Our Dialogs Name
#define ID_ABOUT   101


resource.rc
#include <windows.h>
#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
}


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

Any help? Please?



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.