Page 1 of 1

SetGadgetCallback(@ProcedureName() [, #Gadget)

Posted: Tue Feb 07, 2006 2:24 am
by nco2k
now where the AdvancedGadgetEvents() command was dropped, i think it would be a good idea to make a SetGadgetCallback() command for gadgets.

i know it can be done due winapi, like in this example by danilo, for disabling the right mouse click in a string gadget:

Code: Select all

Global oldStringProc

Procedure NewStringProc(hWnd,Msg,wParam,lParam)
  If Msg = #WM_RBUTTONDOWN
    ProcedureReturn 0
  EndIf
  ProcedureReturn CallWindowProc_(oldStringProc,hWnd,Msg,wParam,lParam)
EndProcedure

OpenWindow(1,200,200,400,200,#PB_Window_SystemMenu,"")
   CreateGadgetList(WindowID(1))
   StringGadget(1,10,10,300,20,"")
   oldStringProc = SetWindowLong_(GadgetID(1),#GWL_WNDPROC,@NewStringProc())
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
but a native callback for gadgets would be great, so we could check for everything we could check with AdvancedGadgetEvents() before and many many more. :wink:

c ya,
nco2k

Posted: Tue Feb 07, 2006 2:37 am
by netmaestro
Can you not use a window ID for that? A gadget is a window.

Posted: Tue Feb 07, 2006 2:42 am
by nco2k
i dont think this is possible, because SetWindowCallback(@ProcedureName() [, #Window) needs a #Window constant. it would be possible if the command would need a handle/id which you could get from WindowID()/GadgetID().

c ya,
nco2k

Posted: Tue Feb 07, 2006 2:57 am
by netmaestro
Maybe it would be simpler if #window was abandoned in favour of just hwnd for everythin. Or would that cause problems?

Posted: Tue Feb 07, 2006 3:04 am
by nco2k
the problem is, then you need to always carry the hWnd variable and could maybe lose the overview sometimes. the id numbers are a better choice for beginners imo and can also become sometimes handy for the pro. i personaly dont care, i like the id numbers and the hWnd variables alike, but thats off topic. :wink:

c ya,
nco2k

Re: SetGadgetCallback(@ProcedureName() [, #Gadget)

Posted: Sat Jun 25, 2016 10:36 am
by RSBasic
This (old) feature request is very useful. Image