SetGadgetCallback(@ProcedureName() [, #Gadget)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

SetGadgetCallback(@ProcedureName() [, #Gadget)

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Can you not use a window ID for that? A gadget is a window.
Last edited by netmaestro on Tue Feb 21, 2006 3:30 pm, edited 2 times in total.
BERESHEIT
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Maybe it would be simpler if #window was abandoned in favour of just hwnd for everythin. Or would that cause problems?
Last edited by netmaestro on Tue Feb 21, 2006 3:32 pm, edited 3 times in total.
BERESHEIT
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

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

Post by RSBasic »

This (old) feature request is very useful. Image
Image
Image
Post Reply