Austin
(Seasoned Scripter)
2003-02-17 08:26 PM
ObjectButton

I am having trouble using the ObjectButton object in my script. I dont understand how to determine what option was chosen.

Can Anyone offer advice?

Thanks


JochenAdministrator
(KiX Supporter)
2003-02-17 08:37 PM
Re: ObjectButton

OptionButton ?

something like this :


break on

$form = createobject("kixtart.form")
$form.Caption = "OptionButton made easy ..."

$opt1 = $form.OptionButton("Option 1",20,20,80,15)
$opt2 = $form.OptionButton("Option 2",20,60,80,15)
$opt3 = $form.OptionButton("Option 3",20,100,80,15)

$Opt1.onclick = "Opt_CLick(1)"
$Opt2.onclick = "Opt_CLick(2)"
$Opt3.onclick = "Opt_CLick(3)"

$Opt1.Value = True
$lbl = $form.Label("Option 1 is selected",20,$Form.ClientHeight-20,$form.ClientWidth-40,15)

$form.Show
while $form.Visible
    $=execute($Form.DoEvents)
loop

exit 1

function Opt_Click($Opt)
    $lbl.Caption = "Option " + $Opt + " is selected"
endfunction



Austin
(Seasoned Scripter)
2003-02-17 09:19 PM
Re: ObjectButton

Great thanks for the help..

Would something like this work? Because I am doing something wrong I think.
code:
  Select
Case $Opt1.OnClick
$Choice = 1
Case $Opt2.OnClick
$Choice = 2
Case $Opt3.OnClick
$Choice = 3
Case $Opt4.OnClick
$Choice = 4
$UsrDB = $txtDBName.Text
EndSelect



JochenAdministrator
(KiX Supporter)
2003-02-17 09:21 PM
Re: ObjectButton

Definetly,

as the OnClick Events are 'executed' in the DoEvents loop

You should declare each Event before the Loop (Execute-able)

hth
J.


Sealeopard
(KiX Master)
2003-02-17 09:21 PM
Re: ObjectButton

You can't do this because the OnClick denotes an event that triggers the execution of the specified function. It is not a value.

Austin
(Seasoned Scripter)
2003-02-17 09:37 PM
Re: ObjectButton

