#92122 - 2003-06-02 11:52 PM
Re: KiXForms Right Click
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
Chris... thanks for the font idea... man I had a blonde moment there I added a few lines to automatically make all the menuitems the same length, but with the font I was using kept changing the left alignment...
Here is the modification...
Break On $Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown" $Form.Show WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1 FUNCTION OnFormMouseDown Dim $Menu,$Item $Menu = "New","Open","Save","Save as","Exit" $longestitem=0 For each $menuitem in $menu if len($menuitem)>$longestitem $longestitem=len($menuitem) endif next For $menucount=0 to ubound($menu) if len($menu[$menucount])<$longestitem do $menu[$menucount]=$menu[$menucount] + " " until len($menu[$menucount])=$longestitem endif next If $Form.MouseButton = 2 ; Right-click $Item = fnPopup($Menu,$Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY) ?"Item=" $Item ENDIF EndFunction FUNCTION fnPopup($MenuStrings,$FormSLeft, $FormSTop) Dim $MenuItems[UBOUND($MenuStrings)] $FormS = CreateObject("Kixtart.Form") $FormS.BorderStyle = 0 $FormS.ClientWidth = 100 $FormS.ClientHeight = 42 $FormS.Top = $FormSTop + 30 $FormS.Left = $FormSLeft + 5 $Top = 1 For $i = 0 To UBOUND($MenuStrings) $MenuItems[$i] = $FormS.ToolButton($MenuStrings[$i], 1, $Top, $FormS.ClientWidth-2, 20) $MenuItems[$i].FontName = "Lucida Console" $MenuItems[$i].FlatStyle = 1 $MenuItems[$i].Alignment = 1 $MenuItems[$i].Icon = 60 $MenuItems[$i].HotBackColor = Navy $MenuItems[$i].HotForeColor = White $MenuItems[$i].OnClick = "$$FormS.Tag=$i $$FormS.Hide" $Top = $Top + 20 Next $FormS.ClientHeight = $Top + 2 $FormS.Line(0,0,0,$FormS.ClientHeight,"White") $FormS.Line(0,0,$FormS.ClientWidth,0,"White") $FormS.Line($FormS.ClientWidth-1,0,$FormS.ClientWidth-1,$FormS.ClientHeight,"DimGray") $FormS.Line(0,$FormS.ClientHeight-1,$FormS.ClientWidth,$FormS.ClientHeight-1,"DimGray") $FormS.Tag = -1
$FormS.Show While $FormS.Visible $=Execute($FormS.DoEvents()) Loop $fnPopup = $FormS.Tag ENDFUNCTION FUNCTION fnClickMe() $bFlip = not $bFlip If $bFlip $btnClose.Icon = 10 ; Green Check Else $btnClose.Icon = 9 ; Red X EndIf ENDFUNCTION
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|