Jump to content

Child window is movable with it's parent, but


Recommended Posts

I have this script:

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

$FormMain = GUICreate("Test", 633, 441, 10, 10)
$button1 = GUICtrlCreateButton("Child_1", 100, 400, 100, 20)
$button2 = GUICtrlCreateButton("Child_2", 400, 50, 100, 20)
GUISetState(@SW_SHOW)
$Form2 = GUICreate("Child", 100, 300, 10, 10, $WS_CHILD, -1, $FormMain)
$label1 = GUICtrlCreateLabel("Test Label1", 5, 5, 90)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$label2 = GUICtrlCreateLabel("Test Label2", 5, 270, 90)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetBkColor ( 0xFF0000)
GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        case $button1
            _show_child_window(ControlGetHandle($FormMain, "", $button1))
        case $button2
            _show_child_window(ControlGetHandle($FormMain, "", $button2))
    EndSwitch
WEnd

func _show_child_window($button_handle)
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form2, "int", 500, "long", 0x00050008)
        GUISetState(@SW_HIDE, $Form2)
        $position = ControlGetPos($FormMain, "", $button_handle)
        WinMove($Form2, "", $position[0], $position[1]+$position[3])
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form2, "int", 500, "long", 0x00040004)
        GUISetState(@SW_SHOW, $Form2)
EndFunc

is it possible to make a child on button1, display outside of it's parent, but still movable when user move the parent window?

Edited by sandin
Link to comment
Share on other sites

$Form2 = GUICreate("Child", 100, 300, 10, 10, $WS_CLIPCHILDREN, $WS_EX_MDICHILD + $WS_EX_TOOLWINDOW, $FormMain)

if you don't like the border then you can change the back to $WS_CHILD after the move just check until the person right click on the control and then change the thing to whatever you wanted $WS_EX_MDICHILD and $WS_CLIPCHILDREN make it so you don't have a X to close it

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Link to comment
Share on other sites

Here is my little help:

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

$Gui = GuiCreate("Test", 300, 200)
$ChildGui = GuiCreate("Child test", 75, 23, -1, -1,$WS_POPUP, $WS_EX_MDICHILD, $Gui)
$button = GUICtrlCreateButton("Button",0,0,75,23)

$ParentPosArr = WinGetPos($Gui)
WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1]+5)
WinSetTrans($ChildGui, '', 250)

GUISetState(@SW_SHOW, $Gui)
GUISetState(@SW_SHOW, $ChildGui)
GUIRegisterMsg(0x231, "On_WM_ENTERSIZEMOVE")
GUIRegisterMsg(0x232, "On_WM_EXITSIZEMOVE")

While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[1] = $Gui And $Msg[0] = -3
            Exit
    EndSelect
WEnd
Func On_WM_ENTERSIZEMOVE()
;~     WinSetTrans($ChildGui, '', 100)
    GUICtrlSetData($button,"Moving")
EndFunc
Func On_WM_EXITSIZEMOVE()
;~     WinSetTrans($ChildGui, '', 200)
    GUICtrlSetData($button,"Button")
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

My solution:

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

$Gui = GUICreate("Test", 633, 441, -1, -1)
$button1 = GUICtrlCreateButton("Child_1", 100, 300, 100, 30)
$button2 = GUICtrlCreateButton("Child_2", 400, 50, 100, 20)
$ChildGui = GuiCreate("Child test", 100, 300, -1, -1,$WS_POPUP, $WS_EX_MDICHILD, $Gui)
$label1 = GUICtrlCreateLabel("Test Label1", 5, 5, 90)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$label2 = GUICtrlCreateLabel("Test Label2", 5, 270, 90)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$ParentPosArr = WinGetPos($Gui)
WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1]+5)
WinSetTrans($ChildGui, '', 250)
GUISetBkColor ( 0xFF0000)
GUISetState(@SW_SHOW, $Gui)
GUISetState(@SW_HIDE, $ChildGui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            _show_child_window($button1)
        Case $button2
            _show_child_window($button2)
    EndSwitch
WEnd

Func _show_child_window($button_handle)
    $position = ControlGetPos($Gui, "", $button_handle)
    $position2 = WinGetPos($Gui, "")
    WinMove($ChildGui, "", $position2[0]+$position[0]+3, $position2[1]+$position[1]+$position[3]+28)
    GUISetState(@SW_SHOW, $ChildGui)
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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