Jump to content

Combo Box - Selection on Show


Affe
 Share

Recommended Posts

I have a layered GUI that I'm using to overlap on another window.

No issues there, until now: I added in a combo box, and it looks great with the transparency and all, but the text within the box is selected when the GUI displays. It's nothing critical, but it doesn't look pleasing on the startup and would prefer to just not have the text highlighted.

Is there any way to do this?

I've tried several methods from hiding/showing the combo, controlclicking the combo, etc. to try and deselect the text on startup, but no luck ;)

Is there some sort of $GUI_NOSELECT style I can use and still have the combo work like a dropdown?

[center][/center]

Link to comment
Share on other sites

I would suggest that you post your code or a working snippet which also shows your issue.

Ein Code sagt mehr als 1000 Worte. ;)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I would suggest that you post your code or a working snippet which also shows your issue.

Ein Code sagt mehr als 1000 Worte. ;)

Br,

UEZ

Alas, I understand where you're coming from when someone posts no code in their question, however it wouldn't do any good. I've changed it so that it will layer over a notepad window instead of the program I'm layering over. You'll have to have a notepad window open.

$Module_Combo is the only combo I have.

Really not sure if this example will work as-is, I've cut it from a multi-file program.

$transparency = 205
WinActivate("[CLASS:notepad; INSTANCE:1]")
WinWaitActive("[CLASS:notepad; INSTANCE:1]")
Sleep(100)
$pos = WinGetPos("[CLASS:notepad; INSTANCE:1]")
Global $orgx = $pos[0]
Global $orgy = $pos[1]

Global $MyGUI = GUICreate($GUITitle, 200, 220, $orgx + $Triangle[0] - 5, $orgy + $Triangle[1] + 130, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW), WinGetHandle("[CLASS:notepad; INSTANCE:1]"))

GUISetBkColor(0xB6B6B7)

GUISetOnEvent($GUI_EVENT_CLOSE, "CheckGUI")

DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $GUITitle, "hwnd", WinGetHandle("[CLASS:notepad; INSTANCE:1]"), "int", $pos[0] + $Triangle[0] - 5, "int", $pos[1] + $Triangle[1] + 130, "int", 200, "int", 200, "uint", 0x0010) ; $SWP_NOACTIVATE

_API_SetLayeredWindowAttributes($MyGUI, 0xB6B6B7, $transparency)

GUISetFont(9, 1, 0, "MS Serif", $MyGUI);, "CLEARTYPE_QUALITY=5")

$Label1 = GUICtrlCreateLabel("# of :", 8, 136, 100, 18)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
$Input1 = GUICtrlCreateInput("1", 112, 136, 18, 18)
GUICtrlSetOnEvent($Input1, "CheckGUI")
GUICtrlSetBkColor(-1, 0xB6B6B7)
GUICtrlSetColor(-1, 0xC0C0C0)
$Slider1 = GUICtrlCreateSlider(132, 136, 60, 18)
GUICtrlSetBkColor(-1, 0xB6B6B7)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
GUICtrlSetOnEvent($Slider1, "CheckGUI")
GUICtrlSetLimit($Slider1, 8, 1)
GUICtrlSetCursor($Slider1, 0)

$Label2 = GUICtrlCreateLabel("# :", 8, 156, 100, 18)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
$Input2 = GUICtrlCreateInput("1", 112, 156, 75, 18)
GUICtrlSetBkColor(-1, 0xB6B6B7)
GUICtrlSetColor(-1, 0xC0C0C0)

$Label3 = GUICtrlCreateLabel("# :", 8, 176, 100, 18)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
$Input3 = GUICtrlCreateInput("1", 112, 176, 75, 18)
GUICtrlSetBkColor(-1, 0xB6B6B7)
GUICtrlSetColor(-1, 0xC0C0C0)


$Label4 = GUICtrlCreateLabel("After :", 8, 196, 100, 18)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
$Input4 = GUICtrlCreateInput("ALT+F1", 112, 196, 75, 18)
GUICtrlSetBkColor(-1, 0xB6B6B7)
GUICtrlSetColor(-1, 0xC0C0C0)

$MyGUI_StatusLine = GUICtrlCreateLabel("", 8, 16, 180, 18)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
$MyGUI_TimerLine = GUICtrlCreateLabel("", 8, 32, 180, 54)
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey

GUISetFont(10, 550, 0, "MS Serif", $MyGUI)
$MyGUI_StartButton = GUICtrlCreateButton("Start", 8, 88, 90, 20)
If @OSVersion = "WIN_VISTA" Then
    GUICtrlSetBkColor(-1, 0xB6B6B7)
Else
    GUICtrlSetBkColor(-1, 0x333333)
EndIf
GUICtrlSetColor(-1, 0xC0C0C0)
GUICtrlSetOnEvent($MyGUI_StartButton, "CheckGUI")
$MyGUI_StopButton = GUICtrlCreateButton("Exit", 100, 88, 90, 20)
If @OSVersion = "WIN_VISTA" Then
    GUICtrlSetBkColor(-1, 0xB6B6B7)
Else
    GUICtrlSetBkColor(-1, 0x333333)
EndIf
GUICtrlSetColor(-1, 0xC0C0C0)
GUICtrlSetOnEvent($MyGUI_StopButton, "CheckGUI")

$Module_Combo = GUICtrlCreateCombo("Module", 16, 112, 169, 25)
GUICtrlSetData(-1, "Module")
GUICtrlSetColor(-1, 0xC0C0C0) ; Grey
GUICtrlSetBkColor(-1, 0xB6B6B7)

GUISetState(@SW_SHOWNOACTIVATE, $MyGUI)

ControlClick($GUITitle, "", "[CLASS:Edit; INSTANCE:5]", "left", 1, 5, 5)

Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)

    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    Local Const $LWA_ALPHA = 0x2
    Local Const $LWA_COLORKEY = 0x1
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, 0, 0)
        Case Else
            Return 1
    EndSelect
EndFunc   ;==>_API_SetLayeredWindowAttributes
Edited by Affe

[center][/center]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...