Page 1 of 1

sending keystrokes to gadgets

Posted: Mon Aug 04, 2003 3:04 pm
by waffle
not sure if this is a bug or other problem....
the webgadget does not seem to receive windows messages unless actually clicked on. I tried activategadget, and it worked with the string gadget, but not the web gadget. Basically, i want to show an image (.gif) in a web gadget and then scroll the image around without user input. Sounds wierd i know, but its so i can "crop" the image properly and hide the web gadgets default scroll bars.

here's some test code:
; PureBasic Visual Designer v3.72


;- Window Constants
;
#Window_0 = 0

;- Gadget Constants
;
#Gadget_0 = 0
#Gadget_1 = 1
#Gadget_2 = 2
#Gadget_3 = 3
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 600, 300, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
If CreateGadgetList(WindowID())
StringGadget(#Gadget_0, 10, 30, 500, 40, "")
ButtonGadget(#Gadget_1, 10, 90, 60, 30, "tryit")
WebGadget(#Gadget_2, 10, 160, 50, 50, "About: see if you can scroll this")
ButtonGadget(#Gadget_3, 150,90,60,30,"Send")
EndIf
EndIf
EndProcedure


Open_Window_0()
SetForegroundWindow_(WindowID())
hGadget.l=GadgetID(#Gadget_0)
setfocus_(hGadget)
keybd_event_(74,0,0,0)

Repeat
quit.l=WindowEvent()
If quit=#PB_EventGadget
Select EventGadgetID()
Case #Gadget_1
;FreeGadget(#Gadget_2)
m.s=GetGadgetText(#Gadget_0)
SetGadgetText(#gadget_2,m)
Delay(20)
;WebGadget(#Gadget_2, 10, 160, 500, 90, GetGadgetText(#Gadget_1))
Case #Gadget_3
;send a command to webgadget
sendmessage_(GadgetID(#Gadget_2),#WM_HSCROLL,#SB_LINEUP,0)
EndSelect
EndIf
Delay(1)
Until quit=#PB_Eventclosewindow

Posted: Mon Aug 04, 2003 3:42 pm
by waffle
i found a solution... not perfect, but pretty good...

place this code in the send event
scrollwindow_(GadgetID(#Gadget_2),-10,-15,0,0)
this will scroll the image, scrollbars and all. But, if i make the web gadget big enough that the scrollbars are offscreen, who cares.