Jump to content

how can i make a button that extends gui


jim1
 Share

Recommended Posts

Here's an example:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIoneventmode", 1)
Opt('GUIResizeMode', 802) 
$expanded = False
GUICreate("GUI",300,300,-1,-1)
guisetstate()
$expand = GUICtrlCreateButton("Expand", 240,10,50,25)
$lol = GUICtrlCreateButton("lol", 400,50,50,25)
GUICtrlSetOnEvent($expand,"expand")
guictrlcreatelabel("SURPRISE!",375,100,100,50)

While 1
    sleep(100)
Wend

Func Expand()
    If $expanded = False Then
        $expanded = True
        WinMove( "GUI", "", default, default,500,332)
    Else
        $expanded = False
        WinMove( "GUI", "", default, default,332,332)
    EndIf
EndFunc

... GUIoneventmode is the only way I know of =( Why won't the program let it work correctly?

Edited by foster74
Link to comment
Share on other sites

thank u

is it possible to do that without those opt? because when i try just the command it just makes the window larger doesnt reveal a new area. In a program i try to do i cant use opt because it doesnt let it work correct. any idea how can i make it without opts and func?

Link to comment
Share on other sites

thank u

is it possible to do that without those opt? because when i try just the command it just makes the window larger doesnt reveal a new area. In a program i try to do i cant use opt because it doesnt let it work correct. any idea how can i make it without opts and func?

The resizing options determine what happens to the controls when the window resizes. The value 802 will keep the controls fixed in the positions and sizes as they were designed relative to the top left of the window. If that isn't what you want then look in the help for GuiCtrlSetResizing.

OR

you need to tell us what opt stops you doing what because because your post didn't really make sense to me :P

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.
Link to comment
Share on other sites

i cant use opt on event mode. so i dont know exactly how i can make button work correct it can extend but not de-extend after u press it one time. i use if/endif for buttons and cant use func because of problem with gui on event mode.

also for some reason if u write same number as gui window will not be sized correct and it need to add +32 why is that?

GUICreate("GUI",300,300,-1,-1)

WinMove( "GUI", "", default, default,500,332)

Link to comment
Share on other sites

i cant use opt on event mode. so i dont know exactly how i can make button work correct it can extend but not de-extend after u press it one time. i use if/endif for buttons and cant use func because of problem with gui on event mode.

also for some reason if u write same number as gui window will not be sized correct and it need to add +32 why is that?

GUICreate("GUI",300,300,-1,-1)

WinMove( "GUI", "", default, default,500,332)

The resizing of controls is not connected to whether or not you use OnEvnt mode.

Unfortunately the AutoIt functions are not consistent IMO when dealing with window sizes. When you crerate a window the dimensions are for the client area, so the window will actually be larger because of the borders and the title bar.

When you use WinMove the size you give is for the window size not the client area, which is why you found that you have to add the height of the title bar plus the width of the border.

I am not sure I understand your extend/de-extend (expand/shrink) problem. If you want one button to toggle the size then you just need to set a variable so that you know which way to adjust the size next time.

If you have a problem then you could show your code and I expect someone would soon tell you how to fix if it's not too long.

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.
Link to comment
Share on other sites

  • 4 weeks later...

if it was me, i'd do something like

...

Global $clicked = 0
Global $Form1 = GUICreate("Form1", 0, 0, 300, 300)
Global $Button1 = GUICtrlCreateButton("...", 10, 10, 75, 25)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
                   if $clicked = 0 then
                      winmove... ;Place the expanded window here
                      $clicked = 1
                   else 
                      winmove ... ; Place the normal window here.
                      $clicked = 0
                   endif
    EndSwitch
WEnd

But then im pretty noobie at this and im sure there are better ways of doing it.

Link to comment
Share on other sites

  • Moderators

jim1,

The last time you asked this question I replied here suggesting that opening child windows might be the way to go.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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