Jump to content

Recommended Posts

Posted (edited)

What do you think about that?

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $VisToggle = 0

GUICreate("OwnCombo-Test", 400, 200)
GUISetOnEvent(-3, "_Exit")

GUICtrlCreatePic(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & "Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)

GUICtrlCreateLabel("OwnCombo", 20, 50, 100, 20, 0x201)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel("Standard Combo", 220, 50, 100, 20, 0x201)
GUICtrlSetBkColor(-1, -2)


Global $hOwnCombo = _OwnCombo_Create("Hello1|Hello2|Hello3|Hello4|Hello5", 20, 80, 100, 80, -2)

GUICtrlCreateCombo("", 220, 80, 100, 80)
GUICtrlSetData(-1, "Hello1|Hello2|Hello3|Hello4|Hello5", "Hello1") ; add other item snd set a new default
GUICtrlSetBkColor(-1, -2)

GUISetState()

While 1
Sleep(20000)
WEnd

Func _OwnCombo_Create($sText, $iLeft, $iTop, $iWidth, $iHeight, $iColor = -1)
Local $hInput, $hList, $hButton, $aText
$aText = StringSplit($sText, "|")
$hList = GUICtrlCreateListView("OwnCombo", $iLeft, $iTop + 18, $iWidth, $iHeight, BitOR(0x4000, 0x8000, 0x4, 0x8), BitOR(0x8, 0x20, 0x200))
GUICtrlSendMsg(-1, 4167, 0, 1)
GUICtrlSendMsg(-1, 4126, 0, $iWidth - 4)
GUICtrlSetState(-1, $GUI_HIDE)
$hButton = GUICtrlCreateButton("u", $iLeft + $iWidth - 18, $iTop + 2, 16, 16, Default, 0x20)
GUICtrlSetOnEvent(-1, "_OwnCombo_ShowHide")
GUICtrlSetFont(-1, 10, Default, 0, "Marlett")
$hInput = GUICtrlCreateLabel($aText[1], $iLeft, $iTop, $iWidth, 20, 0x1200)
If $iColor <> -1 Then
  GUICtrlSetBkColor($hInput, $iColor)
  GUICtrlSetBkColor($hList, $iColor)
EndIf
For $i = 1 To $aText[0]
  GUICtrlCreateListViewItem($aText[$i], $hList)
  GUICtrlSetOnEvent(-1, "_OwnCombo_SetSelText")
Next
GUICtrlSetState($hInput, $GUI_FOCUS)
Return $hInput
EndFunc

Func _OwnCombo_ShowHide()
Local $CtrlID = @GUI_CtrlId - 1
$VisToggle = Not $VisToggle
GUICtrlSetState($CtrlID, $GUI_FOCUS)
If $VisToggle Then
  GUICtrlSetState($CtrlID, $GUI_SHOW)
Else
  GUICtrlSetState($CtrlID, $GUI_HIDE)
EndIf
EndFunc

Func _OwnCombo_SetSelText()
$VisToggle = 0
GUICtrlSetState($hOwnCombo, $GUI_FOCUS)
GUICtrlSetData($hOwnCombo, StringTrimRight(GUICtrlRead(GUICtrlRead($hOwnCombo - 2)), 1))
GUICtrlSetState($hOwnCombo - 2, $GUI_HIDE)
EndFunc

Func _Exit()
Exit
EndFunc
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

Very nice!

But the is one small(?) probelm - the control has no focus.

And btw, the image can be set like this:

GUICtrlCreatePic(@AutoItExe & "\..\Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)

;)

 

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

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
×
×
  • Create New...