Sign in to follow this  
Followers 0
TeddyTech

Toggle Form Frame?

5 posts in this topic

I'm simply trying to toggle a form title bar and frame off and on. If I click on the label on the form I can turn everything off, but I cannot seem to figure out how to toggle it back on.

(This is for a temperature monitoring window that I want to show just the temperature value in a large font with no frame, but have the ability to turn on the title bar to make it easy to position the window.)

Here's a simple example of what my code so far:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Toggle=True
Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 120, 150, 192, 114,$WS_SYSMENU)
$Label1 = GUICtrlCreateLabel("Click Here to toggle header", 0, 0)
GUICtrlSetOnEvent(-1, "LabelPressed")
GUISetState(@SW_SHOW)

While 1
    Sleep(500)
WEnd

Exit

Func LabelPressed()
    If $Toggle Then
        GUISetStyle($WS_POPUPWINDOW)
        GUICtrlSetData($Form1, 'Undo Style')
        $Toggle = NOT $Toggle
    Else
        GUISetStyle($WS_SYSMENU)
        GUICtrlSetData($Form1, 'Set Style')
        $Toggle = NOT $Toggle
    EndIf
EndFunc

Thanks for any help.

Teddy

Share this post


Link to post
Share on other sites



TeddyTech,

Welcome to the AutoIt forum. :)

Whiel I am looking at your script, you might like to look at the Moving and Resizing PopUp GUIs tutorial in the Wiki. It might make the whole problem moot if you can easily position the pop-up window. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

TeddyTech,

Solution was simple. If you want the $WS_SYSMENU style, it says int eh Help file that you must also specify the $WS_CAPTION style.

And when you do this you get what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Toggle = True
Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 120, 150, 192, 114, $WS_SYSMENU)
$Label1 = GUICtrlCreateLabel("Click Here to toggle header", 0, 0)
GUICtrlSetOnEvent(-1, "LabelPressed")
GUISetState(@SW_SHOW)

While 1
    Sleep(500)
WEnd

Exit

Func LabelPressed()
    If $Toggle Then
        GUISetStyle($WS_POPUPWINDOW)
        GUICtrlSetData($Form1, 'Undo Style')
        $Toggle = Not $Toggle
    Else
        GUISetStyle(BitOr($WS_SYSMENU, $WS_CAPTION))
        GUICtrlSetData($Form1, 'Set Style')
        $Toggle = Not $Toggle
    EndIf
EndFunc   ;==>LabelPressed

But I recommend the tutorial anyway! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba23,

Duh! I've been using AutoIT a lot for several years, but never much with the GUI. I looked all over the help files, but missed that little tidbit.

And I will definitely look at the wiki. I would really like to be able to make the window movable without having to put a title bar on it and it sounds like that page may tell me how.

Thanks again for the accurate ... and quick ... assistance.

Teddy

Share this post


Link to post
Share on other sites

TeddyTech,

My pleasure. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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