subclassing from a PB library

Everything else that doesn't fall into one of the other PB categories.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

subclassing from a PB library

Post by localmotion34 »

Code: Select all

Procedure pptproc( hwnd, msg,  wParam, lParam) 
  Select msg 
    Case #WM_LBUTTONUP
      scrollareachild=pptLVstruct(a)\scrollareachild
      pptnumber=CountList(PptLVnumber()) 
      For a=0 To pptnumber-1 
        ClearList(FindChild()) 
        EnumChildWindows_(pptLVstruct(a)\scrollareachild, @EnumChildProc(), 0) 
        ResetList(FindChild()) 
        ForEach FindChild() 
          Index = ListIndex(FindChild()) 
          If hwnd = FindChild()\childwindowhandle 
            SendMessage_(FindChild()\childwindowhandle,#BM_SETCHECK,#BST_UNCHECKED,0)
            ForEach FindChild() 
              If hwnd <> FindChild()\childwindowhandle 
                SendMessage_(FindChild()\childwindowhandle,#BM_SETCHECK,#BST_UNCHECKED,0) 
              EndIf 
            Next 
          EndIf 
        Next 
      Next 
  EndSelect  
  ProcedureReturn CallWindowProc_(origproc(0),hwnd,msg,wParam,lParam) 
EndProcedure    
ok thats my little subclass procedure to handle user clicks on my custom gadget.

now my procedure to create the gadget is

Code: Select all

ProcedureDLL PPtListview(number,x,y,width,height,Imagenumber)
;;;;;yadayada
origproc(0)= SetWindowLong_(GadgetID(pptLVstruct(Index)\childimages[a]), #GWL_WNDPROC, @pptproc())
endprocedure

NOTE that i use an ARRAY to handle the return from setwindowlong, and LINKED LISTS take care of the gadget handles so that they are accessible from anywhere.

when i tailbite the code to a PB lib, and test the gadget out, the pptproc() subclassing does NOT work. doesnt tailbite when compiling look at the procedure where the subclassing is pointing to and include that code?

any help is appreciated to get this code to work. i DO NOT want to use setwindowcallback(), as i am trying to AVOID that. i want to be able to subclass from a tailbitten compiled PB library.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

storing data that way could get you into msg thread issues anyway... there's a far simpler/safer solution...

Code: Select all

ProcedureDLL PPtListview(number,x,y,width,height,Imagenumber)
;;;;;yadayada
hwnd=GadgetID(pptLVstruct(Index)\childimages[a])
;/Set a Thread-Safe Prop :)
  SetProp_(hwnd,"OldProc",SetWindowLong_(hwnd, #GWL_WNDPROC, @pptproc()))

Code: Select all

Procedure pptproc( hwnd, msg,  wParam, lParam)
  Select msg
    Case #WM_LBUTTONUP
      scrollareachild=pptLVstruct(a)\scrollareachild
      pptnumber=CountList(PptLVnumber())
      For a=0 To pptnumber-1
        ClearList(FindChild())
        EnumChildWindows_(pptLVstruct(a)\scrollareachild, @EnumChildProc(), 0)
        ResetList(FindChild())
        ForEach FindChild()
          Index = ListIndex(FindChild())
          If hwnd = FindChild()\childwindowhandle
            SendMessage_(FindChild()\childwindowhandle,#BM_SETCHECK,#BST_UNCHECKED,0)
            ForEach FindChild()
              If hwnd <> FindChild()\childwindowhandle
                SendMessage_(FindChild()\childwindowhandle,#BM_SETCHECK,#BST_UNCHECKED,0)
              EndIf
            Next
          EndIf
        Next
      Next
  EndSelect 
  ProcedureReturn ProcedureReturn 

;/Using the Prop
CallWindowProc_(GetProp_(hwnd,"OldProc"),hwnd,msg,wParam,lParam)
EndProcedure
Post Reply