Sign in to follow this  
Followers 0
jennico

change gui style ?

16 posts in this topic

very simple question:

can you change the gui style according to GUICtrlSetStyle ?

or only possible delete and recreate it ?

i found nothing in help and forum.

thx

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites



no that simple, eh ?

:-)


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

i dont think you can change the style of the GUI without Recreating.

but you can change the style of the controls in the GUI after it has bin created.


[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites

very simple question:

can you change the gui style according to GUICtrlSetStyle ?

or only possible delete and recreate it ?

i found nothing in help and forum.

thx

j.

have a look at this.


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

well, okay then it IS possible !

why not make a new function GUISetStyle in next version ???

i think when there exists GUICtrlSetStyle there should also be GUISetStyle.

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Even though I wasn't the original poster of this thread ..

Thank You martin for the heads up.. works a treat.. :)

You can use the A3LWinAPI.au3 to make short work of accomplishing the task , since it has the required call dll functions already written in au3 format that seems easy to follow..

I used _API_SetWindowLong() and _API_SetWindowPos() with the corect params and it works great.

All Good.

Cheers

Edit: Crude no error checking example:

#include<GuiConstants.au3>

Global Const $SWP_NOMOVE = 0x2
Global Const $SWP_NOSIZE = 0x1
Global Const $SWP_SHOWWINDOW = 0x40
Global Const $SWP_NOZORDER = 0x4
Global $hwnd, $iFlags = BitOr($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
Global $wStyle = $WS_CAPTION

$hwnd = GUICreate("Set Window Style", 300, 200, -1, -1, $wStyle)
$button = GUICtrlCreateButton("Change Style to WS_POPUP", 10, 10, 160, 30)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button 
            $aRet = DllCall("User32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -16)
            If $aRet[0] <> 0x94000000 Then 
                $wStyle = $WS_POPUP
                GUICtrlSetData($button, "Change Style to WS_CAPTION")               
            Else 
                $wStyle = $WS_CAPTION
                GUICtrlSetData($button, "Change Style to WS_POPUP")
            EndIf   
            DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hwnd, "int", -16, "ptr", $wStyle)
            DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0,  "int", 0, _
                                                                    "int", 0, "int", 0, "int", $iFlags)
    EndSelect
WEnd

Exit
Edited by smashly

Share this post


Link to post
Share on other sites

See about func GuiSetStyle

here

Valery


The point of world view

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi Valery,

Tried to visit that link you posted but get a msg "your browser isn't accepting cookies "...

But I'm not blocking cookies from the site...

nvm

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

Reproduced from there:

Hi,

I saw Q about this subject. So, you can use this func GuiSetStyle to

reset style of GUI very easy. Try this GuiStyle.au3 :

#include <GuiConstants.au3>
$NewStyle = False
$hWnd = GuiCreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style",45, 50, 150, 20 )
GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case -3
Exit
Case $Style
if not $NewStyle then
GuiSetStyle($WS_POPUPWINDOW+$WS_THICKFRAME,$WS_EX_CLIENTEDGE +$WS_EX_TOOLWINDOW)
GuiCtrlSetData($Style,'Undo Style')
$NewStyle = True
else
GuiSetStyle()
GuiCtrlSetData($Style,'Set Style')
$NewStyle = False
endif
Case Else
EndSwitch
WEnd

;Set Gui Styles
func GuiSetStyle($Style=-1,$ExStyle=0)
Global $GWL_STYLE = -16
Global $GWL_EXSTYLE = -20
if $Style=-1 then
$Style=$WS_MINIMIZEBOX+$WS_CAPTION+$WS_POPUP+$WS_SYSMENU
$res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd,"int", $GWL_STYLE, "int", $Style)
$res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd,"int", $GWL_EXSTYLE, "int", $ExStyle)
WinSetState($hWnd,'', @SW_HIDE)
WinSetState($hWnd,'', @SW_SHOW)
endfunc

Enjoy,

Valery


The point of world view

Share this post


Link to post
Share on other sites

I tried the function , but I think it needs some work..

It's missing an EndIf ,

Also the

WinSetState($hWnd,'', @SW_HIDE)

WinSetState($hWnd,'', @SW_SHOW)

