Using event handlers - (obsolete version)

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Konne wrote:I didn't want to insult you or anything like that, I think it's a great peace of work. I was just wondering if you are still working on it, that's all.
And thanks fpr the code, but can I get clicks on Imagegadgets too?
No worries. Truth is that time is so tight at the moment, that I probably wouldn't be able to update the code anyhow if someone made a request.

As for mouse clicks:

Code: Select all

XIncludeFile "EasyVENT.pbi"
DisableExplicit

Declare.l MouseOver(*sender.PB_Sender) 
Declare.l MouseDown(*sender.PB_Sender)
Declare.l MouseUp(*sender.PB_Sender)

myImage = LoadImage(#PB_Any, "icon.ico") ; Please use your own icon! 

OpenWindow(0, 0, 0, 640, 480, "", #PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_ScreenCentered|#PB_Window_Maximize)
CreateGadgetList(WindowID(0))
  ImageGadget(1, 20,20, 300, 300, ImageID(myImage), #PB_Image_Border)

;Set event handlers.
SetEventHandler(GadgetID(1), #OnMouseOver, @MouseOver())
SetEventHandler(GadgetID(1), #OnMouseDown, @MouseDown())
SetEventHandler(GadgetID(1), #OnMouseUp, @MouseUp())


Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End

Procedure.l MouseOver(*sender.PB_Sender)
Debug "Mouse over image gadget!"
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure.l MouseDown(*sender.PB_Sender)
Debug "Mouse click over image gadget!"
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure.l MouseUp(*sender.PB_Sender)
Debug "Mouse up over image gadget!"
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Of course, you don't need 3 separate procedures for the above, you could easily combine them into a single handler and then keep an eye on the value of *sender\message in order to determine which event called the handler etc.
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Maybe i'm not readin everything correcty, but why the 'DisableExplicit' ??
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

There maybe an EnableExplicit in his version of EasyEVNT. That is very usefull if you are writeing stuff like that ;)

One other question:
In the help you wrote:
#OnItemSelected
This event fires after the user selects a new item in a registered gadget. The following
gadgets are supported:
ComboBoxGadget ExplorerComboGadget
ListViewGadget
ListIconGadget ExplorerListGadget
TreeGadget ExplorerTreeGadget
PanelGadget

Code: Select all

XIncludeFile "EasyVENT.pbi"

DisableExplicit

OpenWindow(0, 100, 100, 450, 250, "EasyVENT ComboBoxGadget demo.", #PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_ScreenCentered)

CreateGadgetList(WindowID(0))
  ComboBoxGadget(1, 10, 40, 250, 100)
  
  For t = 1 To 10
  AddGadgetItem(1, -1, "Item "+Str(t))
  Next
  
Procedure Aha(*sender.PB_Sender)

  Debug "NNNNNNNNNE"
EndProcedure

SetEventHandler(GadgetID(1), #OnItemSelected, @Aha())

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
  
So why isn't it working?
Apart from that Mrs Lincoln, how was the show?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Konne wrote:So why isn't it working?
'cause there's a bug the size of Ireland in the code!!! :)

Fixed.

The bug was due to alterations I made for someone with a Keyboard accelerator problem.

My apologies.
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

srod wrote:My apologies.
Why apologies. I really think you did a great work with EasyVENT.
And Bugs like that, I know it can happen.
So can I find the fixed code on your website?
And why Ireland???
Apart from that Mrs Lincoln, how was the show?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The download link is in the first post and has been updated.

Why Ireland?

Big place. You tried walking across it? :)
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

But if you wanna make a point you pick something really big like Canada or something really small like the Vatican.
It's just that the last update date at your page was something with October.
And #OnUnhandledWinMessage isn't declared in any includefile.
Apart from that Mrs Lincoln, how was the show?
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Actually, I thought Ireland was quite funny - to me it had a nicer ring than say Canada or Texas, but maybe that's just me.

cheers
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Konne wrote:And #OnUnhandledWinMessage isn't declared in any includefile.
It's there. The program would crash otherwise.

Look in the EasyVENTresident.pbi file, it's the 7th event listed.

@rsts: :)
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

OK there are 3 possiblilitys.
1) I'm kind of gotten dumb this day or
2) My browser doesn't work or
3) You are Uploading the wrong file.

http://www.rodriguz.freeserve.co.uk/EasyVENT.zip

Try downloading it. It seems to be an old Version.
(The file in the archive is saying "Last Changed - 21.9.2006"
Apart from that Mrs Lincoln, how was the show?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Try http://www.purecoder.net/EasyVENT.zip (link on his web site ; although it says 'Last updated on the 11th October 2006', EasyVENT.pbi has been updated)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Whoops! :oops: I swear I'm getting dumber in my old age!

Sorry Konne. I've updated the link in the first post - for definite this time! Gnozal had tracked down the correct version.
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Tried it out in Vista...works great :) Thank You

I borrowed the example code from Konne above and used it real quick with Vista's DWM and doing the 'sheet glass' effect on the background with the color blue. Works great but Vista had a little hiccup with the EnableExplicit so i rem'd it out for this example.

here's a pic of what it looks like
http://www.123pichosting.com/viewer.php ... anddwm.JPG
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Interesting. :)
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

Uhh, works with Vista.
Anyways srod can you help me with this question?
http://www.purebasic.fr/english/viewtop ... 24cd240e5d
Apart from that Mrs Lincoln, how was the show?
Post Reply