Jump to content

[BUG 3.3.8.1] GUISetState, something doesn't add up


Recommended Posts

In many years that I use this language i have never create a "resizable" GUI, at least with the Maximize button enabled :D

The first time i'll try i have found something doesn't add up, like title

GUISetState Help:

When windows are created they are initially hidden so you must use this function to display them (@SW_SHOW)

 

 Ok, the GUI is initially hidden so style like:

@SW_MINIMIZE

@SW_MAXIMIZE

Not work because before you need to add @SW_SHOW. Fortunately, we also have:

@SW_SHOWMINIMIZED

@SW_SHOWMAXIMIZED

In my mind @SW_SHOWMINIMIZED = @SW_SHOW + @SW_MINIMIZED

In fact:

$hGUI = GUICreate("", 230, 175, -1, -1)
GUISetState(@SW_SHOWMINIMIZED)

Work like expected, the GUI start minimized. But for unknow reason i can't do the same with @SW_SHOWMAXIMIZED

I have try:

$hGUI = GUICreate("", 230, 175, -1, -1, $WS_MAXIMIZEBOX)
GUISetState(@SW_SHOWMAXIMIZED) 
$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
GUISetState(@SW_SHOWMAXIMIZED) 

And not work, but this yes:

$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
GUISetState(@SW_SHOW)
GUISetState(@SW_SHOWMAXIMIZED) 

I need to @SHOW two times? Why? In this way the GUI start with W.230 H.175 and THEN Maximize instead of start directly maximized.

The WINAPI version work fine:

$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
_WinAPI_ShowWindow($hGUI, @SW_SHOWMAXIMIZED) 

So i don't want an alternative, i'd like to know why the internal GuiSetState work like expected with @SW_SHOWMINIMIZED but not with @SW_SHOWMAXIMIZED, if it is a style problem or things like that

Thanks 

Edited by johnmcloud
Link to comment
Share on other sites

This works for me (Win 7, 32 and 64 bit, 3.3.10):

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
GUISetState(@SW_SHOWMAXIMIZED)

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd
Link to comment
Share on other sites

Just an FYI, most of the styles being set in this line are the defaults, so you can do this a lot easier.

$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
; can be done like this
$hGUI = GUICreate("", 230, 175, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This works for me (Win 7, 32 and 64 bit, 3.3.10):

 

Work with the last stable version, i'm still stuck to 3.3.8.1 and with that version not work. The breaking things make me scared :D

Edited by johnmcloud
Link to comment
Share on other sites

Not, because LarsJ answer doesn't have the information "work with last stable but not with the previus stable" and i have quoted him in my post.

P.S. Is "Mark Solved", not "Best Answer" and i know how to use the forum :D

Edited by johnmcloud
Link to comment
Share on other sites

I don't have idea was a bug, i have think a style problem or similar issue.

The script you can find in LarsJ post or in my first post with the macro @SW_SHOWMAXIMIZED don't show nothing with 3.3.8.1 but work fine with 3.3.1.0, whatever style you use.

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