Jump to content

Child GUI inside Parent GUI


fi3ldy
 Share

Recommended Posts

Hi,

I'm attempting to get a Child GUI to sit inside the PARENT GUI and when the parent GUI is moved, the Child GUI to stay relative to this and move in position at the same time, so the windows are basically locked together. (i dont want the user to really experience the child gui is another window.)

The reason for this, is I have a transparent GUI .png so the PARENT GUI is transparent with no toolbar, however when embedding an IE object it doesn't work without making a child gui to create the ie object inside (it used to work fine until I've added the Icons.au3 to allow me to use a transparent .png as the gui background).

Heres my code:

#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Include <Icons.au3>
#Include <WinAPIEx.au3>
#NoTrayIcon

;;;;;;;;;;;;;;;;;PRE-SETTINGS;;;;;;;;;;;;;;;;;;;;;
Opt("OnExitFunc", "Quit")
Opt("GuiOnEventMode", 1)
Opt("GUICloseOnESC", 0)
Global $fileTitle = "Herb (v1.1 Beta)"

;;;;;;;;;;;;;LIMIT MULTIPLE WINDOWS;;;;;;;;;;;;;;;
If WinExists($fileTitle) Then
    Exit
EndIf

;;;;;;;;;;;;;;;;;;;;;;VARS;;;;;;;;;;;;;;;;;;;;;;;;
Global $exitItem, $trayIcon, $backGround, $mainGUI, $hBitmap, $object, $objectCtrl, $msg

;;;;;;;;;;;;;;INSTALL NEEDED FILES;;;;;;;;;;;;;;;
Global $trayIcon = @SystemDir & "\herbie.ico"
FileInstall("herbie.ico", @SystemDir, 1)
FileSetAttrib($trayIcon, "+H")

Global $backGround = @SystemDir & "\herbie_bg.png"
FileInstall("herbie_bg.png", $backGround, 1)
FileSetAttrib($backGround, "+H")

;;;;;;;;;;;;;;;;;;TRAY MENU;;;;;;;;;;;;;;;;;;;;;
Global $exitItem = TrayCreateItem("Exit")
TraySetIcon(@SystemDir & "\herbie.ico")
TraySetToolTip($fileTitle)
Opt("TrayMenuMode", 1)
opt("TrayIconHide", 0)
TraySetState()


;;;;;;;;;;;;;;;;;;CREATE MAIN GUI;;;;;;;;;;;;;;;;;;;
AutoItWinSetTitle($fileTitle)
$mainGUI = GUICreate($fileTitle, 282, 290, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), $WS_POPUP+$WS_CLIPCHILDREN+$WS_CLIPSIBLINGS, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$hBitmap = _Icons_Bitmap_Load(@ScriptDir & '\herbie_bg.png')
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
_SetBitmap($mainGUI, $hBitmap, 255)

GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

GUICtrlCreateLabel("Drag", 118, 0, 164, 160, '', $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)


GUISetState(@SW_SHOW, $mainGUI)


;;;;;;;;;;;;;;;;;;CREATE CHILD GUI;;;;;;;;;;;;;;;;;;
$childGUI = GUICreate("", 230, 120, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), $WS_EX_MDICHILD)

$object = _IECreateEmbedded()
$objectCtrl = GUICtrlCreateObj($object, 0, 0, 230, 120)
_IENavigate($object, "http://www.google.co.uk")
$object.document.body.scroll = "no"
$object.document.body.style.border = 0
GUISetState(@SW_SHOW, $childGUI)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
    $tmsg = TrayGetMsg()
    If $tmsg = $exitItem Then ExitLoop
Wend


;;;;;;;;;;;;;;;;;;FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;
Func Quit()
    Exit
EndFunc ;==>Quit

Func _SetBitmap($hWnd, $hBitmap, $iOpacity)
    Local $hDC, $hMemDC, $tBlend, $tSize, $tSource
    $hDC = _WinAPI_GetDC($hWnd)
    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = _WinAPI_GetBitmapDimension($hBitmap)
    $tSource = DllStructCreate($tagPOINT)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    DllStructSetData($tBlend, 'Alpha', $iOpacity)
    DllStructSetData($tBlend, 'Format', 1)
    _WinAPI_UpdateLayeredWindow($hWnd, $hDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_SetBitmap

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $mainGUI
            Return $HTCAPTION
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

I've attached the required image & icon so you can run the script to see for yourself!

I'm really pulling my hair out so a solution to this would be excellent.

Kind regards,

Danny

post-19272-12667976924707_thumb.png

herbie.ico

Edited by fi3ldy
Link to comment
Share on other sites

as per the helpfile

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

when you create your child gui,

where the , parent option is

you need to add the gui that the child would be attached to.

in your case $mainGUI

$childGUI = GUICreate("", 230, 120, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), $WS_EX_MDICHILD,-1,$mainGUI)

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Moderators

kaotkbliss,

You need to get the styles in the right order: :mellow:

$childGUI = GUICreate("", 230, 120, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), -1, $WS_EX_MDICHILD, $mainGUI)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

kaotkbliss,

You need to get the styles in the right order: :mellow:

$childGUI = GUICreate("", 230, 120, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), -1, $WS_EX_MDICHILD, $mainGUI)

M23

woops.

that would help

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

$childGUI = GUICreate("", 230, 120, ((@DesktopWidth-282)/2), ((@DesktopHeight-290)/2), -1, $WS_EX_MDICHILD, $mainGUI)

Sorted it 100% - thanks a lot for your help guys really appreciate it. I tried for hours, seems as though I was missing the $WS_EX_MDICHILD with linking to it's PARENT. I tried both individually numerous times :mellow:

Hehe, thanks again.

Quick question whilst im here, can't seem to find an documentation or results on removing the border from creating an IE embedded object?

Here's my object:

$object = _IECreateEmbedded()
$objectCtrl = GUICtrlCreateObj($object, 0, 0, 266, 115)
_IENavigate($object, "http://www.google.co.uk")
$object.document.body.scroll = "no"
$object.document.body.style.border = 0

Kind regards,

Danny

Edited by fi3ldy
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...