Sign in to follow this  
Followers 0
Info

GuiCtrlSetStyle() Doesn't seem to work for me

6 posts in this topic

#1 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 314, 45, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 8, 8, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetStyle($Button1,"",$WS_EX_CLIENTEDGE)
            GUISetState(@sw_hide)
            GUISetState(@sw_show)
    EndSwitch
WEnd

notice the GUISetState(@sw_hide) and the GUISetState(@sw_show), I tried "refreshing" the GUI but it still doesn't work :)

Edited by Info

Share this post


Link to post
Share on other sites



???

doesn't work...

Share this post


Link to post
Share on other sites

???

doesn't work...

I think you can't change the style of a button to certain styles. You could delete it and create it again.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 314, 45, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 8, 8, 65, 25)
GUISetState(@SW_SHOW)
#EndRegion### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ;GUICtrlSetStyle($Button1, -1, $WS_EX_CLIENTEDGE)
            GUICtrlDelete($Button1)
            $Button1 = GUICtrlCreateButton("Button1", 8, 8, 65, 25,-1, $WS_EX_CLIENTEDGE)
            ;GUISetState(@SW_HIDE);I don't see what these are for
            ;GUISetState(@SW_SHOW);unless you thought redrawing would help?
    EndSwitch
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Actually, you can change it on the fly, but you have to call SetWindowPos() to update the cache:

#include <WindowsConstants.au3>
#include <Constants.au3>

$gui = GUICreate("test", 200, 200)
$b1 = GUICtrlCreateButton("b1", 10, 10, 50, 25)
$b2 = GUICtrlCreateButton("b2", 65, 10, 50, 25)

GUISetState()

Sleep(2000)
ConsoleWrite("Now we change the button style..." & @CRLF)
GUICtrlSetStyle($b2, -1, $WS_EX_CLIENTEDGE)
ConsoleWrite("Nothing happened?  Let's try this..." & @CRLF)
Sleep(2000)
$call = DllCall("user32.dll", "int", "SetWindowPos", "hwnd", GUICtrlGetHandle($b2), "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, _
                        "uint", BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER, $SWP_FRAMECHANGED))
ConsoleWrite("Return:  " & $call[0] & @CRLF)
ConsoleWrite("Ah, the sweet taste of victory." & @CRLF)

Do
Until (GUIGetMsg() = -3)
Edited by wraithdu

Share this post


Link to post
Share on other sites

Thanks :)

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