|
From: Abhijit S. <mu...@gm...> - 2002-09-10 15:17:03
|
----- Original Message -----
From: "Vlada Djurovic" <dj...@im...>
To: "'Abhijit Shylanath'" <mu...@gm...>
Sent: Monday, September 09, 2002 1:09 PM
Subject: RE: [Dev-C++] no menu
>
>
>> Can you post some code?
>
> Sorry foe the delay, here's the code:
> Header:resource.h
> #define IDR_MENU 100
> #define ID_FILE_EXIT 110
> #define ID_DIALOG_SHOW 120
> #define ID_DIALOG_HIDE 121
>
>
> Resorce:rsFile.rc
> #include <resource.h>
> #include <windows.h>
>
> IDR_MENU MENU
> BEGIN
> POPUP "&File"
> BEGIN
> MENUITEM "E&xit",ID_FILE_EXIT
> END
> POPUP "&Dialog"
> BEGIN
> MENUITEM "&Show",ID_DIALOG_SHOW
> MENUITEM "&Hide",ID_DIALOG_HIDE
> END
> END
>
> Source:main.c
>
> #include <windows.h>
> #include <resource.h>
> LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
> char szClassName[ ] = "WindowsApp";
> int WINAPI
> WinMain (HINSTANCE hThisInstance,
> HINSTANCE hPrevInstance,
> LPSTR lpszArgument,
> int nFunsterStil)
>
> {
> HWND hwnd;
> MSG messages;
> WNDCLASSEX wincl;
> wincl.hInstance = hThisInstance;
> wincl.lpszClassName = szClassName;
> wincl.lpfnWndProc = WindowProcedure;
> wincl.style = CS_DBLCLKS;
> wincl.cbSize = sizeof (WNDCLASSEX);
>
> wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
> wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
> wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
> wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
> wincl.cbClsExtra = 0;
> wincl.cbWndExtra = 0;
> wincl.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
>
>
> if (!RegisterClassEx (&wincl))
> return 0;
>
>
> hwnd = CreateWindowEx (
> WS_EX_CLIENTEDGE,
> szClassName,
> "Windows App",
> WS_OVERLAPPEDWINDOW,
> CW_USEDEFAULT,
> CW_USEDEFAULT,
> 544,
> 375,
> HWND_DESKTOP,
> NULL,
> hThisInstance,
> NULL
> );
>
>
> ShowWindow (hwnd, nFunsterStil);
> UpdateWindow(hwnd);
>
> while (GetMessage (&messages, NULL, 0, 0))
> {
>
> TranslateMessage(&messages);
>
> DispatchMessage(&messages);
> }
>
>
> return messages.wParam;
> }
> LRESULT CALLBACK
> WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
> switch (message)
> {
> case WM_DESTROY:
> PostQuitMessage (0);
> break;
> default:
> return DefWindowProc (hwnd, message, wParam, lParam);
> }
>
> return 0;
> }
Wherever you've specified #include <resource.h>, change it to "resource.h"
and it should work. #include <file> searches for `file' in the standard
directories only, while #include "file" searches in the current directory
first and then the standard directories. So, right now, it's like
`resource.h' isn't included at all, and it treats all references to the IDs
(IDI_APPLICATION, etc.) as strings, which would be used like this:
wincl.lpszMenuName = IDR_MENU)
(note the absence of MAKEINTRESOURCE(), which converts an int into a
specially flagged string)
HTH.
PS: Please pursue this on the list, by clicking `Reply all' instead of
`Reply'... better not leave too many loose ends in the archives.
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|