ALTIN Posted September 18, 2010 Share Posted September 18, 2010 (edited) Could not try your example. I recieve an error *blocked out*\Test2.au3(68,43) : WARNING: $cmdRegister: possibly used before declaration. _GUICtrlButton_Enable($cmdRegister, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ *blocked out*\Test2.au3(68,43) : ERROR: $cmdRegister: undeclared global variable. _GUICtrlButton_Enable($cmdRegister, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ *blocked out*\Test2.au3 - 1 error(s), 1 warning(s) Oh... I forgot to remove one line, though it does not throw any error in my side, but i repaired it now. Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Opt('MustDeclareVars', 0) Opt("GUICloseOnESC", 1) ;1=ESC closes window when ESC is pressed ;main window global variables Global $msgMain, $mainWindow, $mainWidth = 460, $mainHeight = 350 ;main window width & height Global $childOpen ;Group Pro Version ;child window global positioning variables Global $childWidth = 300 ;reg window width Global $childHeight = 150 ;reg window height Global $childLeft = ($mainWidth - $childWidth)/2 ;child left position from main window Global $childTop = ($mainHeight - $childHeight)/2 ;child top position from main window MainGui() Func MainGui() $mainWindow = GUICreate("Main Window", $mainWidth, $mainHeight) ; will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) ; will change background color $childOpen = GuiCtrlCreateButton ("Open", 180, 160, 100, 25) GUISetState(@SW_SHOW) ; Run the GUI until the window is closed While 1 $msgMain = GUIGetMsg() Select Case $msgMain = $GUI_EVENT_CLOSE ExitLoop Case $msgMain = $childOpen Child_Window() EndSelect WEnd GUIDelete() Exit EndFunc ;==>MainGui Func Child_Window() Local $pos = WinGetPos("Main Window") ;get position of main window Local $x = $pos[0] + $childLeft ;set child x position Local $y = $pos[1] + $childTop ;set child y position Global $childWindow = GUICreate("Child Window", $childWidth, $childHeight, $x, $y, $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW, $mainWindow) GUISetBkColor(0xE0FFbb) ; will change background color Global $cmdCancel = GUICtrlCreateButton("&Cancel" , 125, 115, 80, 25) GUISetState(@SW_DISABLE, $childWindow) GUISetState(@SW_SHOW, $childWindow) _GUICtrlButton_Enable($cmdCancel, True) GUISetState(@SW_ENABLE, $childWindow) While 1 $msgChild = GuiGetMsg($childWindow) Select Case $msgChild = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $childWindow) ExitLoop Case $msgChild = $cmdCancel GUISetState(@SW_HIDE, $childWindow) ExitLoop EndSelect WEnd EndFunc ;==>Child window Edited September 18, 2010 by ALTIN Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 Okay, yours has what I am looking for, The Minimizing effect and what the window somewhat looks like. What it does not have is what is currently in my coding for the window to follow it(unless it is not working on my side) Compare yours and mine and you will see the differences(unless its my computer) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $mainwindow = GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) $dummywindow = GUICreate("Dummy window for testing ", 200, 100) GUISetState(@SW_SHOW, $mainwindow) GUISetStyle($WS_BORDER, $WS_EX_TOOLWINDOW, $dummyWindow) While 1 $msg = GUIGetMsg(1) $g1pos = WinGetPos($mainwindow) $g2pos = WinGetPos($dummywindow) If WinActive($mainwindow) = true Then WinSetOnTop($dummywindow, "", 1) else WinSetOnTop($dummywindow, "", 0) EndIf If $g2pos[0] <> $g1pos[0] + $g1pos[2] or $g2pos[1] <> $g1pos[1] Then WinMove($dummywindow,"",$g1pos[0]+$g1pos[2],$g1pos[1]) Select Case $msg[0] = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") GUISetState(@SW_SHOW, $dummywindow) Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE on the main window! Exiting...") ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
ALTIN Posted September 18, 2010 Share Posted September 18, 2010 Ok, now I understood exactly what you want I almost did it in my previous script, you just have to add these lines in the While loop in child window function: $g1pos = WinGetPos($mainwindow) $g2pos = WinGetPos($childWindow) If $g2pos[0] <> $g1pos[0] + $g1pos[2] or $g2pos[1] <> $g1pos[1] Then WinMove($childWindow,"",$g1pos[0]+$g1pos[2],$g1pos[1]) So this is the fully working script: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Opt('MustDeclareVars', 0) Opt("GUICloseOnESC", 1) ;1=ESC closes window when ESC is pressed ;main window global variables Global $msgMain, $mainWindow, $mainWidth = 460, $mainHeight = 350 ;main window width & height Global $childOpen ;Group Pro Version ;child window global positioning variables Global $childWidth = 300 ;reg window width Global $childHeight = 150 ;reg window height Global $childLeft = ($mainWidth - $childWidth)/2 ;child left position from main window Global $childTop = ($mainHeight - $childHeight)/2 ;child top position from main window MainGui() Func MainGui() $mainWindow = GUICreate("Main Window", $mainWidth, $mainHeight) ; will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) ; will change background color $childOpen = GuiCtrlCreateButton ("Open", 180, 160, 100, 25) GUISetState(@SW_SHOW) ; Run the GUI until the window is closed While 1 $msgMain = GUIGetMsg() Select Case $msgMain = $GUI_EVENT_CLOSE ExitLoop Case $msgMain = $childOpen Child_Window() EndSelect WEnd GUIDelete() Exit EndFunc ;==>MainGui Func Child_Window() Local $pos = WinGetPos("Main Window") ;get position of main window Local $x = $pos[0] + $childLeft ;set child x position Local $y = $pos[1] + $childTop ;set child y position Global $childWindow = GUICreate("Child Window", $childWidth, $childHeight, $x, $y, $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW);, $mainWindow) GUISetBkColor(0xE0FFbb) ; will change background color Global $cmdCancel = GUICtrlCreateButton("&Cancel" , 125, 115, 80, 25) GUISetState(@SW_DISABLE, $childWindow) GUISetState(@SW_SHOW, $childWindow) _GUICtrlButton_Enable($cmdCancel, True) GUISetState(@SW_ENABLE, $childWindow) While 1 $msgChild = GuiGetMsg($childWindow) Select Case $msgChild = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $childWindow) ExitLoop Case $msgChild = $cmdCancel GUISetState(@SW_HIDE, $childWindow) ExitLoop EndSelect $g1pos = WinGetPos($mainwindow) $g2pos = WinGetPos($childWindow) If $g2pos[0] <> $g1pos[0] + $g1pos[2] or $g2pos[1] <> $g1pos[1] Then WinMove($childWindow,"",$g1pos[0]+$g1pos[2],$g1pos[1]) WEnd EndFunc ;==>Child window Correct now??? Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 Exactly, Longer coding though. Maybe my coding had a few holes in it that would not have worked. Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 (edited) Exactly, Longer coding though.Maybe my coding had a few holes in it that would not have worked.There is still one more thing though. If you Don't minimize the program and you go into another window say your web browser(as which is what I just did)If you go back to the program, The second window does not show up, it says back where is was(as my original problem also has Happened.)Thinking about it. Maybe my code(with the help of *cant remember name*) and your code works in similarities.I tried to do it with my code, if you try. Run the programOpen the second windowGo to another window and go back to it from the task bar a few times, maybe even clicking on the main window, every so often the WinActive() event does not run.May put pictures up if this is confusing.Edit: May even upload a video to show exactly what I have been dealing with if you guys need me to. Edited September 18, 2010 by KurogamineNox Link to comment Share on other sites More sharing options...
ALTIN Posted September 18, 2010 Share Posted September 18, 2010 (edited) May put pictures up if this is confusing. Edit: May even upload a video to show exactly what I have been dealing with if you guys need me to. there is no need,, Just modify the child window with this: Global $childWindow = GUICreate("Child Window", $childWidth, $childHeight, $x, $y, $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW, $mainWindow) ...what I did now is I just added $mainWindow handle to the end of this line Finished now? Edited September 18, 2010 by ALTIN Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 Oh My Gawd. It Worked! No Glitches! Longer Code BUT STILL! Results are what I NEEDED! This forum is such a great help. Thank you all for helping me. Link to comment Share on other sites More sharing options...
ALTIN Posted September 18, 2010 Share Posted September 18, 2010 (edited) Oh My Gawd. It Worked! No Glitches! Longer Code BUT STILL! Results are what I NEEDED! This forum is such a great help. Thank you all for helping me.LOL such a long post for a simple thing, but it took a long time to understand what you needed exactly.Glad we could help, have a great programming time Edit:Longer Code BUT STILL! Results are what I NEEDED!Yes, it's a bit longer code but this is the right way to do it I think... Edited September 18, 2010 by ALTIN Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 LOL such a long post for a simple thing, but it took a long time to understand what you needed exactly. Glad we could help, have a great programming time Edit: Yes, it's a bit longer code but this is the right way to do it I think... Lol right way wrong way, what matters to me are results. Was able to adapt your code. Aparently all I needed was to make the main window the parent window for the childwindow and the original coding I was working with works perfectly(As far as I can tell) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $mainwindow = GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) ;$dummywindow = GUICreate("Dummy window for testing ", 200, 100) $dummywindow = GUICreate("Child Window", 200, 100, "", "", $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW, $mainWindow) GUISetState(@SW_SHOW, $mainwindow) ;GUISetStyle($WS_BORDER, $WS_EX_TOOLWINDOW, $dummyWindow) While 1 $msg = GUIGetMsg(1) $g1pos = WinGetPos($mainwindow) $g2pos = WinGetPos($dummywindow) If $g2pos[0] <> $g1pos[0] + $g1pos[2] or $g2pos[1] <> $g1pos[1] Then WinMove($dummywindow,"",$g1pos[0]+$g1pos[2],$g1pos[1]) Select Case $msg[0] = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") GUISetState(@SW_SHOW, $dummywindow) Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE on the main window! Exiting...") ExitLoop EndSelect WEnd Experiment if you like, both codes seem to work very similer even though the size difference is much different. Link to comment Share on other sites More sharing options...
ALTIN Posted September 18, 2010 Share Posted September 18, 2010 (edited) Experiment if you like, both codes seem to work very similer even though the size difference is much different.Yes I see what you mean but remember that your original code does not actually contain the loop to control it and it's controls (you will need to add some controls on it, right?)...anyway problem seems to be solved now, and I'm sleepy (it's 4:32AM here)Goodnight autoit! Edited September 18, 2010 by ALTIN Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 18, 2010 Author Share Posted September 18, 2010 Yes I see what you mean but remember that your original code does not actually contain the loop to control it and it's controls (you will need to add some controls on it, right?)...anyway problem seems to be solved now, and I'm sleepy (it's 4:32AM here)Goodnight autoit! Lol your like on the other side of the world(7:46pm)Basically I am adapting this code to my main program. I experiment with new functions in a separate program then I adapt them to the main program. That way I know how the program runs before I make any changes to the main program.The While is the loop, though my program is only missing a few button functions. I already know how to do that so It was intentionally left out as I will add the stuff I need while adapting it to the main program. Well good night to you, get a good nights rest. Lol. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now