Jump to content
cliff48

Using 2 windows (

Recommended Posts

cliff48

hi all, newbie here and have been reading many forum posts and the help file to try to learn.

 

The example in the help file with GUICreate using 2 windows (one is called $hDummyGUI) does not display the DummyGUI Window, and gets an error after clicking the OK Button:

MsgBox($MB_OK, "GUI Event", "You selected OK!")
MsgBox(^ ERROR
>Exit code: 1    Time: 3.336

 

I also have had a problem with GUICreate trying to set the Window  Style:

GUICreate("My GUI menu", 300, 200, -1, -1, style = $WS_OVERLAPPEDWINDOW)
GUICreate("My GUI menu", 300, 200, -1, -1, ^ ERROR
 

I have an example that did work... the 'style =' was removed and was using $WS_POPUP .. so I tried:

GUICreate("My GUI menu", 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW)
GUICreate("My GUI menu", 300, 200, -1, -1, ^ ERROR

 

I am sure I am doing something wrong, so any advice would be appreciated.

Win 7 Ultimate 64bit, SciTE-Lite 3.5.4, AutoIt 32 bit 3.3.14.0

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
cliff48

OK,  I found the solution to the second part of the problem, the helpfile example didn't have :

#include <MsgBoxConstants.au3>

plus I needed to add:

GUISwitch($hDummyGUI)
GUISetState(@SW_SHOW)

 

So my remaining problem is how to set Window Styles as described in the Help File?

Share this post


Link to post
Share on other sites
Melba23

cliff48,

Welcome to the AutoIt forums.

My Help file does not have a GUICreate example with a $hDummyGUI window - can you post the full script you are trying to run (see here how to do it).  I also think that you do not have an up-to-date AutoIt version as we check all the help file examples to make sure that the correct includes are present, so I find it hard to believe that an actual example would be a missing one (which is also the reason you are getting the $WS_OVERLAPPEDWINDOW error - you need to include WindowsConstants.au3).

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

cliff48,

Do you mean this script from the GUI Reference section? That is the only $hDummyGUI I can find in the Help file.

#include <Constants.au3>
#include <GUIConstantsEx.au3>

Local $hMainGUI = GUICreate("Hello World", 200, 100)
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
Local $iOKButton = GUICtrlCreateButton("OK", 70, 50, 60)

Local $hDummyGUI = GUICreate("Dummy window for testing", 200, 100)

GUISwitch($hMainGUI)
GUISetState(@SW_SHOW)

Local $aMsg = 0
While 1
    $aMsg = GUIGetMsg(1)

    Select
        Case $aMsg[0] = $iOKButton

            MsgBox($MB_SYSTEMMODAL, "GUI Event", "You selected OK!")

        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $hMainGUI

            MsgBox($MB_SYSTEMMODAL, "GUI Event", "You selected CLOSE on the main GUI! Exiting...")
            ExitLoop

    EndSelect
WEnd

If so, then there was never any intention to show the dummy GUI - it is just there to show how you can differentiate between different GUIs when it comes to system messages like $GUI_EVENT_CLOSE. But the script runs fine for me as it is - so I still wonder about your AutoIt version.

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
cliff48

https://www.autoitscript.com/autoit3/docs/guiref/GUIRef_OnEventMode.htm

 

Yes - that appears to be the same one.  

As I said, I have managed to now get that working.  I guess the only problem(?) that remains is the Help File description of GUICreate:

GUICreate ( "title" [, width [, height [, left = -1 [, top = -1 [, style = -1 [, exStyle = -1 [, parent = 0]]]]]]] )

 

That implies to me that 'style' is an optional parameter where I could have something like:

GUICreate("My test gui",  200, 200,  style = WS_OVERLAPPEDWINDOW)

Which I now realise is incorrect, but I am sure it would confuse other newbies too.

I did have an older version of AutoIt installed, but after reading the forum I downloaded v3.3.14.  I did uninstall the original version first.

 

If fact, I installed the latest version to c:\AutoIt because the first version was installed in C:\Program Files but that was a problem because  a compile would attempt to write compiled script in the folder...  which of course it cant do.

 

Maybe there are still some remnants of my original install causing problems.  Foe example, following the tutorial ...  when I select 'New' I am supposed to get a template in the editor  ... but I just get an empty editor.

 

Anyway, I seem to be struggling along and am quite enjoying it.


 

 

 

 

 

 

Share this post


Link to post
Share on other sites
Melba23

cliff48,

The "optional parameter" syntax that we have is pretty widely used - but I will look to see if we can add something to the Help file to make it clearer.

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

×