help with returning image events
Posted: Mon Nov 24, 2003 3:31 pm
ok i have a program i am writing as a database for my PHD dissertation research. i have a window with 10 tabs, 6 image gadgets each. i want to be able to paste an image from Clampfit(its software that traces electrophysiological readings). the traces are able to be copied from clampfit and pasted into anything else. what i want to be able to do is when the mouse hovers over an image gadget, i want to be able to right click, have a popup menu appear, click on "paste" and have the image be pasted into the image the mouse is over. then move to the next or any other 59 images and do the same. ive worked with the ismouseovergadget and got the popup to appear, but i cant seem to figure out how to return the actual image gadget i am over to paste the image into.
Procedure IsMouseOverGadget(Gadget)
target1=Gadget
GetWindowRect_(GadgetID(Gadget),GadgetRect.RECT)
GetCursorPos_(mouse.POINT)
If mouse\x>=GadgetRect\Left And mouse\x<=GadgetRect\right And mouse\y>=GadgetRect\Top And mouse\y<=GadgetRect\bottom
ProcedureReturn #True and target1
Else
ProcedureReturn #False
EndIf
EndProcedure
;inside loop
EventID = WaitWindowEvent()
Select EventID
Case #WM_rButtonDown
target=IsMouseOverGadget(#Image_9)
If target=#True
DisplayPopupMenu(1,WindowID())
EndIf
;how i paste
Procedure pasteimage()
If CreateImage(17, 270,210)
foo.l = GetClipboardData(#PB_Clipboard_Image)
If foo
If StartDrawing(ImageOutput())
DrawImage(foo,0,0,270,210)
StopDrawing()
EndIf
EndIf
EndIf
SetGadgetState(target1,UseImage(17))
EndProcedure
Case #MENU_9
pasteimage()
Procedure IsMouseOverGadget(Gadget)
target1=Gadget
GetWindowRect_(GadgetID(Gadget),GadgetRect.RECT)
GetCursorPos_(mouse.POINT)
If mouse\x>=GadgetRect\Left And mouse\x<=GadgetRect\right And mouse\y>=GadgetRect\Top And mouse\y<=GadgetRect\bottom
ProcedureReturn #True and target1
Else
ProcedureReturn #False
EndIf
EndProcedure
;inside loop
EventID = WaitWindowEvent()
Select EventID
Case #WM_rButtonDown
target=IsMouseOverGadget(#Image_9)
If target=#True
DisplayPopupMenu(1,WindowID())
EndIf
;how i paste
Procedure pasteimage()
If CreateImage(17, 270,210)
foo.l = GetClipboardData(#PB_Clipboard_Image)
If foo
If StartDrawing(ImageOutput())
DrawImage(foo,0,0,270,210)
StopDrawing()
EndIf
EndIf
EndIf
SetGadgetState(target1,UseImage(17))
EndProcedure
Case #MENU_9
pasteimage()
Code: Select all
Code: Select all
Code: Select all