flat assembler
Message board for the users of flat assembler.

Index > Windows > User message handling without subclassing.

Thread Post new topic Reply to topic

Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 01 Sep 2004, 23:14
Just now I am playing with Fresh library in order to make it more consistent and modular. So, some of the visually created windows have to have user defined procedures for message handling and also, have to support some advanced features as auto alignment/autosize, fonts inheriting, etc.
The main idea is to make all this without subclassing the windows. The approach I am trying is to use API functions: "GetProp" and "SetProp".
The idea is to use:
invoke SetProp, [.hwnd], propUserWinProc, [ptrToUserWindowProcedure]

And instead of setting GWL_WINPROC using SetWindowLong to call user procedure directly from the main message loop:

        invoke  TranslateMessage, esi                           ; So, standard processing.

        invoke  GetProp, [esi+MSG.hwnd], propUserWinProc
        test    eax, eax
        jz      .default        ; there is no user procedure...

; call user procedure if any...
        push    esi edi ebx
        mov     ebx, [esi+MSG.message]
        stdcall eax, [esi+MSG.hwnd], ebx, [esi+MSG.wParam], [esi+MSG.lParam]
        pop     ebx edi esi
        jnc     .msg_loop

        invoke  DispatchMessage, esi
        jmp     .msg_loop

What you think about this kind of approach? Is there some problems I am missing?
Any opinions are welcome.
The simple test example works fine with this approach. The full example code is attached.


P.S. There is small problem with autoalign windows, but it is not related with the user message handling. I will fix it later.

Filename: FreshLib.zip
Filesize: 19.17 KB
Downloaded: 262 Time(s)

Post 01 Sep 2004, 23:14
View user's profile Send private message Visit poster's website ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.