I have subclassed controls before and they have worked fine,
but for some reason this subclass of an entire window from
a dialog is not working. The modal dialog calls the window
and it draws successfully, but when it closes, the dialog
callback is still disabled, so the program cannot resume.
I'm re-setting the callback to the previous callback, but I
think it is going to the main wndproc instead of the dialogproc.
Anyone ever had this problem? I can't find any documentation
that says you can't subclass a window from a modal dialog, yet
it isn't working. I've included a simple shell of what I'm
doing below; anybody see a reason why it wouldn't return control
to the dialog callback?
Thanks,
Jim Seekamp
global hbrks&
style&=%ws_popup or %ws_visible or %ws_caption or %ws_sysmenu or %ws_maximizebox or %ws_minimizebox
hwnd&=createwindow(wclassname,_ ''window class name
wcaption,_ ''window caption
style&,_ ''window style
0,_ ''initial x position
0,_ ''initial y position
640,_ ''initial x size
480,_ ''initial y size
htakeoff&,_ ''parent window handle
%null,_ ''window menu handle
hinstance&,_ ''program instance handle
%null) ''creation parameters
hbrks&=setwindowlong(hwnd&,%gwl_wndproc,codeptr(brkproc))
showwindow hwnd&,%sw_show
updatewindow hwnd&
end sub
function brkproc(byval hwnd&,byval msg&,byval a&,byval xparam&) as long
select case msg&
case %wm_paint
dim ps as paintstruct
hdc&=beginpaint(hwnd&,ps)
''drawing takes place successfully here
deletedc hdc&
exit function
case %wm_syscommand
if lowrd(a&)=%sc_close then
destroywindow hwnd&
function=1
exit function
end if
case %wm_destroy
setwindowlong hwnd&,%gwl_wndproc,hbrks&
exit function
end select
function=callwindowproc(codeptr(wndproc),hwnd&,msg&,a&,xparam&)
end function
-------------
Jim Seekamp
but for some reason this subclass of an entire window from
a dialog is not working. The modal dialog calls the window
and it draws successfully, but when it closes, the dialog
callback is still disabled, so the program cannot resume.
I'm re-setting the callback to the previous callback, but I
think it is going to the main wndproc instead of the dialogproc.
Anyone ever had this problem? I can't find any documentation
that says you can't subclass a window from a modal dialog, yet
it isn't working. I've included a simple shell of what I'm
doing below; anybody see a reason why it wouldn't return control
to the dialog callback?
Thanks,
Jim Seekamp
global hbrks&
style&=%ws_popup or %ws_visible or %ws_caption or %ws_sysmenu or %ws_maximizebox or %ws_minimizebox
hwnd&=createwindow(wclassname,_ ''window class name
wcaption,_ ''window caption
style&,_ ''window style
0,_ ''initial x position
0,_ ''initial y position
640,_ ''initial x size
480,_ ''initial y size
htakeoff&,_ ''parent window handle
%null,_ ''window menu handle
hinstance&,_ ''program instance handle
%null) ''creation parameters
hbrks&=setwindowlong(hwnd&,%gwl_wndproc,codeptr(brkproc))
showwindow hwnd&,%sw_show
updatewindow hwnd&
end sub
function brkproc(byval hwnd&,byval msg&,byval a&,byval xparam&) as long
select case msg&
case %wm_paint
dim ps as paintstruct
hdc&=beginpaint(hwnd&,ps)
''drawing takes place successfully here
deletedc hdc&
exit function
case %wm_syscommand
if lowrd(a&)=%sc_close then
destroywindow hwnd&
function=1
exit function
end if
case %wm_destroy
setwindowlong hwnd&,%gwl_wndproc,hbrks&
exit function
end select
function=callwindowproc(codeptr(wndproc),hwnd&,msg&,a&,xparam&)
end function
-------------
Jim Seekamp
Comment