Sign in to follow this  
Followers 0
penggilas2

Gui & Child

3 posts in this topic

It`s Possible to Run And Minimize Program in a Gui..?? Not in Taskbar WIndosws..?

Example In this Script..

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

$X = @DesktopWidth
$Y = @DesktopHeight
$hP = GUICreate("Parent", $X, $Y, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST),-1, WinGetHandle(AutoItWinGetTitle()))
GUISetBkColor(0)
GUISetState()


$ch = GUICreate("Child", $X, $Y -40, 0, $Y -40, BitOR($WS_MINIMIZEBOX, $WS_CHILD,$WS_BORDER),-1,$hP)
GUISetBkColor(0xA6CAF0)
$OptionsBtn = GUICtrlCreateButton("Start",0, 0, 40, 40)
    $OptionsDummy = GUICtrlCreateDummy()
    $OptionsContext = GUICtrlCreateContextMenu($OptionsDummy)
    $OptionsCommon = GUICtrlCreateMenuItem("Calculator", $OptionsContext)
    $OptionsFile = GUICtrlCreateMenuItem("Notepad", $OptionsContext)
    GUICtrlCreateMenuItem("", $OptionsContext)
    $OptionsExit = GUICtrlCreateMenuItem("Exit", $OptionsContext)
    GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $OptionsExit
            Exit
        Case $OptionsCommon
            Run("calc.exe")

        Case $OptionsFile
            Run("notepad.exe")

        Case $OptionsBtn
            ShowMenu($hP, $nmsg, $OptionsContext)

    EndSwitch
WEnd


; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)

    $arPos = ControlGetPos($hWnd, "", $CtrlID)

    $x = $arPos[0]
    $y = $arPos[1] + $arPos[0]

    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc   ;==>ShowMenu


; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")

    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))

    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local
    $stPoint = 0
EndFunc   ;==>ClientToScreen


; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc   ;==>TrackPopupMenu

How to Minimize Notepad And Calc. In Child Gui..?

Thank`s..

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

Ooo. Desktop shell replacement. Take a look at the vast amount of entries we had for a little bit of competitive fun a while back :)

Cheers,

Brett

:(

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  
Followers 0