Jump to content

setting the client coords of a window..


CodyBarrett
 Share

Recommended Posts

im wondering if its possible to set the client rgn of a window so that it automatically creates a ctrl on 0,0 but not overlapping the transparent but on the colored section instead.

#include <WindowsConstants.au3>
#include <Misc.au3>
#include <string.au3>
#include <array.au3>
#include <winapi.au3>
Opt ('GUIOnEventMode',1)
$gui_w = Int (@DesktopWidth/3)
$gui_h = Int (@DesktopHeight/3)
CreateBase (@ScriptName)
While 1
    Sleep (100)
WEnd
Func _NewWindow ()
    CreateBase (@GUI_WinHandle)
EndFunc
Func CreateBase ($title)
    Local $hwnd, $WIDTH,$HEIGHT, $offset
    $offset = 5
    $hwnd = GUICreate ($title,$gui_w,$gui_h,-1,-1,$WS_POPUPWINDOW,BitOR ($WS_EX_LAYERED,$WS_EX_DLGMODALFRAME))
        GUISetFont (10,10,'','Tahoma')
        GUISetBkColor(0xABCDEF)
        _WinAPI_SetLayeredWindowAttributes ($hwnd,0xABCDEF)
        $WIDTH = _WinAPI_GetClientWidth ($hwnd)
        $HEIGHT = _WinAPI_GetClientHeight ($hwnd)
        GUISetOnEvent (-3,'_WinClose')
        GUISetState ()
            GUICtrlCreateLabel (WinGetTitle ($hwnd),0,0,$WIDTH-20,20,BitOR (0x01,0x0200),0x00100000)
            GUICtrlCreateLabel ('',0,20,$WIDTH,20,-1,0x00100000) ;top
                GUICtrlCreateLabel ('',0,40,$offset,$HEIGHT-(40+$offset),-1,0x00100000) ;left
                GUICtrlCreateLabel ('',0,$HEIGHT-$offset,$WIDTH,$offset,-1,0x00100000) ;bottom
                GUICtrlCreateLabel ('',$WIDTH-$offset,40,$offset,$HEIGHT-(40+$offset),-1,0x00100000) ;right
            GUICtrlCreateLabel ('x',$WIDTH-20,0,20,20,BitOR (0x01,0x0200))
                GUICtrlSetCursor (-1,0)
                GUICtrlSetOnEvent (-1,'_WinClose')
            GUICtrlCreateLabel ('',$offset,40,$WIDTH-($offset*2),$HEIGHT-(40+$offset))
                GUICtrlSetBkColor (-1,0x000000)
                GUICtrlSetState (-1,128)
        GUICtrlCreateButton ('Click To Clone',60,100,100,20)
        GUICtrlSetOnEvent (-1,'_NewWindow')
EndFunc
Func _WinClose ()
    Exit
EndFunc
Link to comment
Share on other sites

Instead of creating a coloured label create a child window and set the colour of that. Then create your controls on the child window and 0,0 is the top left as you want.

#include <WindowsConstants.au3>
#include <Misc.au3>
#include <string.au3>
#include <array.au3>
#include <winapi.au3>
Opt ('GUIOnEventMode',1)
$gui_w = Int (@DesktopWidth/3)
$gui_h = Int (@DesktopHeight/3)
CreateBase (@ScriptName)
While 1
    Sleep (100)
WEnd
Func _NewWindow ()
    CreateBase (@GUI_WinHandle)
EndFunc
Func CreateBase ($title)
    Local $hwnd, $WIDTH,$HEIGHT, $offset
    $offset = 5
    $hwnd = GUICreate ($title,$gui_w,$gui_h,-1,-1,$WS_POPUPWINDOW,BitOR ($WS_EX_LAYERED,$WS_EX_DLGMODALFRAME))
    GUISetFont (10,10,'','Tahoma')
    GUISetBkColor(0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes ($hwnd,0xABCDEF)
    $WIDTH = _WinAPI_GetClientWidth ($hwnd)
    $HEIGHT = _WinAPI_GetClientHeight ($hwnd)
    GUISetOnEvent (-3,'_WinClose')
    GUISetState ()
    GUICtrlCreateLabel (WinGetTitle ($hwnd),0,0,$WIDTH-20,20,BitOR (0x01,0x0200),0x00100000)
    GUICtrlCreateLabel ('',0,20,$WIDTH,20,-1,0x00100000) ;top
    GUICtrlCreateLabel ('',0,40,$offset,$HEIGHT-(40+$offset),-1,0x00100000) ;left
    GUICtrlCreateLabel ('',0,$HEIGHT-$offset,$WIDTH,$offset,-1,0x00100000) ;bottom
    GUICtrlCreateLabel ('',$WIDTH-$offset,40,$offset,$HEIGHT-(40+$offset),-1,0x00100000) ;right
    GUICtrlCreateLabel ('x',$WIDTH-20,0,20,20,BitOR (0x01,0x0200))
    GUICtrlSetCursor (-1,0)
    GUICtrlSetOnEvent (-1,'_WinClose')
    ;GUICtrlCreateLabel ('',$offset,40,$WIDTH-($offset*2),$HEIGHT-(40+$offset))
    ;GUICtrlSetBkColor (-1,0x000000)
                guicreate("child1",$WIDTH-($offset*2),$HEIGHT-(40+$offset),$offset,40,$WS_CHILD,-1,$hwnd)
                GUISetBkColor(0)
                GUISetState()
    ;GUICtrlSetState (-1,128)
    GUICtrlCreateButton ('Click To Clone',0,0,100,20)
    GUICtrlSetOnEvent (-1,'_NewWindow')
EndFunc
Func _WinClose ()
    Exit
EndFunc
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.
Link to comment
Share on other sites

Well... the lag of MDIChild movements is really bad when its running on a slowish machine. i guess i'll have to make a child. but IS it possible? no matter how hard?

Link to comment
Share on other sites

Well... the lag of MDIChild movements is really bad when its running on a slowish machine. i guess i'll have to make a child. but IS it possible? no matter how hard?

Where does MidiChild come from?

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.
Link to comment
Share on other sites

don't you need to have $WS_EX_MDICHILD to have it movable with the parent?

edit: never mind, i see your example works without that style. thanks martin, i guess ill just make a child as it seems simpler.

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