Sign in to follow this  
Followers 0
LeHuynhNam

I need more help with gui!

4 posts in this topic

I have a gui like that

Posted Image

and when i click expand button it appears

Posted Image

and when i click contract button it returns gui 1

What can i do to do this?


I'm Learner Of English so my words can have many mistake! I'll try my best to improve it

Share this post


Link to post
Share on other sites



You can use 2 different methods to handle this problem.

Method 1: Have 2 GUIs and only one is shown. The small screen would be shown by default. When the "Expand" button is clicked, the GUI that is the small screen is hidden while the GUI that is the big screen is shown. Use GUISetState to do this. You will need to make sure you use unique IDs for all the controls in both GUIS so that there is no conflict.

Method 2: Use one GUI, but when the "Expand" button is clicked, have the GUI resize itself with WinMove, and move the controls with GUICtrlSetPos. When the "Contract" button is clicked, you will need to move the controls back.

Either method will work, but it depends on how you want to do it.

Share this post


Link to post
Share on other sites

Method 2 example:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
;

Global $hImageList

$hGUI = GUICreate("Expand GUI Example", 300, 200, -1, -1, -1, $WS_EX_TOOLWINDOW)

#Region Expanded controls
$sOld_Opt_GRM = Opt("GUIResizeMode", $GUI_DOCKALL)

$Expand_Button = GUICtrlCreateButton("Expand", 20, 80, 80, 22, $BS_ICON)
_GUICtrlButton_SetImageEx($hImageList, $Expand_Button, @SystemDir & "\rasdlg.dll", 14)

GUICtrlCreateButton("Some Button", 20, 240, 80)
GUICtrlCreateButton("Other Button", 120, 240, 80)
GUICtrlCreateInput("Some Input", 20, 200, 200, 20)

Opt("GUIResizeMode", $sOld_Opt_GRM)
#EndRegion Expanded controls
;

GUISetState()

While 1
    $Msg = GUIGetMsg()
    
    Switch $Msg
        Case -3
            _GUIImageList_Destroy($hImageList)
            Exit
        Case $Expand_Button
            _Toggle_ExpandControls_Proc($hGUI, 300, 200, $Expand_Button)
    EndSwitch
WEnd

Func _Toggle_ExpandControls_Proc($hWnd,$iInitWndHeight,$iExpndHeight,$iExpndCtrlID,$sExpndText="Expand",$sCntrctText="Contract")
    Local $iHeight, $sButtonText, $aSysCaptMetrics, $aSysBordMetrics
    
    Local Const $SM_CYCAPTION       = 4 ;Caption (Title) heigth
    Local Const $SM_CXFIXEDFRAME    = 7 ;Window border size
    
    $aSysCaptMetrics = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYCAPTION)
    $aSysBordMetrics = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CXFIXEDFRAME)
    
    $aGuiPos = WinGetPos($hWnd)
    
    If $aGuiPos[3] < $iInitWndHeight + $aSysCaptMetrics[0] Then
        _GUICtrlButton_SetImageEx($hImageList, $Expand_Button, @SystemDir & "\rasdlg.dll", 16)
        
        $iHeight = $iInitWndHeight + $aSysCaptMetrics[0] + $aSysBordMetrics[0]
        $sButtonText = $sCntrctText
    Else
        _GUICtrlButton_SetImageEx($hImageList, $Expand_Button, @SystemDir & "\rasdlg.dll", 14)
        
        $iHeight = $iExpndHeight + $aSysCaptMetrics[0] + $aSysBordMetrics[0] + 2
        $sButtonText = $sExpndText
    EndIf
    
    GUICtrlSetData($iExpndCtrlID, $sButtonText)
    WinMove($hWnd, "", $aGuiPos[0], $aGuiPos[1], $aGuiPos[2], $iHeight)
EndFunc

Func _GUICtrlButton_SetImageEx(ByRef $hImageList, $nCtrl, $sIconFile, $nIconID=0, $nAlign=-1)
    If $hImageList Then _GUIImageList_Destroy($hImageList)
    
    $hImageList = _GUIImageList_Create(16, 16, 5, 1)
    _GUIImageList_AddIcon($hImageList, $sIconFile, $nIconID)
    
    Local $stBIL = DllStructCreate("dword;int[4];uint")
    
    DllStructSetData($stBIL, 1, $hImageList)
    DllStructSetData($stBIL, 2, 1, 1)
    DllStructSetData($stBIL, 2, 1, 2)
    DllStructSetData($stBIL, 2, 1, 3)
    DllStructSetData($stBIL, 2, 1, 4)
    DllStructSetData($stBIL, 3, $nAlign)
    
    Return GUICtrlSendMsg($nCtrl, $BCM_SETIMAGELIST, 0, DllStructGetPtr($stBIL))
EndFunc

:)


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks for quick reply but when i have a skin with this gui, can it changed?


I'm Learner Of English so my words can have many mistake! I'll try my best to improve it

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