Jump to content

Recommended Posts

This UDF allows to create FloatPanel control for specific input controls.

Common features:

Quote

 * Can work with external windows/controls.
 * Custom menu build from string.
* Popup FloatPanel control on hovering.
* Popup FloatPanel control on TAB navigation (not compatible with $FLOATPANEL_POPUPONHOVER flag).

 

Example:

#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', BitOR($FLOATPANEL_HEADER, $FLOATPANEL_POSTOPLEFT))
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -29, _CustomMenu_Proc, 'Custom menu', True)
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -40, _Menu_Proc, 'Menu from string', False, 'Func: _FncMsg;Calc: 1+9;Exec: cmd.exe;[MENU:Menu]{Menu Item1|[MENU:SubMenu]{SubMenu Item1|SubMenu Item2}}')
_GUICtrlFloatPanel_AddButton($hFloatPanel, '') ;Separator
_GUICtrlFloatPanel_AddButton($hFloatPanel, 'shell32.dll', -44, '', 'Dummy')

$hFloatPanel2 = _GUICtrlFloatPanel_Create($hGUI, $hEdit, -1, '', BitOR($FLOATPANEL_POSBOTTOMLEFT, $FLOATPANEL_POPUPONHOVER))
_GUICtrlFloatPanel_AssignCtrls($hFloatPanel2, $iLabel)
_GUICtrlFloatPanel_AddButton($hFloatPanel2, 'shell32.dll', -233, _OpenMyComp_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 _CustomMenu_Proc($hFloatPanel, $iBttnID, $iCtrlID)
    Local $iContextMenu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    Local $iCalc_MItem = GUICtrlCreateMenuItem('Calc', $iContextMenu)
    Local $iMsg_MItem = GUICtrlCreateMenuItem('Message', $iContextMenu)
    
    Local $hParent = _GUICtrlFloatPanel_GetParent($hFloatPanel)
    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, $hParent)
            
            If @error Then
                Return $FLOATPANEL_RETNOHIDE
            EndIf
            
            ControlSetText($hParent, '', $iCtrlID, '=' & Execute($sInput))
        Case $iMsg_MItem
            MsgBox(64, @ScriptName, 'Ok', 0, $hParent)
        Case Else
            Return $FLOATPANEL_RETNOHIDE
    EndSwitch
    
    Return $FLOATPANEL_RETHIDE
EndFunc

Func _Menu_Proc($hFloatPanel, $iMenuItemID, $iCtrlID)
    Local $hParent = _GUICtrlFloatPanel_GetParent($hFloatPanel)
    Local $sItem = GUICtrlRead($iMenuItemID, 1)
    Local $sAction = StringRegExpReplace($sItem, '^(\w+):\h*.*', '\1')
    Local $sParam = StringRegExpReplace($sItem, '^\w+:\h*(.*)', '\1')
    
    Switch $sAction
        Case 'Func'
            $sItem = 'Return: ' & Call($sParam, $hParent)
        Case 'Calc'
            $sItem = '=' & Execute($sParam)
        Case 'Exec'
            $sItem = 'PID: ' & ShellExecute($sParam)
    EndSwitch
    
    ControlSetText($hParent, '', $iCtrlID, $sItem)
EndFunc

Func _FncMsg($hParent)
    Return Int(MsgBox(36, @ScriptName, 'Hello i am a message, ok?', 0, $hParent) = 6)
EndFunc

Func _OpenMyComp_Proc($hFloatPanel, $iBttnID, $iCtrlID)
    ShellExecute('::{20D04FE0-3AEA-1069-A2D8-08002B30309D}')
    Return $FLOATPANEL_RETHIDE
EndFunc

Func _SelFolder_Proc($hFloatPanel, $iBttnID, $iCtrlID)
    Local $hParent = _GUICtrlFloatPanel_GetParent($hFloatPanel)
    Local $sSel = FileSelectFolder('Select', '', 0, '', $hParent)
    
    If Not @error Then
        ControlSetText($hParent, '', $iCtrlID, $sSel)
        Return $FLOATPANEL_RETHIDE
    EndIf
    
    Return $FLOATPANEL_RETNOHIDE
EndFunc

 

History:

Quote

v0.2
* _GUICtrlFloatPanel_AddButton function now returns added button id on success.
+ Added _GUICtrlFloatPanel_DeleteButton function.
+ Added _GUICtrlFloatPanel_UnAssignCtrls function.
* Now $hFunc parameter in _GUICtrlFloatPanel_AddButton function can also accept function name as string.
* Fixed bug when sometimes buttons on the panel was not displayed.
* Improved buttons positioning.
* Clarifications in functions docs.
* Changed example.

v0.1b
* Added OnHover mode.
* Added panel position support (by flags).

v0.1a
* First public test version.

 

GUIFloatPanel_0.2.zip

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...