I just figured that out... ; (

Hmm.. well here is what I am trying to do. Use the optionbutton to get user input but not do anything other than set a variable until I click my execute button.. but I need to set a value based on what is selected in the optionbutton group.

Can I do this?

Thanks


Sealeopard
(KiX Master)
2003-02-17 09:39 PM
Re: ObjectButton

code:
function Opt_Click($Opt)
$globalvalue = $opt
endfunction



Austin
(Seasoned Scripter)
2003-02-18 12:07 AM
Re: ObjectButton

Ahh yes... I see... Dohh...

Thanks as always for the help.


Austin
(Seasoned Scripter)
2003-02-25 11:32 PM
Re: ObjectButton

Ok got the image working great.. now trying to use $Object.OnClick to open an html file.. cant seem to figure it out.. can anyone offer advice.

Sealeopard
(KiX Master)
2003-02-25 11:33 PM
Re: ObjectButton

Please show us your code.

Austin
(Seasoned Scripter)
2003-02-25 11:41 PM
Re: ObjectButton

Cant get to it at the moment.. working on different machine. I will post it when I get back to my computer. Think something like this was my final attempt.

code:
 $ImageList 			= $Form.ImageList
$ImageList.ImageSize = 14,14
$ImageList.Images.Add("$InstallDir\help.bmp")

$HLPButton = $Form.ToolButton
$HLPButton.Size = 21,21
$HLPButton.Top = 2
$HLPButton.Icon = $ImageList.Images(0)
$HLPButton.Left = $lblprocessA.Left + $lblprocessA.WIDTH + 2
$HLPButton.OnClick = "Run $InstPath\help.htm"

Ahh could be the quotes because the path to the htm file has a space in it?

Will post the real one when I get back to my computer.

Thanks


JochenAdministrator
(KiX Supporter)
2003-02-25 11:43 PM
Re: ObjectButton

Austin .. take a look at PostPrep 1.0.1 ... especially the function for button 'Preview' [Wink]

Austin
(Seasoned Scripter)
2003-02-25 11:44 PM
Re: ObjectButton

Not sure I know what postprep is? I will search the board for it.

Thanks


JochenAdministrator
(KiX Supporter)
2003-02-25 11:47 PM
Re: ObjectButton

PostPrep 1.0.1 - Update Release

Austin
(Seasoned Scripter)
2003-02-25 11:48 PM
Re: ObjectButton

I think I see where you are going with this.. only trouble I might have is how to assigne the doc to open?

Will play with it tonight.

Thanks for the direction.


NTDOCAdministrator
(KiX Master)
2003-02-26 01:51 AM
Re: ObjectButton

Austin,

If you look at my Signature you should see a couple of links to download the PostPrep 1.0.1 package.

[Big Grin] [Big Grin] [Big Grin] [Big Grin] [Big Grin]


Austin
(Seasoned Scripter)
2003-02-26 04:01 AM
Re: ObjectButton

Ok got it..
code:
 Function HlpBtn_Click()
Dim $ie,$doc,$f,$t
$ie = CreateObject("internetexplorer.application")
$ie.addressbar=0
$ie.menubar=0
$ie.toolbar=0
$ie.statusbar=0
$ie.navigate("$InstallDir\Help.htm")
$ie.visible=1
$Silent = SetFocus("PassSync Help Version $Build")
While $ie.visible Sleep 0.1 Loop
Exit
EndFunction

Now I have another question in the same line. If I want to be able to double click an image and call a function but I dont want to use the toolbutton because I dont want it to look like a button.. is there a way to make it flat?

Thanks


JochenAdministrator
(KiX Supporter)
2003-02-26 08:15 AM
Re: ObjectButton

That would be then the PictureBox() object ...

sample :



break on

$form = createobject("Kixtart.form")
$form.Caption = "PictureBox sample"

$pic = $form.PictureBox
$pic.Size = 256,256
$pic.Borderstyle = 0

$pic.Picture = "%SystemRoot%\Prairie Wind.bmp"
$pic.OnClick = "$$x = $$form.msgbox('You clicked me !!!',Kixforms,64)"

$pic.Center
$form.Show
while $form.Visible
    $=execute($Form.DoEvents)
loop

exit 1



Please note that the DoubleClick event was replaced by OnClick as it seems to happen that the event is not trapped within my latest build 38

J.


NTDOCAdministrator
(KiX Master)
2003-02-26 08:24 AM
Re: ObjectButton

I'm sorry... I can't click on YOU!!! right now.

JochenAdministrator
(KiX Supporter)
2003-02-26 08:27 AM
Re: ObjectButton

crap ... Shawn should release build 38 as soon as possible !

Each of my sample failed since i have a completely different version [Frown]

Or .... do you just kidding ? [Eek!]

errg ... coffee break [Roll Eyes]

[ 26. February 2003, 08:29: Message edited by: jpols ]


LonkeroAdministrator
(KiX Master Guru)
2003-02-26 08:48 AM
Re: ObjectButton

toolbutton is perfect too ( I use it everywhere) and it does not look like button when you set it's "flatstyle" property to 1

NTDOCAdministrator
(KiX Master)
2003-02-26 10:53 AM
Re: ObjectButton

Works fine Jochen.. just pulling your leg. [Wink] [Razz]

Austin
(Seasoned Scripter)
2003-02-26 10:11 PM
Re: ObjectButton

Right... I actually ended up using this code..

code:
 $ImageList2 			= $fraDetails2.ImageList
$ImageList2.ImageSize = 15,15
$ImageList2.Images.Add("$InstallDir\bang.bmp")
$ImageList2.Images.Add("$InstallDir\bangred.bmp")
$ImageList2.Images.Add("$InstallDir\banggreen.bmp")
$ImageList2.TabStop = 0

$CHGIcon = $fraDetails2.ToolButton
$CHGIcon.Size = 15,15
$CHGIcon.Top = $lblCHG.TOP - 2
$CHGIcon.Icon = $ImageList2.Images(0)
$CHGIcon.Left = $lblCHG.WIDTH + 10
$CHGIcon.OnClick = "DrawError()"
$CHGIcon.FlatStyle = 0
$CHGIcon.TabStop = 0
$CHGIcon.Border = 2

Problem was that I was using a single statement to declare everyting when using the picturebox like this:
code:
 $Image = $fraDetails2.Image("$InstallDir\bang.bmp",$lblCHG.WIDTH + 10,$lblCHG.TOP - 2,15,15)
$Image.OnDblClick = "DrawError"

Reason it would not work is because I was chaning the picture in other cases in the script with the same call but I was having to redefine the $Image.OnDblClick.

Anyways the above code solved the problem.

Thanks for the help..