Page 1 of 1

Buttons Plugin (uses cpvButton.ocx in System32)

PostPosted: Sat Jun 27, 2009 10:40 pm
by cpkspikyhair
I created my first real plugin (using System32's OCX "cpvButton.ocx"). It creates 3D buttons (like actual VB buttons) in a defined area.

To call this, use the procedure CreateButton, like this:

Code: Select all
CreateButton BUTTONINDEX, LEFT, TOP, WIDTH, HEIGHT, CAPTIONSTRING


To make the button do something when you click it, here is the code you put in your Procedures (the COMPONENTNAME is "Button" and then the value you typed in for the BUTTONINDEX when you created the button [for instance, I typed 1]):


Code: Select all
Sub Button1_Click(Trigger)
...code...
End Sub

PostPosted: Sat Jun 27, 2009 10:57 pm
by Lyberodoggy
Just use the event triggered. say it's cpvButton_pressed
go to AM and create a sub called cpvButton_pressed. The code inside the sub will be executed when the event is triggered.

PostPosted: Sun Jun 28, 2009 12:29 am
by cpkspikyhair
Ok. I tried this, and it returned an error when I clicked on the button.

The code I used in procedures was:

Code: Select all
Sub Button1_Click()
click = click + 1
End Sub


Where Button1 is the name of the component instance I have loaded, and Click is the event that tracks button clicks. As far as I know, there are no arguments for this event.

If anyone could help it would be appreciated.

EDIT: Got it! Just had to put Trigger into the argument area. Thanks for the help Lyberodoggy!!!! :mrgreen:

PostPosted: Sun Jun 28, 2009 9:15 am
by Lyberodoggy
Anytime :wink:

PostPosted: Sun Jun 28, 2009 4:03 pm
by cpkspikyhair
The plugin is done! :mrgreen:

Read the first post for instructions!

PostPosted: Sun Jun 28, 2009 4:21 pm
by Lyberodoggy
Unfortunately didn't work for me

I enabled the plugin and used this code:
Code: Select all
CreateButton 1, Hotspot(1).LEFT, Hotspot(1).TOP, Hotspot(1).WIDTH, Hotspot(1).HEIGHT, "OK"



and nothing happened

PostPosted: Sun Jun 28, 2009 4:26 pm
by cpkspikyhair
I tried using the Hotspot's dimension properties and it didn't work.

What you have to do is actually type in the dimensions of the area you want as a button (you don't actually have to have a hotspot there).

For example, if the top left was going to be at (100, 80) and you wanted it to be 75x50, you would type:

Code: Select all
CreateButton 1, 100, 80, 75, 50, "OK"

PostPosted: Sun Jun 28, 2009 4:51 pm
by Lyberodoggy
Oh, ok thanks (why doesn't it work with hotspot coordinates? they're just variables... :? )

PostPosted: Sun Jun 28, 2009 5:13 pm
by cpkspikyhair
I've never had any luck with setting variables as Hotspot coordinates...I dont know why it doesn't work... :?

PostPosted: Mon Aug 31, 2009 3:18 pm
by Lyberodoggy
fixed it... works with coordinates if you change the plugin's code to this:

Code: Select all
Sub CreateButton(hspotind , hleft , htop , hwidth , hheight , captionx)

hspotind2 = "Button" + CStr(hspotind)

Action.AddComponent "Button2.cpvButton", hspotind2

Component(hspotind2).Visible = True
execute "Component(hspotind2).Move "+cstr(hleft)+", "+cstr(htop)+", "+cstr(hwidth)+", "+cstr(hheight)
Component(hspotind2).Object.ResetToDefaultColors
Component(hspotind2).Object.Caption = captionx

End Sub

PostPosted: Mon Aug 23, 2010 10:07 pm
by JasonMc
Any ideas on how to change the color of the button?