Page 1 of 1

Is it possible to remove a callback?

Posted: Tue Jun 06, 2006 7:11 pm
by sverson
1. Is it possible to remove or disable the callback after SetWindowCallback() :?:
2. How can i find out the function adress of the current callback :?:

THX sverson

Posted: Tue Jun 06, 2006 7:26 pm
by Trond
1. Use SetWindowCallback(0).

Posted: Tue Jun 06, 2006 8:46 pm
by srod
2)

Code: Select all

GetWindowLong_(WindowID(#win), #GWL_WNDPROC))

Posted: Tue Jun 06, 2006 9:17 pm
by sverson
@Trond + srod
Thanks!

;-) sverson

Posted: Thu Jun 08, 2006 4:59 pm
by Andre
To remove/disable a previous set Callback just call SetWindowCallback(0) again.
Just added this to the manual. :)

Posted: Thu Jun 08, 2006 7:42 pm
by sverson
@Andre:
To remove/disable a previous set Callback just call SetWindowCallback(0) again.
Just added this to the manual. :)
Thanks!

- Could you please put a hint and/or a link from "Misc"/"File"/"FileSystem" to ProgramFilename()? - I would not search it in "Process". (or move it to Misc?!?)
- Could you please put a hint and/or a link from "Winow" to DesktopWidth(#Desktop)/DesktopHeight(#Desktop) in "Desktop"?

e.g.
  • GetFilePart()
    ...
    Viele weitere nützliche Befehle rund um die Verwendung von Dateien finden Sie in den File, FileSystem und Process Bibliotheken.
    ========================
    WindowWidth(#Window)
    ...
    Die Breite des aktuellen Desktops können Sie mit DesktopWidth(#Desktop) aus der Bibliothek Desktop ermitteln.
Thanks ;-) sverson

Posted: Sat Jun 10, 2006 10:35 am
by Dräc
Andre wrote:
To remove/disable a previous set Callback just call SetWindowCallback(0) again.
Just added this to the manual. :)
Today this sentence is incomplete: The 0 is used to cancel the CallBack procedure address pointer, but with the v4, it is also necessary to specify the targeted window.
Thus the sentence should be in my opinion:

To remove/disable a Callback defined by SetWindowCallback (@ProcedureName [, #Window]), just call SetWindowCallback (0 [, #Window]).

Posted: Sat Jun 10, 2006 11:10 am
by Trond
Dräc wrote:but with the v4, it is also necessary to specify the targeted window.
No it isn't neccessary, it's optional.

Posted: Sat Jun 10, 2006 11:24 am
by Dräc
It is why I said “incomplete” and the sentence is :

To remove/disable a Callback defined by SetWindowCallback (@ProcedureName [, #Window]), just call SetWindowCallback (0 [, #Window]).

Try yourself ;)

Code: Select all

Procedure.l WinProc(hWnd,Msg,wParam,lParam)
   result = #PB_ProcessPureBasicEvents
   Select Msg
      Case #WM_NOTIFY
         Debug "call : clic column"
         
         *NMHDR.NMHDR = lParam
         
         If *NMHDR\hWndFrom = GadgetID(1)
            If *NMHDR\code = #LVN_COLUMNCLICK
               *NMLV.NMLISTVIEW = lParam
               column = *NMLV\iSubItem
               Debug "call: clic on column : "+Str(column)
            EndIf
         EndIf
   EndSelect
   ProcedureReturn result
EndProcedure

#Window = 10

OpenWindow(#Window, 0, 0, 300, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
CreateGadgetList(WindowID(#Window))
ListIconGadget(1,10,10,280,200,"col1",50)
For i=1 To 4
   AddGadgetColumn(1, i,Str(i),50)
Next

For i=1 To 4
   AddGadgetItem(1, i,Str(i))
Next

; SetWindowCallback(@WinProc())
SetWindowCallback(@WinProc(), #Window)

SetWindowCallback(0) 
; SetWindowCallback(0, #Window)

Repeat
   event = WaitWindowEvent()

   Select event
      Case #WM_NOTIFY
         Debug "pure : clic column"
         
      Case #PB_Event_Gadget
         Select EventGadget()
            Case 1
               Debug "pure :clic on list"
               Debug EventlParam()
               Debug EventwParam()
               
             
         EndSelect
         
   EndSelect
   
Until event = #WM_CLOSE

Posted: Mon Jun 12, 2006 5:07 pm
by Andre
Ok, thanks for the latest comments.

I will try what I can do about the manual... :wink: