Jump to content

Recommended Posts

Posted (edited)

Have you ever wondered how do I create a GUI like the one shown below?! Then look no further with these Examples. I was playing around with $WS_DLGFRAME and figured that if I BitOR'd it with $WS_SIZEBOX it would create a GUI without the minimize and maximize, but what if I didn't want the re-sizing? After some playing around I realised that replacing $WS_SIZEBOX with $WS_SYSMENU would accomplish this instead of using WM_COMMAND to intercept SC_SIZE from the GUI.

Then ?do=embed' frameborder='0' data-embedContent> pointed out it could be done via a different approach, so I updated using his way :huh2:

Examples below are for both re-sizing and non re-sizing as well as 2 Examples that don't appear in the TaskBar, this is due to using the hidden window [AutoItWinGetTitle()] as the parent handle.

Any suggestions, then please post below. Thanks.

Posted Image

Examples:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example1() ; Without Re-Sizing.
Example2() ; With Re-Sizing.
Example3() ; Without Re-Sizing & No TaskBar.
Example4() ; With Re-Sizing & No TaskBar.

Func Example1() ; Without Re-Sizing.
    Local $hGUI = GUICreate('GUI With Only Close', 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example1

Func Example2() ; With Re-Sizing.
    Local $hGUI = GUICreate('GUI With Only Close', 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MINIMIZEBOX))
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example2

Func Example3() ; Without Re-Sizing & No TaskBar.
    Local $hGUI = GUICreate('GUI With Only Close', 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), -1, WinGetHandle(AutoItWinGetTitle()))
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example3

Func Example4() ; With Re-Sizing & No TaskBar.
    Local $hGUI = GUICreate('GUI With Only Close', 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MINIMIZEBOX), -1, WinGetHandle(AutoItWinGetTitle()))
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example4

Old way I was doing it:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example5() ; Old Way Of Doing It!

Func Example5() ; Old Way Of Doing It!
    Local $hGUI = GUICreate('GUI With Only Close', 250, 250, -1, -1, BitOR($WS_SIZEBOX, $WS_DLGFRAME))

    GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example5

Func WM_SYSCOMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $ilParam
    Local Const $SC_MAXIMIZE = 0xF030, $SC_MINIMIZE = 0xF020, $SC_RESTORE = 0xF120, $SC_SIZE = 0xF000 ; $SC_MOVE = 0xF010
    Switch BitAND($iwParam, 0xFFF0)
        Case $SC_MAXIMIZE, $SC_MINIMIZE, $SC_RESTORE, $SC_SIZE
            Return -1

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND

?do=embed' frameborder='0' data-embedContent>

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

If you look into the help file, and check the style parameter, you will see that there is default styles set:

$WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU

So you just need to remove the $WS_MINIMIZEBOX and you get the wanted result :huh2:

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Thanks for the tip! But both ways are right aren't they? OR not? I only posted because some users will ask this question and now I have a reference post.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

GUICreate("GUI With Only Close", 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) ;I think this one is better
    ;Or
    GUICreate("GUI With Only Close", 250, 250, -1, -1, BitAND($GUI_SS_DEFAULT_GUI, BitNOT($WS_MINIMIZEBOX)))
    ;Or
    GUICreate("GUI With Only Close", 250, 250, -1, -1, $GUI_SS_DEFAULT_GUI - $WS_MINIMIZEBOX)

:huh2:

Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Well, I learnt something today, Thanks. Updated OP.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)
  Quote

Cant say whether its better or worse than your example?

It is moveable. Did you try the Examples? Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 1 year later...
Posted

I've updated the syntax of the examples. Now the handle of the GUI is assigned to a variable and explicitly used in GUIDelete, rather than relying on the 'previously used' default. Any problems then please post below. Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 2 weeks later...
Posted

Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Good job, good stuff, wouldn't it be nice if those examples were present in the help file? along with the most useful udfs and snippets?

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

  On 10/23/2012 at 10:10 AM, 'careca said:

Good job, good stuff, wouldn't it be nice if those examples were present in the help file? along with the most useful udfs and snippets?

Honestly, no. That's not the purpose of the help file I'm afraid, the Forum and help file work in conjunction with one another. Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Yes, they work with each other, but i think sometimes there are bits of code that get "lost" in the forum, like this one you posted, someday you'll probably see someone asking how to create this kind of frame. So if it was present in the help file, maybe not in the function itself of creating windows, but as a "related" function, those who are interested, would check there, instead of scrolling thru dozens of posts to find this one, seems more efficient to me.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

The question remains where though. If you have suggestions please post in the help file section under the Developer section, though bare in mind read the first post.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...