iota
02-23-2006, 06:21 AM
Hi CF Programming Gurus,
One of my friends face C ++ errors and would like to get your help.
He said :
Problem is i have no error while i compile the program but after i run my program then the dialog GUI never pop up. Please advice. Thanks
File Name : CarRental.c
#include <windows.h>
#include "main.h"
//DialogProc function
BOOL CALLBACK DialogProc(HWND hwnd, UINT msg,
WPARAM wParam,LPARAM lParam)
{
switch (msg){
case WM_COMMAND:
switch (LOWORD(wParam)){
case IDC_VIEW:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_EDIT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_RENT :
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_SHOWALL:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_SHOWONE:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_ADD:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_ABOUT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_HELP:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_EXIT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
}//end inner switch
break;
case WM_CLOSE:
EndDialog(hwnd,0);
break;
default:
return FALSE;
}//end switch
return TRUE;
}//end DialogProc()function
//execute application
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,LPSTR cmdline,
int cmdShow)
{
//call for dialog box function
return DialogBox(hInstance,
MAKEINTRESOURCE(IDD_MAIN),NULL,
DialogProc);
}//end WinMain function
File Name : main.h
//filename: main.h
#define IDD_MAIN 101
#define IDC_VIEW 1000
#define IDC_EDIT 1002
#define IDC_RENT 1003
#define IDC_SHOWALL 1004
#define IDC_SHOWONE 1005
#define IDC_ADD 1006
#define IDC_ABOUT 1007
#define IDC_HELP 1008
#define IDC_EXIT 1009
================================Above file name is main.h=======================================
//filename:mainmenu.rc
#include "main.h"
#include "windows.h"
#include "afxres.h"
/////////////////////////////////////////////
//standard main menu dialog
///////////////////////////////////////////
IDD_MAIN DIALOG DISCARDABLE 0,0,210,160
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP|
WS_CAPTION | WS_SYSMENU
CAPTION "Car rental"
FONT 18, "Bookman Old Style"
BEGIN
PUSHBUTTON "&VIEW RENTAL DETAILS",IDC_VIEW ,20,30,60,18
PUSHBUTTON "&EDIT CAR RECORD",IDC_EDIT ,100,30,60,18
PUSHBUTTON "&RENT CAR",IDC_RENT ,20,50,60,18
PUSHBUTTON "&SHOW ALL RENTAL RECORDS",IDC_SHOWALL,100,50,60,18
PUSHBUTTON "S&HOW CAR RENTAL RECORD",IDC_SHOWONE,100,70,60,18
PUSHBUTTON "&ADD NEW CAR RECORD",IDC_ADD,20,70,60,18
PUSHBUTTON "A&BOUT",IDC_ABOUT,20,90,30,18
PUSHBUTTON "&HELP",IDC_HELP,70,90,30,18
PUSHBUTTON "&EXIT",IDC_EXIT,120,90,30,18
END
One of my friends face C ++ errors and would like to get your help.
He said :
Problem is i have no error while i compile the program but after i run my program then the dialog GUI never pop up. Please advice. Thanks
File Name : CarRental.c
#include <windows.h>
#include "main.h"
//DialogProc function
BOOL CALLBACK DialogProc(HWND hwnd, UINT msg,
WPARAM wParam,LPARAM lParam)
{
switch (msg){
case WM_COMMAND:
switch (LOWORD(wParam)){
case IDC_VIEW:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_EDIT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_RENT :
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_SHOWALL:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_SHOWONE:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_ADD:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_ABOUT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_HELP:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
case IDC_EXIT:
MessageBox(hwnd,"empty string!","Warning",
MB_OK);
break;
}//end inner switch
break;
case WM_CLOSE:
EndDialog(hwnd,0);
break;
default:
return FALSE;
}//end switch
return TRUE;
}//end DialogProc()function
//execute application
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,LPSTR cmdline,
int cmdShow)
{
//call for dialog box function
return DialogBox(hInstance,
MAKEINTRESOURCE(IDD_MAIN),NULL,
DialogProc);
}//end WinMain function
File Name : main.h
//filename: main.h
#define IDD_MAIN 101
#define IDC_VIEW 1000
#define IDC_EDIT 1002
#define IDC_RENT 1003
#define IDC_SHOWALL 1004
#define IDC_SHOWONE 1005
#define IDC_ADD 1006
#define IDC_ABOUT 1007
#define IDC_HELP 1008
#define IDC_EXIT 1009
================================Above file name is main.h=======================================
//filename:mainmenu.rc
#include "main.h"
#include "windows.h"
#include "afxres.h"
/////////////////////////////////////////////
//standard main menu dialog
///////////////////////////////////////////
IDD_MAIN DIALOG DISCARDABLE 0,0,210,160
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP|
WS_CAPTION | WS_SYSMENU
CAPTION "Car rental"
FONT 18, "Bookman Old Style"
BEGIN
PUSHBUTTON "&VIEW RENTAL DETAILS",IDC_VIEW ,20,30,60,18
PUSHBUTTON "&EDIT CAR RECORD",IDC_EDIT ,100,30,60,18
PUSHBUTTON "&RENT CAR",IDC_RENT ,20,50,60,18
PUSHBUTTON "&SHOW ALL RENTAL RECORDS",IDC_SHOWALL,100,50,60,18
PUSHBUTTON "S&HOW CAR RENTAL RECORD",IDC_SHOWONE,100,70,60,18
PUSHBUTTON "&ADD NEW CAR RECORD",IDC_ADD,20,70,60,18
PUSHBUTTON "A&BOUT",IDC_ABOUT,20,90,30,18
PUSHBUTTON "&HELP",IDC_HELP,70,90,30,18
PUSHBUTTON "&EXIT",IDC_EXIT,120,90,30,18
END