Buttons Plugin (uses cpvButton.ocx in System32)

This forum is meant for announcing new plugins, downloading other people's plugins, posting questions, etc.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Buttons Plugin (uses cpvButton.ocx in System32)

Postby cpkspikyhair » Sat Jun 27, 2009 10:40 pm

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
Attachments
ButtonPlugin_v1_0.zip
PL1 file and cpvButton.ocx
(30.45 KiB) Downloaded 492 times
Last edited by cpkspikyhair on Sun Jun 28, 2009 4:27 pm, edited 5 times in total.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sat Jun 27, 2009 10:57 pm

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.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Jun 28, 2009 12:29 am

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:
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sun Jun 28, 2009 9:15 am

Anytime :wink:
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Jun 28, 2009 4:03 pm

The plugin is done! :mrgreen:

Read the first post for instructions!
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sun Jun 28, 2009 4:21 pm

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
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Jun 28, 2009 4:26 pm

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"
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sun Jun 28, 2009 4:51 pm

Oh, ok thanks (why doesn't it work with hotspot coordinates? they're just variables... :? )
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Jun 28, 2009 5:13 pm

I've never had any luck with setting variables as Hotspot coordinates...I dont know why it doesn't work... :?
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Mon Aug 31, 2009 3:18 pm

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
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby JasonMc » Mon Aug 23, 2010 10:07 pm

Any ideas on how to change the color of the button?
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA


Return to The Plugins Corner

Who is online

Users browsing this forum: No registered users and 1 guest

cron