Jump to content

Link 2 GUI window


 Share

Recommended Posts

At the beginning, I made only one Gui window will all my stuff in it. After a while, I realised that it would be better to split my gui window into two little one. While doing this, I encountered alot of errors.

First of all, I want to know how to link two guis windows as one. Even if there's two windows open I want that in the taskbar, it appear only at once. Those windows have to be link so if I minimize one, it will minimise the other.

Using two windows, I got alot of errors with my variables.

Here's my first script (only 1 GUI window):

#include <GuiConstants.au3>


GuiCreate("First GUI", 100, 105,50, -1,$WS_CAPTION)

$Image_0 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 50, 50, 40, 40)
$Image_1 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 10, 50, 40, 40)

$Button_1 = GuiCtrlCreateButton("", 23, 10, 35, 35, $BS_BITMAP)
GUICtrlSetImage($Button_1, @ScriptDir & "\Images\FirstPic.bmp")

Guisetstate()

$File1 = @ScriptDir & "\Images\blank.bmp"

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    
    Case $msg = $Button_1
    $File1 = @ScriptDir & @ScriptDir & "\Images\FirstPic.bmp"
    
    Case $msg = $Image_0
    GuiCtrlSetImage($Image_0, $File1)
    
    Case $msg = $Image_1
    GuiCtrlSetImage($Image_1, $File1)

            Case $msg = $GUI_EVENT_SECONDARYDOWN
            $ControlID = GUIGetCursorInfo()
            
            ;Set the square blank on right click
            For $a = 0 to 1
                
                If $ControlID[4] = Eval('Image_' & $a) Then
                    GUICtrlSetImage($ControlID[4], @ScriptDir & "\Images\blank.bmp")
                Else
                EndIf
            Next

    EndSelect
WEnd
Exit
oÝ÷ Ù©ÝêÞßÛ&ÊÇ¢wlr¸©´Ì¦j)àº,"Ú0²b¶×{hÛ§v,jëh×6

#include <GuiConstants.au3>


GuiCreate("First GUI", 100, 105,50, -1,$WS_CAPTION)

$Image_0 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 50, 50, 40, 40)
$Image_1 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 10, 50, 40, 40)

GuiSetstate()
GuiCreate("Second GUI", 100, 105,800, -1,$WS_SYSMENU)

$Button_1 = GuiCtrlCreateButton("", 23, 30, 35, 35, $BS_BITMAP)
GUICtrlSetImage($Button_1, @ScriptDir & "\Images\FirstPic.bmp")

Guisetstate()

$File1 = @ScriptDir & "\Images\blank.bmp"

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    
    Case $msg = $Button_1
    $File1 = @ScriptDir & "\Images\FirstPic.bmp"
    
    Case $msg = $Image_0
    GuiCtrlSetImage($Image_0, $File1)
    
    Case $msg = $Image_1
    GuiCtrlSetImage($Image_1, $File1)

            Case $msg = $GUI_EVENT_SECONDARYDOWN
            $ControlID = GUIGetCursorInfo()
            
            ;Set the square blank on right click
            For $a = 0 to 1
                
                If $ControlID[4] = Eval('Image_' & $a) Then
                    GUICtrlSetImage($ControlID[4], @ScriptDir & "\Images\blank.bmp")
                Else
                EndIf
            Next

    EndSelect
WEnd
Exit

The right click case that work in one window give me an error message when my main window is splitted in 2 :shocked:

I hope I provided enough information to help me.

Thanks !

DOWNLOAD

If you want to see what happen with the right pictures:

GUI_windows.rar

Edited by Dieuz
Link to comment
Share on other sites

Hi,

how to link two guis windows as one

Try to make the second one as a child window...

.....
;Get window handel that returned by GuiCreate (into $Parent variable)...
$Parent = GuiCreate("First GUI", 100, 105,50, -1,$WS_CAPTION)

$Image_0 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 50, 50, 40, 40)
$Image_1 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 10, 50, 40, 40)

GuiSetstate()
GuiCreate("", 100, 105,800, -1,$WS_SYSMENU,-1, $Parent) ;Using the window handel ($Parent) to set this window as a child window.
.....oÝ÷ Ú«¨µäáz¸ ×%ÉjÇ­«p¢¹"ÞÂ)Ý£"½éjw«®æzËïêº^b¦ºËlzا¶¬q«¶¨¦Ø¨©ij¶¦z׫¡ñ®g­
ê좲'~¬k§©ÝzZj«z{pwhÁ«­¢+ظ¸¸)U%Ñ
ÕÉͽÉ%¹¼ ÀÌØíAɹФìÀÌØíAɹХÌÑ¡Ý¥¹½Ü¡¹°Ñ¡ÐÉÑÕɹäÕ¥
ÉÑ ¤¸(¸¸¸
Edited by MsCreatoR

 

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

Link to comment
Share on other sites

Thanks alot MsCreator, that worked! :shocked:

The only problem is that if I select one of the two windows, it deselect the other one ( I mean the other one stop being active). How can both windows be alway active and always in front (even if you open something, the windows will alway stay on the screen and never diseapear) ?

Edited by Dieuz
Link to comment
Share on other sites

How can both windows be alway active

This is impossible (i think :shocked: ), just one window can be active at the same time.

and always in front

If you mean always on top, then just use the $WS_EX_TOPMOST exStyle...

...
GuiCreate("First GUI", 100, 105,50, -1,$WS_CAPTION, $WS_EX_TOPMOST)
....

Glad to help :(

 

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

Link to comment
Share on other sites

Well if they cannot be "active" at the same time, can they only "look" both active?

When I select one of the two windows, it unselect the other one and the color of the title bar change:

Posted Image

How can I make both windows keep the same title bar's color at any time?

Edited by Dieuz
Link to comment
Share on other sites

Well if they cannot be "active" at the same time, can they only "look" both active?

When I select one of the two windows, it unselect the other one and the color of the title bar change:

Posted Image

How can I make both windows keep the same title bar's color at any time?

I think that happens because the one with dark blue with active. I don't think it's possible to make is so they both stay dark blue...

One thing that I've done was make my own backgrounds which don't change color when inactive. The only problem with this is that on the windows tray (if that's what you call) it still will make the active window look as if it's pushed and the inactive look unpushed.

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

There's no way to set it like if it was only one window splitted in 2?

You can make a custom title, then bouth windows will look the same :shocked:

Somthing likle this:

#include <GuiConstants.au3>

;Parent windoe
$Parent = GUICreate("Win1", 200, 200, 300, -1, $WS_POPUPWINDOW, $WS_EX_STATICEDGE+$WS_EX_TOPMOST)

GUICtrlCreateLabel("My Title 1", 13, 0, 170, 15, $ES_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x0505E0)

$CloseButton1 = GUICtrlCreateButton("X", 182, 0, 15, 15)

;Child Window
$Child = GUICreate("Win2", 200, 200, 500, -1, $WS_POPUPWINDOW, $WS_EX_STATICEDGE+$WS_EX_TOPMOST, $Parent)

GUICtrlCreateLabel("My Title 2", 13, 0, 170, 15, $ES_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x0505E0)

$CloseButton2 = GUICtrlCreateButton("X", 182, 0, 15, 15)

GUISetState(@SW_SHOW, $Parent)
GUISetState(@SW_SHOW, $Child)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3, $CloseButton1, $CloseButton2
            Exit
        Case Else
            ;;;
    EndSwitch
WEnd

 

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

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