----- Original Message -----
From: <sca...@ne...>
To: <dev...@li...>
Sent: Sunday, August 17, 2003 7:12 AM
Subject: [Dev-C++] Resources
>
> I'm using Dev-C++ Version 4.9.8.1 with Windows98. I have created, compiled
and .exe a window, but I haven't been able to include resources such as
menus, bitmaps or custom cursors in Win32. Could someone help me to get
started? Thanks.
>
On second thought, you might have problems with the way Dev-C++ handles
resources.
After creating a new C template application, you'll need further steps to
include resources in your project.
I'm creating a project named "example" to explain the steps needed.
Step 1:
Project -> Project Options -> Version Info
check this box:
Include version information in project
Dev-C++ automatically creates these files:
example_private.rc and example_private.h
Note this file: example_private.rc.
Step 2a
File -> New -> Resource File
name it as, for example:
example.rc
You can write your Resource statements here:
My example is:
#include "exampleres.h" // This line is very important
IDR_MYMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Stuff"
BEGIN
MENUITEM "&Go", ID_STUFF_GO
MENUITEM "G&o somewhere else", 0, GRAYED
END
END
Note that Dev-C++ does not have a Visual Resource editor. :-(
Step 2b
Create another new file and name it:
exampleres.h
You should put your defines here, for example:
#define IDR_MYMENU 101
#define IDI_MYICON 201
#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
Step 3:
Edit example_private.rc
Add this line just below in the window.h include:
#include "example.rc"
Step 4
In main.c
Step A
#include <windows.h>
#include "exampleres.h" // add this line just below windows.h
Step B
wincl.lpszMenuName = NULL; /* No menu */
// remove this line
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); // replace with this
line
Step 5
The Build the project and you should see the menu
Step 6
The next step is to respond to menu clicks.
In main.c, in the WindowProcedure, add this:
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
case ID_STUFF_GO:
MessageBox(hwnd, "Stuff Go! menu item called!", "Hello!",
MB_OK | MB_ICONINFORMATION);
break;
}
break;
Well, those are the steps you need to know if you want to use resources in
Dev-C++.
If you need the project source codes in a zip file, please e-mail me.
Best Regards,
Yeoh
--
|