News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Accelerators Q

Started by DC, February 26, 2006, 03:07:56 AM

Previous topic - Next topic

DC

I have this:
;    RC FILE:

#define IDM_PRINT 0
#define IDM_SAVEAS 2
#define IDM_PREFS 3
#define IDA_ACCEL1 100

IDA_ACCEL1 ACCELERATORS
BEGIN
"S", IDM_SAVEAS, VIRTKEY, NOINVERT, CONTROL
"P", IDM_PRINT, VIRTKEY, NOINVERT, CONTROL
VK_F2, IDM_PREFS, VIRTKEY, NOINVERT
END
;===============================================
;    INC FILE:

IDM_PRINT       equ 0
IDM_SAVEAS      equ 2
IDM_PREFS       equ 3
IDA_ACCEL1      equ 100
;===============================================
;   ASM FILE:

start:
    invoke  GetModuleHandle, NULL
    mov     hInstance, eax
    invoke  LoadAccelerators, hInstance, IDA_ACCEL1
    mov     hAcc, eax
   
;   ... winmain ...

    .while  TRUE
        invoke   GetMessage, addr msg, 0, 0, 0
        .break  .if (!eax)
            invoke  TranslateAccelerator, hwnd, hAcc, addr msg
        .if !eax
            invoke  TranslateMessage, addr msg
            invoke  DispatchMessage, addr msg
        .endif
    .endw
    mov     eax, msg.wParam
    ret
WinMain endp

and the accelerators don't work, am I forgetting something or doing something wrong (I really do search for answers before asking) :red
thanx,
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

donkey

Everything looks OK, but I would try some more realistic values for the command IDs of the accelerators, if you ignore the upper WORD of wParam in WM_COMMAND, 0,1 and 2 are all reserved by Windows (NULL, OK and CANCEL). Other than that (probably) benign point I can see no error.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

DC

hhhhmmmmm....
I changed them 101-103...
still not working
I'll put the whole thing up again... it's a WinASM project
'F2', ctl+'s', and ctl+'p' should pull up Dlg's,
thanx,
DC

[attachment deleted by admin]
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

Mincho Georgiev

Let me guess  :P - you didnt pass the LOWORD through the wParam check :)
It MUST be that way:
Quote
.if uMsg == WM_COMMAND
  mov eax,wParam
  and eax,0ffffh
;//and now you can make the check
  .if wParam == IDM_WHATEVER
     ;///some code
  .endif
.endif

When you using accelerators the DWORD value in wParam isn't working.

p.s. Yeah, i was right ,i saw your app.
here:


[attachment deleted by admin]

DC

thanx shaka_zulu,
that's a detail that could've kept me stumpt for a long time.
take care,
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net