News:

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

Superclassing & static

Started by angvelem, April 08, 2011, 08:28:38 PM

Previous topic - Next topic

angvelem

.data
  StaticClassProc WNDPROC    0
  szStatic           BYTE    'STATIC', 0

NewStaticWndProc proc Win, uMsg, wParam, lParam : DWORD
  invoke CallWindowProc, StaticClassProc, Win, uMsg, wParam, lParam
  ret
NewStaticWndProc endp

...
  LOCAL wc : WNDCLASSEX
...
    case WM_INITDIALOG
      .if !StaticClassProc
        mov    wc.cbSize,        sizeof WNDCLASSEX
        invoke GetClassInfoEx, 0, ADDR szStatic, ADDR wc
        mrm    StaticClassProc,  wc.lpfnWndProc
        mrm    wc.lpfnWndProc,   offset NewStaticWndProc
        mrm    wc.hInstance,     hInstance
        mov    wc.lpszClassName, offset szStatic
        mov    eax,              wc.style
        and    eax,              not CS_GLOBALCLASS
        mov    wc.style,         eax
        invoke RegisterClassEx, ADDR wc
      .endif

Trying subclassing Static controls, searching around the internet, but nothing worthwhile is not found. This code is normally executed, registration is successful, but the message in a new processor does not come. Tell me where I wrong? Do not want to do a separate subclassing for each control.

Clarification: uses MASM

jj2007

Usual code would look like this:

invoke CreateWindowEx, NULL, addr ClassStatic, addr txStatic,
WS_CHILD or WS_VISIBLE or ES_LEFT, 0, 0, 0, 0,
hWnd, IdStatic, hInstance, NULL
mov hStatic, eax ; static window created
invoke SetWindowLong, hStatic, ; we subclass the static control
GWL_WNDPROC, SubStatic
mov opSubStatic, eax ; the old pointer
....
SubStatic proc hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
invoke SetWindowText, hEdit, str$(uMsg)
SWITCH uMsg
CASE WM_NCHITTEST
invoke SetWindowText, hEdit, chr$("MOVE")
ENDSW
invoke Sleep, 1
; subclassing finished, continue with default handler
  invoke CallWindowProc, opSubStatic, hwnd, uMsg, wParam, lParam
  ret
SubStatic endp


This works fine, but the problem is that a static control hardly receives any useful messages...

qWord

Quote from: angvelem on April 08, 2011, 08:28:38 PM... but the message in a new processor does not come. Tell me where I wrong? Do not want to do a separate subclassing for each control.
so you want apply your subclass system wide (in all running processes) ?
FPU in a trice: SmplMath
It's that simple!

angvelem

Quote from: qWord on April 08, 2011, 09:10:44 PM
Quote from: angvelem on April 08, 2011, 08:28:38 PM... but the message in a new processor does not come. Tell me where I wrong? Do not want to do a separate subclassing for each control.
so you want apply your subclass system wide (in all running processes) ?

Read carefully:   and    eax,              not CS_GLOBALCLASS

angvelem

Quote from: jj2007 on April 08, 2011, 09:04:56 PM
Usual code would look like this:

I know this way, this is a crutch

qWord

Quote from: angvelem on April 08, 2011, 09:17:06 PM
Quote from: qWord on April 08, 2011, 09:10:44 PM
Quote from: angvelem on April 08, 2011, 08:28:38 PM... but the message in a new processor does not come. Tell me where I wrong? Do not want to do a separate subclassing for each control.
so you want apply your subclass system wide (in all running processes) ?

Read carefully:   and    eax,              not CS_GLOBALCLASS

angvelem, you should read what you have written :tdown
FPU in a trice: SmplMath
It's that simple!

angvelem

I have understood, on this forum can not read. :bg Feel sorry. :'( But question is solved, subject locked.