Doesn't refresh the new style for me (I'm using XP SP2)..

I think you need to use WinSetPos api call to get the new style to work,

With the WinSetPos api call you can set the flags for what the window should behave like after changing the styles.

I'm only going from what I've tried and read.

Cheers

Share this post


Link to post
Share on other sites

This is word wrap result...

:)

GuiStyle.au3

#include <GuiConstants.au3>
$NewStyle = False
$hWnd = GuiCreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style",45, 50, 150, 20 )
GUISetState()

While 1
 $Msg = GUIGetMsg()
 Switch $Msg
  Case -3
   Exit
  Case $Style
   if not $NewStyle then
    GuiSetStyle($WS_POPUPWINDOW+$WS_THICKFRAME,$WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW)
    GuiCtrlSetData($Style,'Undo Style')
    $NewStyle = True
   else
    GuiSetStyle()
    GuiCtrlSetData($Style,'Set Style')
    $NewStyle = False
   endif
   Case Else
   EndSwitch
WEnd

;Set Gui Styles
func GuiSetStyle($Style=-1,$ExStyle=0)
Global $GWL_STYLE = -16
Global $GWL_EXSTYLE = -20
 if $Style=-1 then $Style=$WS_MINIMIZEBOX+$WS_CAPTION+$WS_POPUP+$WS_SYSMENU
 $res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
 $res = DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
 WinSetState($hWnd,'', @SW_HIDE)
 WinSetState($hWnd,'', @SW_SHOW)
endfunc

It works for my XP Russian + SP2

Valery


The point of world view

Share this post


Link to post
Share on other sites

This code was verified by big_daddy extension for Firefox, too.

Valery


The point of world view

Share this post


Link to post
Share on other sites

Thanks Valery

Yep it works without the word wrap :)

When I saw the EndIf error I added Endif near the end of the function, hence the failure...lol

But I still think it works better with WinSetPos even though it's more code.

It works instantly instead of the controls disappearing and re-appearing when changing.

#include <GuiConstants.au3>
$NewStyle = False
$hWnd = GuiCreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style",45, 50, 150, 20 )
GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
  Case -3
   Exit
  Case $Style
   if not $NewStyle then
    GuiSetStyle($WS_POPUPWINDOW+$WS_THICKFRAME,$WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW)
    GuiCtrlSetData($Style,'Undo Style')
    $NewStyle = True
   else
    GuiSetStyle()
    GuiCtrlSetData($Style,'Set Style')
    $NewStyle = False
   endif
   Case Else
   EndSwitch
WEnd

;Set Gui Styles
func GuiSetStyle($Style=-1,$ExStyle=0)
Local Const $GWL_STYLE = -16
Local Const $GWL_EXSTYLE = -20
Local Const $SWP_NOMOVE = 0x2
Local Const $SWP_NOSIZE = 0x1
Local Const $SWP_SHOWWINDOW = 0x40
Local Const $SWP_NOZORDER = 0x4
Local $iFlags = BitOr($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
If $Style=-1 Then $Style=$WS_MINIMIZEBOX+$WS_CAPTION+$WS_POPUP+$WS_SYSMENU
DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0,  "int", 0, _
                                                                    "int", 0, "int", 0, "int", $iFlags)
Endfunc

Cheers

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

great work, thank you all, martin, smashly, valery !

smashly's second version works excellent, while the first one produces some strange behaviour (window looses titlebar when not active).

valery's code works, too, maybe not that smooth like smashly's.

i think the function should be included.

thx to all excellent job !!!!

j.

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

It's sort of taste.

More short version:

;Set Gui Styles
func GuiSetStyle($Style=-1,$ExStyle=0)
Local Const $GWL_STYLE = -16
Local Const $GWL_EXSTYLE = -20
Local $iFlags = 0x47
If $Style=-1 Then $Style=$WS_MINIMIZEBOX+$WS_CAPTION+$WS_POPUP+$WS_SYSMENU
DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0,  "int", 0, "int", 0, "int", 0, "int", $iFlags)
Endfunc

:)

Valery


The point of world view

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

very handy, valery,

add it to the other thread for jpm !

j. :-)

(I made an "official" feature request here:)

http://www.autoitscript.com/forum/index.ph...mp;#entry389010

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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