I have defined menu in the following way; MENUITEM "&New\tCtrl+N",1 MENUITEM "&Open...\tCtrl+O",2 MENUITEM "&Save\tCtrl+S",3 MENUITEM "Save &As\tF12",4 I know how to define for Save As, VK_F12,4,VIRTKEY but how to define for New, Open .... Thanks, e-nigma PS: please comment, which one is better to use; MENUITEM "&New\tCtrl+N",1 or MENUITEM "&New\tCtrl+N",IDM_NEW ******** 1 or IDM_NEW
Posted on 2001-01-10 06:38:00 by e-nigma
1 or IDM_NEW, that is the question. Weather tis nobler to suffer the slings and arrows of outragous program crashes, or to rise UP, and alias all your magic number constants, and thus define them. Actually, it all comes down to your own style. MY preference is to go the IDM_NEW route, so the NAME of the CONSTANT gives me a hint as to what it's doing. Without knowing a thing, if I see "IDM_NEW" I'm already thinking "Seems like it's a menu handler for something NEW." If I see "1" I'm thinking "where did that magic number come from? I wonder what it does." Now to make this work, you have to define this number TWICE, once in "C" for your resource file, and once in MASM for your .asm file. The counter agrument to mine is that defining a number twice can lead to disaster when the resource thinks IDM_NEW is 1000 and the .asm thinks it's 1. Programs quite happily builds, but does not work. Quite true. And if that bothers you, automate the 2nd file. Make a .h file of equates for the resource and include it there. Then run the .h through h2inc to get a MASM version of it, and include that in the .asm. Yep, messy, especialy in large projects. I just added 2 more files to the project. If you do it this way the same way every time, you can establish a convention that makes sense, such as naming them: rsrc.rc the resource file itself rsrc.h equates for the resource (needed in rsrc.rc) rsrc.inc EQU's for the .asm (needed in xxxx.asm) _ (made by h2inc) Adding a line to the MASM32 bat files to handle this for you would make the process almost invisible. For myself, I added a bat file that just handles the .h to .inc transformation so I deciede when I need to do this (I like NEAT source code, and always edit the whitespace in h2inc outputs)
Posted on 2001-01-10 12:22:00 by Ernie
Still could not do it right. Whenever user press CTRL+O, the program should; 1)open the OPEN dialog box. 2)open the selected file It happily does all the things expect it puts "o" in the edit control as if the user had typed it. MENU: MENUITEM "&Open\tCtrl+O", IDM_OPEN ACCELE: "O", IDM_OPEN, VIRTKEY, CONTROL puts o in the edit control along with the file opened. So if the file contains "This is a test message" then it will look like "oThis is a test message" I don't know what I'm doing wrong. thanks, e-nigma
Posted on 2001-01-11 01:59:00 by e-nigma
If TranslateAccelerator succeeds, you must skip the TranslateMessage-DispatchMessage code. The keyboard messages have already been dispatched. If, on success, you fall through to DispatchMessage, the keyboard message gets dispatched twice.
Posted on 2001-01-11 23:21:00 by tank
Posted on 2001-01-12 10:19:00 by e-nigma