hey... i put this code along with WM_CREATE in the mdichildproc. the app crashes. What am i doing wrong?
.if uMsg==WM_CREATE
invoke MdiCreateWindows,hWnd
invoke GetWindowLong,hWnd,GWL_USERDATA
mov edi,eax
invoke SetWindowLong,[edi.MdiStruct.hEdit],GWL_WNDPROC,addr EditProc
mov [edi.MdiStruct.lpfnEditProc],eax
and also this:
EditProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg==WM_CHAR
invoke MessageBeep,MB_OK
jmp cwp
.else
cwp:
invoke SendMessage,hMdi,WM_MDIGETACTIVE,0,0
invoke GetWindowLong,eax,GWL_USERDATA
invoke CallWindowProc,[eax.MdiStruct.lpfnEditProc],hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
EditProc endp
thabks in advance for help
I don't understand very well why you need to subclass a mdi windows.
You need subclassing to get an event loop on a control for example.
Creating a subclass for a mdi is not needed because you have already an event loop,the classic WNDProc.
Even without error code,make an attempt to create another event loop could only crash.
the subclass is for the edit control. thanks
Here a sample of subclasing for an Hedit (handle of an edit control)
Quote
; Event_Hedit PROTO :DWORD,:DWORD,:DWORD,:DWORD
;.data
; ~~~~~~~~~~~~~~~~~~~~~
Prev_Event_Hedit dd ?
;
invoke SetWindowLong,HHedit,GWL_WNDPROC,Event_Hedit
mov Prev_Event_Hedit, eax ;retourne l'adresse de la premiere procédure
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Event_Hedit proc hwnd:DWORD, uMsg, wParam, lParam
Local retour:DWORD
mov retour,0 ;la plus commune des valeurs de retour
.if uMsg ==
.elseif uMsg ==
.else
invoke CallWindowProc,Prev_Event_Hedit,hwnd,uMsg,wParam,lParam
mov retour,eax
.endif
mov eax,retour
ret
Event_Hedit endp
Thanks Tout...
works fine with a global variable. The thing is i was trying to put the original lpfnEditProc in a structure pointed by edi. Thanks Tout
The architecture of Windows requires a variable of GLOBAL scope for a subclass return value, just ensure that each global name is unique.
Quote from: xandaz on December 03, 2020, 01:27:32 AM
invoke GetWindowLong,eax,GWL_USERDATA
invoke CallWindowProc,[eax.MdiStruct.lpfnEditProc],hWnd,uMsg,wParam,lParam
Using GWL_USERDATA instead of a global variable is a funny idea but it works, see attachment :cool:
Thanks All