Jump to content
Sign in to follow this  
monitorlg

Attaching a form to parent form.

Recommended Posts

monitorlg

Hi All,

I have a Main form. Where i have 3 tabs.

When i click one tab an another form should get opened...

I am Using GUISwitch(...)but this command doesnt give me the privilege to embeed other form.

I am not able to embeed the form...

I am attaching the code please help me.....

Thanks in Advance....

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

#Region ### START Koda GUI section ### Form=e:\documents and settings\srikrishna.lge\desktop\main.kxf
$Form1_1 = GUICreate("Form1", 1067, 887, 312, 94)
$TabOrder = GUICtrlCreateTab(18, 8, 1033, 864)
GUICtrlSetFont(-1, 9, 800, 0, "Trebuchet MS")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$Welcome = GUICtrlCreateTabItem("Welcome")
;~ $LG = GUICtrlCreatePic("E:\Documents and Settings\srikrishna.lge\My Documents\lg-logo.jpg", 376, 108, 340, 308, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Welcome to LG Inventory Management System", 233, 480, 725, 44)
GUICtrlSetFont(-1, 24, 800, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0xA0A0A4)

$InventoryUpdate = GUICtrlCreateTabItem("Inventory Update")
$InventoryManage = GUICtrlCreateTabItem("Inventory Manage")

GUISwitch($Form1_1,$InventoryUpdate)
GUICtrlCreateTabItem("")

GUISwitch($Form1_1,$InventoryUpdate)
GUICreate("Form1", 600, 600, 100, 20)
    
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $TabOrder
EndSwitch
WEnd
Edited by monitorlg

Share this post


Link to post
Share on other sites
martin

Hi All,

I have a Main form. Where i have 3 tabs.

When i click one tab an another form should get opened...

I am Using GUISwitch(...)but this command doesnt give me the privilege to embeed other form.

I am not able to embeed the form...

I am attaching the code please help me.....

Thanks in Advance....

#include <GUIConstantsEx.au3>
 #include <StaticConstants.au3>
 #include <TabConstants.au3>
 #include <WindowsConstants.au3>
 
 #Region ### START Koda GUI section ### Form=e:\documents and settings\srikrishna.lge\desktop\main.kxf
 $Form1_1 = GUICreate("Form1", 1067, 887, 312, 94)
 $TabOrder = GUICtrlCreateTab(18, 8, 1033, 864)
 GUICtrlSetFont(-1, 9, 800, 0, "Trebuchet MS")
 GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
 $Welcome = GUICtrlCreateTabItem("Welcome")
;~ $LG = GUICtrlCreatePic("E:\Documents and Settings\srikrishna.lge\My Documents\lg-logo.jpg", 376, 108, 340, 308, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
 $Label1 = GUICtrlCreateLabel("Welcome to LG Inventory Management System", 233, 480, 725, 44)
 GUICtrlSetFont(-1, 24, 800, 0, "Trebuchet MS")
 GUICtrlSetBkColor(-1, 0xA0A0A4)
 
 $InventoryUpdate = GUICtrlCreateTabItem("Inventory Update")
 $InventoryManage = GUICtrlCreateTabItem("Inventory Manage")
 
 GUISwitch($Form1_1,$InventoryUpdate)
 GUICtrlCreateTabItem("")
 
 GUISwitch($Form1_1,$InventoryUpdate)
 GUICreate("Form1", 600, 600, 100, 20)
     
 GUISetState(@SW_SHOW)
 #EndRegion ### END Koda GUI section ###
 
 While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
 Case $GUI_EVENT_CLOSE
 Exit
 
 Case $TabOrder
 EndSwitch
 WEnd
If you want to embed the$Form1_1 in $Form1 then you don't need GuiSwitch. Replace that with GuiSetState() so you can see the form, then look up GuiCreate and note the parent parameter. That will let you set $Form1_1 inside $form1. Create $Form1 first then $Form1_1 using the parent parametr. Note that the coordinates for the position of the child window are relative to the top left of the client area of the parent.

Also, search for "SetParent" which allows you to set an already existing window into another.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
monitorlg

If you want to embed the$Form1_1 in $Form1 then you don't need GuiSwitch. Replace that with GuiSetState() so you can see the form, then look up GuiCreate and note the parent parameter. That will let you set $Form1_1 inside $form1. Create $Form1 first then $Form1_1 using the parent parametr. Note that the coordinates for the position of the child window are relative to the top left of the client area of the parent.

Also, search for "SetParent" which allows you to set an already existing window into another.

@Martin..

hey Its working but the desired result is that form 2 should be embeeded into form 1,

That is when i move form1, form 2 should also move...

I am posting my code.....

Please help me...

Thanks in advance..

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;--------Form2------------
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 298, 323, 207, "", $WS_EX_MDICHILD, $Form1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;----------End Form 2------------------

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
martin

@Martin..

hey Its working but the desired result is that form 2 should be embeeded into form 1,

That is when i move form1, form 2 should also move...

I am posting my code.....

Please help me...

Thanks in advance..

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 
 #Region ### START Koda GUI section ### Form=
 $Form1 = GUICreate("Form1", 633, 447, 193, 125)
 GUISetState(@SW_SHOW)
 #EndRegion ### END Koda GUI section ###
 
;--------Form2------------
 #Region ### START Koda GUI section ### Form=
 $Form2 = GUICreate("Form2", 413, 298, 323, 207, "", $WS_EX_MDICHILD, $Form1)
 GUISetState(@SW_SHOW)
 #EndRegion ### END Koda GUI section ###
 
;----------End Form 2------------------
 
 While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
 
     EndSwitch
 WEnd
Maybe this does what youi want.

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;--------Form2------------
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 298, 100, 100,BitOr($WS_BORDER,$WS_CHILD,$WS_CAPTION,$WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX ), -1, $Form1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;----------End Form 2------------------

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Here is another way

#include <WindowsConstants.au3>

$hGui1 = GUICreate('Parent Gui', 1100,800,200,200,BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN))
GUISetState()


$Form2 = GUICreate("Form2", 413, 298, 100, 100,BitOr($WS_BORDER,$WS_CAPTION,$WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX ))

$origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $Form2, "hwnd",$hGui1);
GUISetState(@SW_SHOW)
GUISwitch($hGui1)
While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then
       
        Exit
    EndIf
    
WEnd

Unfortunately I don't understand why the 2 methods give different, and unwanted, results.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
Sign in to follow this  

×