flat assembler
Message board for the users of flat assembler.

Index > Windows > [SOLVED] MDI editor and TranslateAccelerator

Author
Thread Post new topic Reply to topic
frech



Joined: 10 Mar 2009
Posts: 31
frech
Hi.

I'm facing a problem with my MDI editor: I can't use accelerators. I used a resource editor (and compiled the result with GoRC) to prepare an options dialog, to add icons and now I want to add some shortcuts for the user. Ctrl+X/C/V are already recognized by the RichEdit control, so I simply need to show them in the menu, but I need to add one to open and save a document, one to create a new one and other two to compile the file edited by the user.
Here is the part of the resource file created with the editor:
Code:
IDR_ACCEL ACCELERATORS
BEGIN
  78,IDM_NEW,VIRTKEY,CONTROL,NOINVERT
  79,IDM_OPEN,VIRTKEY,CONTROL,NOINVERT
  83,IDM_SAVE,VIRTKEY,CONTROL,NOINVERT
END    
, and here is the message loop I use:
Code:
  msg_loop:
 invoke  GetMessage,msg,NULL,0,0
     or      eax,eax
     jz      end_loop
        invoke  TranslateMDISysAccel,[hwnd_client],msg
        .if eax = 0
            invoke      TranslateAccelerator,[hwnd_client],[hAccel],msg
            .if eax = 0
                invoke       TranslateMessage,msg
                invoke  DispatchMessage,msg
            .endif
        .endif
 jmp     msg_loop    
Of course I loaded the accelerator table with
Code:
invoke  LoadAccelerators,[hinstance],IDR_ACCEL
mov     [hAccel],eax    
I tried also to connect the accelerator to [hwnd_frame] instead of [hwnd_client], even it should not be so, but no way.
Any tip? Thx in advance!


Last edited by frech on 23 Apr 2009, 11:34; edited 1 time in total
Post 23 Apr 2009, 08:01
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Is the handle, returned by LoadAccelerators ok? Check eax for 0 (function failed) before saving the handle to memory.
Post 23 Apr 2009, 08:45
View user's profile Send private message Reply with quote
frech



Joined: 10 Mar 2009
Posts: 31
frech
I tried, it seems to be ok. I enclose a zip file with the program until now.


Description:
Download
Filename: ISIDE.zip
Filesize: 27.44 KB
Downloaded: 34 Time(s)

Post 23 Apr 2009, 08:55
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Why not use hwnd_frame handle instead of hwnd_client?
Code:
            invoke      TranslateAccelerator,[hwnd_frame],[hAccel],msg
    


Second, instead of comparing whole wparam with the ID, only compare the lowerword of wparam!
Code:
        cmp     word[wparam],IDM_NEW
        je      .fm_new
    
Post 23 Apr 2009, 11:09
View user's profile Send private message Reply with quote
frech



Joined: 10 Mar 2009
Posts: 31
frech
Thx pete! Now it works perfectly! I've tried using [hwnd_frame], but without result. I supposed that just comparing wparam was enough, I didn't imagine that comparing the whole wparam was the origin of the problem... Now I added also the other accelerators I need for the moment. Thanks, really thanks!
Post 23 Apr 2009, 11:33
View user's profile Send private message Visit poster's website Reply with quote
pete



Joined: 20 Apr 2009
Posts: 110
pete
Make use of dbmon.exe and OutputDebugString Function; these help you when debugging your applications!
Post 23 Apr 2009, 11:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.