#include <GUIFloatPanel.au3>
#include <GUIEdit.au3>
$hGUI = GUICreate('GUIFloatPanel Example', 300, 200)
$iInput1 = GUICtrlCreateInput('', 20, 20, 200, 20)
$iInput2 = GUICtrlCreateInput('', 20, 50, 200, 20)
$hEdit = _GUICtrlEdit_Create($hGUI, 'Handle control', 20, 80, 200, 40)
$iLabel = GUICtrlCreateLabel('Label', 80, 140, 80, 20)
Dim $aInputs[2] = [$iInput1, $iInput2]
$hFloatPanel = _GUICtrlFloatPanel_Create($hGUI, $aInputs, 0xEBE8AB, 'Header', $FLOATPANEL_FLAG_HEADER)
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -29, _Custom_Proc, 'Custom menu', True)
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -40, _Menu_Proc, 'Menu from string', False, 'Func: _Message;Calc: 1+9;Exec: C:\;[MENU:Menu]{Menu Item1|[MENU:SubMenu]{SubMenu Item1|SubMenu Item2}}')
_GUICtrlFloatPanel_AddButton($hFloatPanel, '')
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -44, '', 'Dummy')
$hFloatPanel2 = _GUICtrlFloatPanel_Create($hGUI, $hEdit, -1, '', $FLOATPANEL_FLAG_TRANSPARENT)
_GUICtrlFloatPanel_AssignCtrls($hFloatPanel2, $iLabel)
_GUICtrlFloatPanel_AddButton($hFloatPanel2, 'shell32.dll', -233, _MyComp_Proc, 'My Computer')
_GUICtrlFloatPanel_AddButton($hFloatPanel2, '') ;Separator
_GUICtrlFloatPanel_AddButton($hFloatPanel2, 'shell32.dll', -5, _SelFolder_Proc, 'Select Folder')
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _Custom_Proc($hFloatPanel, $iBttnID, $iCtrlID)
Local $iContextMenu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
Local $iCalc_MItem = GUICtrlCreateMenuItem('Calc', $iContextMenu)
Local $iMsg_MItem = GUICtrlCreateMenuItem('Message', $iContextMenu)
Local $iItem = _GUICtrlFloatPanel_ShowMenu($hFloatPanel, $iContextMenu, $iBttnID, True)
Switch $iItem
Case $iCalc_MItem
Local $sInput = InputBox('Input', 'Calc:', '5 + 5', '', -1, -1, Default, Default, 0, $hGUI)
If @error Then
Return $FLOATPANEL_RET_NOHIDE
EndIf
GUICtrlSetData($iCtrlID, Execute($sInput))
Case $iMsg_MItem
MsgBox(64, @ScriptName, 'Ok', 0, $hGUI)
Case Else
Return $FLOATPANEL_RET_NOHIDE
EndSwitch
Return $FLOATPANEL_RET_HIDE
EndFunc
Func _Menu_Proc($hFloatPanel, $iMenuItemID, $iCtrlID)
Local $sItem = GUICtrlRead($iMenuItemID, 1)
Local $sAction = StringRegExpReplace($sItem, '^(\w+):\h*.*', '\1')
Local $sParam = StringRegExpReplace($sItem, '^\w+:\h*(.*)', '\1')
Switch $sAction
Case 'Func'
$sItem = Call($sParam)
Case 'Calc'
$sItem = Execute($sParam)
Case 'Exec'
$sItem = ShellExecute($sParam)
EndSwitch
GUICtrlSetData($iCtrlID, $sItem)
EndFunc
Func _Message()
MsgBox(64, @ScriptName, 'Hello i am a message')
EndFunc
Func _MyComp_Proc($hFloatPanel, $iBttnID, $iCtrlID)
ShellExecute('::{20D04FE0-3AEA-1069-A2D8-08002B30309D}')
Return $FLOATPANEL_RET_HIDE
EndFunc
Func _SelFolder_Proc($hFloatPanel, $iBttnID, $iCtrlID)
Local $sSel = FileSelectFolder('Select', '', 0, '', _GUICtrlFloatPanel_GetParent($hFloatPanel))
If Not @error Then
GUICtrlSetData($iCtrlID, $sSel)
Return $FLOATPANEL_RET_HIDE
EndIf
Return $FLOATPANEL_RET_NOHIDE
EndFunc