-
resource script
is it possible to write a resource script in visual c++, without using the wizards for dialog boxes and such, everytime i open a new resource script i am not able to write anything, just use the templates but i want to learn to write them with code for myself.
How can i do this?
Thanks for your help
-
Big subject, a book will be explain this better than I can.
Code:
MyMenu MENU
{
POPUP "File"
{
MENUITEM "Open", IDM_OPEN
}
MENUITEM "Help", IDM_HELP
}
This is code for a menu, the keyword MENU is what informs the compiler its a menu and MyMenu is the menu name.
A POPUP means that the specified name, in this case file, is a submenu. A MENUITEM is an item the user can select.
The IDM_OPEN & IDM_HELP are the messages windows sends when the corresponding MENUITEM is clicked and you need to define them for example:
#define IDM_OPEN 1000
#define IDM_HELP 1001
You should save the file with a .rc extension, msvc will produce the resource file from that.
A dialog is harder create this way as you need to specify the size of buttons and the position of buttons, which is far easier visually.
Anyway a dialog goes like this:
Code:
MyDB DIALOGEX 10, 10, 210, 110
CAPTION "My Dialog Box"
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_BORDER
{
DEFPUSHBUTTON "Button1", IDD_BUTTON1, 11, 10, 36, 14
PUSHBUTTON "Button2", IDD_BUTTON2, 11, 34, 36, 14
}
A bit more going on here, the keywords should be fairly obvious as to what they do.
As far as the numbers go the first 2 for each item are the position and the second 2 are the size.
You really need to find a book with this in though.