Sign in to follow this  
Followers 0
Spiff59

ComboBox height not retained after minimize

10 posts in this topic

#1 ·  Posted (edited)

Manually adjusting the height of a combobox gets trashed if the window is minimized.

#include <GuiComboBox.au3>
#include <GuiConstants.au3>

$GUI_Main = GuiCreate("", 200, 200, 200, 200)
GUISetFont(7.5, 400, 0)
GUICtrlCreateLabel("RTC: ", 20, 40, 32, 12)
$Combo_RTC = GUICtrlCreateCombo("", 48, 36, 80, 16, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "1 WEEK|2 WEEKS|4 WEEKS|8 WEEKS|3 MONTHS", "")
_GUICtrlComboBox_SetItemHeight(-1, 12)
_GUICtrlComboBox_SetItemHeight(-1, 12, 0)
$button1 = GUICtrlCreateButton("click to minimize, then restore", 20, 80, 160, 16)
$button2 = GUICtrlCreateButton("click to adjust combo box height", 20, 120, 160, 16)
GUISetState()


While 1
    $msg = GUIGetMsg()
    If $msg = $button1 Then
        GUISetState(@SW_MINIMIZE)
        Sleep(500)
        GUISetState(@SW_RESTORE)
    EndIf
    If $msg = $button2 Then
        _GUICtrlComboBox_SetItemHeight($Combo_RTC, 12)
        _GUICtrlComboBox_SetItemHeight($Combo_RTC, 12, 0)
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Exit

Ideas?

Edited by Spiff59

Share this post


Link to post
Share on other sites



Uh, re-adjust it after the user unminimizes it?


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Or maybe if he wanted to keep GUICtrlCreateCombo, would GUICtrlSetPos work?


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Rehashing an old annoyance...

The suggestion to use _GUICtrlComboBox_Create() does indeed retain the height parameter after the window has been minimized, but...

How do I set the font size inside a control created with _GUICtrlComboBox_Create()?

It does not utilize the default setting via GUISetFont(), and GUICtrlSetFont() has no effect either.

I searched through the long list of _GUICtrlComboBox functions and found nothing appropriate.

There is not much use in creating a "skinny" combobox if:

A ) It reverts to a default height after the window has been minimized

or

B ) You can't populate the box with a font small enough to fit.

Thanks.

(I do think this ought to be categorized as a GUICtrlCreateCombo bug. I'm getting the itch to go visit BugTracker...)

Edited by Spiff59

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This problem is still causing me pain, neither GUICtrlCreateCombo nor _GUICtrlComboBox_Create() are behaving nicely.

Here's my latest demonstrator:

#include <GuiComboBox.au3>
Global $combobox_height[2] = [12, 16], $c_height
Global $font_size[2] = [7.5, 9], $f_size

$GUI_Main = GuiCreate("ComboBox Limitations", 430, 240)
GUICtrlCreateGroup("", 10, 10, 410, 55)
GUICtrlCreateGroup("", -99, -99, 1, 1)

; GUICtrlCreateCombo() ---------------------------------------------------------
GUISetFont(9, 600, 0)
GUICtrlCreateLabel("GUICtrlCreateCombo()", 40, 20, 190, 16)
GUISetFont(7.5, 400, 0)
$Combo =  GUICtrlCreateCombo("RESTORE TRASHES HEIGHT", 20, 40, 190, 12, $CBS_DROPDOWNLIST)
_GUICtrlComboBox_SetItemHeight($Combo, 12)
GUICtrlSetData($Combo, "2 WEEKS|4 WEEKS|8 WEEKS|3 MONTHS", "")
;
GUICtrlCreateLabel("> IGNORES INITIAL HEIGHT SETTING", 15, 75, 190, 16)
GUICtrlSetColor(-1, 0xFF0000 )
GUICtrlCreateLabel("> ALLOWS BOX HEIGHT CHANGES", 15, 90, 190, 16)
GUICtrlCreateLabel("> HEIGHT DEFAULTS AFTER MINIMIZE", 15, 105, 200, 16)
GUICtrlSetColor(-1, 0xFF0000 )
GUICtrlCreateLabel("> APPLIES INITIAL FONT SIZE", 15, 120, 190, 16)
GUICtrlCreateLabel("> ALLOWS FONT SIZE CHANGES", 15, 135, 190, 16)


; _GUICtrlComboBox_Create() ----------------------------------------------------
GUISetFont(9, 600, 0)
GUICtrlCreateLabel("_GUICtrlComboBox_Create()", 222, 20, 185, 16)
GUISetFont(7.5, 400, 0)
$_Combo =  _GUICtrlComboBox_Create($GUI_Main,"CAN'T ADJUST FONT SIZE|4 WEEKS|8 WEEKS", 220, 40, 190, 12, $CBS_DROPDOWNLIST)
_GUICtrlComboBox_SetItemHeight($_Combo, 12)
_GUICtrlComboBox_SetCurSel($_Combo, 0) ; select first item
;
GUICtrlCreateLabel("> IGNORES INITIAL HEIGHT SETTING", 225, 75, 190, 16)
GUICtrlSetColor(-1, 0xFF0000 )
GUICtrlCreateLabel("> ALLOWS BOX HEIGHT CHANGES", 225, 90, 190, 16)
GUICtrlCreateLabel("> HEIGHT RETAINED AFTER MINIMIZE", 225, 105, 190, 16)
GUICtrlCreateLabel("> IGNORES INITIAL FONT SIZE", 225, 120, 190, 16)
GUICtrlSetColor(-1, 0xFF0000 )
GUICtrlCreateLabel("> IGNORES FONT SIZE CHANGES", 225, 135, 190, 16)
GUICtrlSetColor(-1, 0xFF0000 )


; ------------------------------------------------------------------------------
$button1 = GUICtrlCreateButton("TOGGLE COMBOBOX HEIGHTS BETWEEN 12 AND 16 PIXELS", 40, 160, 340, 18)
$button2 = GUICtrlCreateButton("TOGGLE FONT SIZE BETWEEN 7.5 AND 9 PIXELS", 40, 185, 340, 18)
GUISetFont(9, 400, 0)
$button3 = GUICtrlCreateButton("CLICK TO MINIMIZE, THEN RESTORE", 90, 210, 240, 22)
GUISetState()
Send("{TAB}{TAB}{TAB}{TAB}")

; ------------------------------------------------------------------------------
While 1
    $msg = GUIGetMsg()
    If $msg = $button1 Then ; toggle combobox height
        $c_height = Not $c_height
        _GUICtrlComboBox_SetItemHeight($Combo, $combobox_height[$c_height])
        _GUICtrlComboBox_SetItemHeight($_Combo, $combobox_height[$c_height])
    EndIf
    If $msg = $button2 Then ; toggle font size
        $f_size = Not $f_size
        GUICtrlSetFont($Combo, $font_size[$f_size])
        GUICtrlSetFont($_Combo, $font_size[$f_size])
    EndIf
    If $msg = $button3 Then ; minimize then restore
        GUISetState(@SW_MINIMIZE)
        Sleep(500)
        GUISetState(@SW_RESTORE)
        Send("{TAB}{TAB}{TAB}{TAB}")
    EndIf
    If $msg = -3 Then ExitLoop ; exit
Wend
Exit

I list off what does, and does not, work with each function in a column below each type of combobox. I need a "shorter" box with a smaller than default height like the one on the left is initially. Toggle the "minimize/restore" button and you'll see what happens.

I'm still looking for some sort of work-around. I'd feel pretty idiotic to be constantly polling the GUI state waiting for a minimize, and then go back to polling until the restored bit is set and then finally kicking off a routine to reset the combobox heights. Can I get the OS to do most of that for me? Is there some event/message triggered by a window restore than can be captured via WM_NOTIFY or WM_COMMAND or ???

Any other ideas?

Thanks.

edit: script tweaks

Edited by Spiff59

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Everytime you mix standard Autoit's GUI code (controls) with GUI UDFs or native API functions/messages (for controls) you may hit some problems/limitations. It's because Autoit internally do more than just plain wrappers over native API controls like it is in UDF wrappers. Autoit can store some states of controls internally for example and when you use UDF functions you may "broke" these hidden states etc.

Unfortunatelly I have no advice for you.

Like Yashied said use _GUICtrlComboBox_Create() if you plan to use _GUICtrlComboBox_xxx() functions.

Edited by Zedna

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I could be remembering this wrong but I think if you are going to use the native AutoIt ComboBox then the functions in GUIComboBoxEx.au3 file play nicer than the same functions in GUIComboBox.au3

Also I agree with Yashied and Zedna, either the UDF controls OR the native controls. Even if I'm correct above it doesn't mean that everything will be better even if it solves the current issue.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I could be remembering this wrong but I think if you are going to use the native AutoIt ComboBox then the functions in GUIComboBoxEx.au3 file play nicer than the same functions in GUIComboBox.au3

Also I agree with Yashied and Zedna, either the UDF controls OR the native controls. Even if I'm correct above it doesn't mean that everything will be better even if it solves the current issue.

I'm beginning to think that requesting that "A combobox created via GUICtrlCreateCombo() not revert to the default height after a window minimize and restore" would make a valid BugTracker of the "bug" variety.

Or, that: "Adding a function to allow changing the font properties (size) of comboboxes created with _GUICtrlComboBox_Create()" might make a valid BugTracker in the "feature request" category.

Edit: Oops! I submitted BugTracker #1532 a few months ago regarding the "bug" mentioned above. It got shot down. The repsonse basically said: "There is no support for custom combobox heights when using GUICtrlCreateCombo()". Maybe I'll try the other route and see how far a feature request for a "font properties" function for _GUICtrlComboBox_Create() will fly.

Edit2: Inserting these two lines between the _GUICtrlComboBox_Create() and _GUICtrlComboBox_SetItemHeight() got the UDF version of ComboBox working better:

$hFont = _WinAPI_CreateFont(12, 0); 12 pixels = 7.5 point? 15pix = 9pt?
_WinAPI_SetFont($_Combo, $hFont)

And then this at script exit:

_WinAPI_DeleteObject($hFont)

(Thanks Smashly and all).

Edited by Spiff59

Share this post


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
Sign in to follow this  
Followers 0