Jump to content

Gui Styles


Radsam
 Share

Recommended Posts

Hi all,

I'm putting together a little tool that will help people understand what the diferent "styles" and "exStyles" will look like.

The following is what I have so far. Feel free to let me know what you think.

#include <GuiConstants.au3>

Dim $Hand
Dim $cQuit
Dim $Checkbox_1
Dim $Checkbox_2
Dim $Checkbox_3
Dim $Checkbox_4
Dim $Checkbox_5
Dim $Checkbox_6
Dim $Desc = "Default:" & @CRLF & "style = -1" & @CRLF & "exStyle = -1"
Dim $iMainHeight = -1; -1 = 400
Dim $iMainStyle = $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU + $WS_SIZEBOX
Dim $iMainExStyle = -1; -1 is default

_GuiCreate($iMainHeight, $iMainStyle, $iMainExStyle)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Checkbox_1
        $Height = -1
        $Style = -1
        $ExStyle = -1
        $Desc = "Default:" & @CRLF & "style = -1" & @CRLF & "exStyle = -1"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_CHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_UNCHECKED)
    Case $msg = $Checkbox_2
        $Height = -1
        $Style = -1
        $ExStyle = $WS_EX_TOOLWINDOW
        $Desc = "TOOLWINDOW:" & @CRLF & "style = -1" & @CRLF & "exStyle = $WS_EX_TOOLWINDOW"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_CHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_UNCHECKED)
    Case $msg = $Checkbox_3
        $Height = 400 + 25
        $Style = $WS_DLGFRAME
        $ExStyle = -1
        $Desc = "DLGFRAME:" & @CRLF & "style = $WS_DLGFRAME" & @CRLF & "exStyle = -1"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_CHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_UNCHECKED)
    Case $msg = $Checkbox_4
        $Height = -1
        $Style = -1
        $ExStyle = $WS_EX_STATICEDGE
        $Desc = "STATICEDGE:" & @CRLF & "style = -1" & @CRLF & "exStyle = $WS_EX_STATICEDGE"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_CHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_UNCHECKED)
    Case $msg = $Checkbox_5
        $Height = 400 + 32
        $Style = $WS_OVERLAPPED
        $ExStyle = -1
        $Desc = "OVERLAPPED:" & @CRLF & "style = $WS_OVERLAPPED" & @CRLF & "exStyle = -1"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_CHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_UNCHECKED)
    Case $msg = $Checkbox_6
        $Height = -1
        $Style = $WS_CAPTION+$WS_POPUP+$WS_SYSMENU
        $ExStyle = $WS_EX_CONTEXTHELP
        $Desc = "CONTEXTHELP:" & @CRLF & "style = $WS_CAPTION+$WS_POPUP+$WS_SYSMENU" & @CRLF & "exStyle = $WS_EX_CONTEXTHELP"
        GUIDelete($Hand)
        _GuiCreate($Height, $Style, $ExStyle)
        GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
        GUICtrlSetState($Checkbox_6,$GUI_CHECKED)
    Case $msg = $cQuit
        Exit
    Case Else
    ;;;
    EndSelect
WEnd

Func _GuiCreate($iHeight, $iStyle, $iExStyle)

$Hand = GUICreate("Gui Types", -1, $iHeight, -1, -1, $iStyle, $iExStyle)    
$Checkbox_1 = GuiCtrlCreateCheckbox("Default", 20, 20, 120, 13)
$Checkbox_2 = GuiCtrlCreateCheckbox("TOOLWINDOW", 20, 35, 120, 13)
$Checkbox_3 = GuiCtrlCreateCheckbox("DLGFRAME", 20, 50, 120, 13)
$Checkbox_4 = GuiCtrlCreateCheckbox("STATICEDGE", 20, 65, 120, 13)
$Checkbox_5 = GuiCtrlCreateCheckbox("OVERLAPPED", 20, 80, 120, 13)
$Checkbox_6 = GuiCtrlCreateCheckbox("CONTEXTHELP", 20, 95, 120, 13)
$Edit = GUICtrlCreateEdit ($Desc, 7, 310, 385, 50, $ES_READONLY, $WS_EX_STATICEDGE )
$cQuit = GuiCtrlCreateButton("Quit", 300, 370, 75, 23)

GuiSetState()
EndFunc
Link to comment
Share on other sites

How sure are you that you understand them? :lmao:

Styles should always be BitOR'd together, not added.

Here's the defintion for WS_CAPTION, it combines 2 styles for convience:

WS_CAPTION (0x00C00000) = WS_BORDER (0x00800000) | WS_DLGFRAME (0x00400000)

Now take the following innocent style:

WS_CAPTION+WS_BORDER

Its redundant, but may not be uncommon in some cases, particularly with WS_OVERLAPPEDWINDOW which or's together several common styles.

Using bitwise OR:

0x00C00000 | 0x00800000 = 0x00C00000

There is no change, all the bits that needed set were already set.

But using addition:

0x00C00000 + 0x00800000 = 0x01400000

That is clearly not the inention. The style you've just made still contains WS_DLGFRAME but it has changed to also include WS_MAXIMIZE (0x01000000) and now excludes WS_BORDER completely.

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...