Author Topic: Message loop in masm64  (Read 110 times)

greenozon

  • Regular Member
  • *
  • Posts: 30
Message loop in masm64
« on: November 22, 2022, 12:45:47 AM »
A question regarding message loop

in masm32 one could write the following one:

    .WHILE TRUE
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
    .ENDW

but it doesn't compile in masm64

any hints why?

BugCatcher

  • Member
  • **
  • Posts: 84
Re: Message loop in masm64
« Reply #1 on: November 22, 2022, 02:12:13 AM »
Read masm64 help file. .WHILE

greenozon

  • Regular Member
  • *
  • Posts: 30
Re: Message loop in masm64
« Reply #2 on: November 22, 2022, 04:09:39 AM »
ml64  complains on this piece of code

.BREAK .IF (!eax)

C3

  • Regular Member
  • *
  • Posts: 14
Re: Message loop in masm64
« Reply #3 on: November 22, 2022, 05:30:05 AM »
Hi greenozon,

I'll answer your both questions, this is how I use .while/.endw and how I have implemented message-loop:

Code: [Select]
    .while TRUE
        invoke GetMessage,ADDR msg,NULL,0,0
        .break .if (rax==0)
        invoke TranslateAccelerator,hwnd,hAccel,ADDR msg
        .if (rax==0)
            invoke TranslateMessage,ADDR msg
            invoke DispatchMessage,ADDR msg
        .endif
    .endw

I think you have problem with the macros, use lowercase for .while and .endw

greenozon

  • Regular Member
  • *
  • Posts: 30
Re: Message loop in masm64
« Reply #4 on: November 22, 2022, 06:10:58 AM »
Excellent info!
thanks a lot

PS in case my app does not have accelerators - I guess the block of TranslateAccelerator might be omitted..

C3

  • Regular Member
  • *
  • Posts: 14
Re: Message loop in masm64
« Reply #5 on: November 22, 2022, 06:16:20 AM »
Yes, you don't need TranslateAccelerator unless you someday want to add Accelerator Resource to your Window. Just remove pieces that are not useful.