Is it possible to remove a callback?

Just starting out? Need help? Post your questions and find answers here.
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Is it possible to remove a callback?

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

1. Use SetWindowCallback(0).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

2)

Code: Select all

GetWindowLong_(WindowID(#win), #GWL_WNDPROC))
I may look like a mule, but I'm not a complete ass.
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Post by sverson »

@Trond + srod
Thanks!

;-) sverson
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

To remove/disable a previous set Callback just call SetWindowCallback(0) again.
Just added this to the manual. :)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Post 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
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post 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]).
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post 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
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Ok, thanks for the latest comments.

I will try what I can do about the manual... :wink:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply