here are all of my codes
Main.CPP
Windows1.rcCode:#include <windows.h> #include "resource.h" #include "dialog.h" const char *ClsName = "BasicApp"; const char *WndName = "Mystical Island"; //window name LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) //main function of window { MSG Msg; //window messages HWND hWnd; //handle of window WNDCLASSEX WndClsEx; //structure of window // Create the application window WndClsEx.cbSize = sizeof(WNDCLASSEX); //type WndClsEx.style = CS_HREDRAW | CS_VREDRAW; //horizontal | vertical WndClsEx.lpfnWndProc = WndProcedure; WndClsEx.cbClsExtra = 0; //none WndClsEx.cbWndExtra = 0; //none WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); //loading icon WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW); //loading cursor WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); //background color WndClsEx.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); //loading menu WndClsEx.lpszClassName = ClsName; //varaible class name WndClsEx.hInstance = hInstance; //previous instance WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Register the application RegisterClassEx(&WndClsEx); // Create the window object hWnd = CreateWindow(ClsName, WndName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); // Find out if the window was created if( !hWnd ) // If the window was not created, return 0; // stop the application // Display the window to the user ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // Decode and treat the messages // as long as the application is running while( GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { switch(LOWORD(wParam)) { case ID_HELP_ABOUT: { int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc); if(ret == IDOK){ MessageBox(hwnd, "Dialog exited with IDOK.", "Notice", MB_OK | MB_ICONINFORMATION); } else if(ret == IDCANCEL){ MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice", MB_OK | MB_ICONINFORMATION); } else if(ret == -1){ MessageBox(hwnd, "Dialog failed!", "Error", MB_OK | MB_ICONINFORMATION); } } } break; case WM_DESTROY: // then close it PostQuitMessage(WM_QUIT); break; default: // Process the left-over messages return DefWindowProc(hWnd, Msg, wParam, lParam); } // If something was not done, let it go return 0; }
dialog.hCode:#include "resource.h" #include "windows.h" IDR_MYMENU MENU BEGIN POPUP "&File" BEGIN MENUITEM "E&xit", 9001 END POPUP "&Area" BEGIN MENUITEM "&Go", 9002 MENUITEM "G&o somewhere else", 0, GRAYED END POPUP "&Battle" BEGIN MENUITEM "&Player", 9003 END POPUP "&Help" BEGIN MENUITEM "&About", 9004 END END IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About Mystical Island" FONT 8, "Courier New" BEGIN DEFPUSHBUTTON "&OK",IDOK,174,18,50,14 PUSHBUTTON "&Cancel",IDCANCEL,174,35,50,14 GROUPBOX "About this program...",IDC_STATIC,7,7,225,52 CTEXT "This is a test version of the RPG, \r\n\r\nMystical Island by Renegade" IDC_STATIC,16,18,144,33 END
finally, resource.hCode:#ifndef _DIALOG_H_ #define _DIALOG_H_ 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: EndDialog(hwnd, IDOK); break; case IDCANCEL: EndDialog(hwnd, IDCANCEL); break; } break; default: return FALSE; } return TRUE; } #endif
I get these errors:Code:#ifndef _RESOURCE_H_ #define _RESOURCE_H_ #define IDR_MYMENU 101 #define ID_FILE_EXIT 9001 #define ID_AREA_GO 9002 #define ID_BATTLE_PLAYER 9003 #define ID_HELP_ABOUT 9004 #define IDC_STATIC -1 #endif
main.cpp: In function `LRESULT WndProcedure(HWND__*, UINT, WPARAM, LPARAM)':
main.cpp:76: error: `IDD_ABOUT' undeclared (first use this function)
main.cpp:76: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:76: error: `hwnd' undeclared (first use this function)
main.cpp:72: warning: unreachable code at beginning of switch statement
Thank you in advance, and if any1 can help through IM my AIM screen name is: MetalChansey18![]()



LinkBack URL
About LinkBacks



