Announcement

Collapse
No announcement yet.

SubClassing Window from Dialog

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    In your CallWindowProc() line, you should be passing the original windows procedure's address (hbrks&) rather then an explicit CODEPTR().

    As Semen points out, you should let the %WM_DESTROY message flow through to CallWindowProc(), so remove the EXIT FUNCTION from that handler.

    Also, try it without the dialog as the parent of the window, but explicitly disable and reenable the dialog by program control instead.

    If you are still having problems, post a complete compilable example of the proble code.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Jim -
    what about inserting additional line
    callwindowproc(codeptr(wndproc),hwnd&,msg&,a&,xparam&)
    after Case %WM_DESTROY before setwindowlong (I mean first of all to supply standart processing)

    ------------------

    Leave a comment:


  • Jim Seekamp
    started a topic SubClassing Window from Dialog

    SubClassing Window from Dialog

    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
Working...
X