Sign in to follow this  
Followers 0
JScript

_GUICreateEx - Width and Height relative to GUI

1 post in this topic

#1 ·  Posted (edited)

Hello guys ...

I noticed that a window created with AutoIt, the coordinates of width and height are relative to the client area rather than to the window itself!

Well, after some tests I got this simple code that causes the width and height are for the window and not to the client area.

I hope it's useful for someone else ...

Code:

Func _GUICreateEx($Title, $iWidth = 400, $iHeight = 400, $iLeft = -1, $iTop = -1, $iStyle = -1, $iexStyle = -1, $hParent = 0)
    If $iWidth > @DesktopWidth Then
        $iFrameY = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 33)
        $iFrameY = $iFrameY[0]
        $iWidth = @DesktopWidth - $iFrameY
    EndIf
    If $iHeight > @DesktopHeight Then $iHeight = @DesktopHeight

    Local $hWnd = GUICreate($Title, $iWidth, $iHeight, $iLeft, $iTop, $iStyle, $iexStyle, $hParent)
    WinMove($hWnd, "", Int((@DesktopWidth - $iWidth) / 2), Int((@DesktopHeight - $iHeight) / 2), $iWidth, $iHeight)

    Return $hWnd
EndFunc   ;==>_GUICreateEx
The syntax, of course, is the same as the native function!

So long,

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

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

  • Similar Content

    • Skysnake
      By Skysnake
      Hi
      Maybe I am just being silly, but I don't understand what is supposed to happen here.
      ::/html/functions/GUICreate.htm
      GuiCreate from the Help file has 2 examples.  Specifically, the 2nd example creates a ChildGui.  Or so it says.  I do not see this on screen.
      $hGUI gets created, no problem.
      Local $hChild = GUICreate("ChildGui", 10, 10, 20, 20, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI) What exactly does this line do? Should I see it on screen?
      Skysnake
    • Skysnake
      By Skysnake
      I think I am missing something obvious
      I want the "color bar" to stretch from side to side (entire width) of the GUI.  On resize it must expand / contract as necessary.  I guess the answer is easy, but I need a bit of help please?
      $hForm = GUICreate('myColor Picker', 300, 200,-1, -1, $WS_MAXIMIZEBOX + $WS_SYSMENU + $WS_CAPTION) ;color the GUI background ;GUISetBkColor($sColorformFile, $hForm) ; set the gui background color ;Local $mycolorLabel = GUICtrlCreateLabel("",10,10,300,10) ; a blank LABEL color bar Local $mycolorLabel = GUICtrlCreateGraphic( -1,-1,300,10) ; a blank GRAPHIC color bar GUICtrlSetResizing($mycolorLabel, $ws_sizebox);$GUI_DOCKMENUBAR);$GUI_DOCKAUTO) ;$GUI_DOCKBORDERS) GUICtrlSetBkColor($mycolorLabel,$sColorformFile) ; set the color for the label  
      This is an extract from here, by @Yashied
      $hForm = GUICreate('myColor Picker', 300, 200,-1, -1, $WS_MAXIMIZEBOX + $WS_SYSMENU + $WS_CAPTION) ;color the GUI background ;GUISetBkColor($sColorformFile, $hForm) ; set the gui background color ;Local $mycolorLabel = GUICtrlCreateLabel("",10,10,300,10) ; a blank LABEL color bar Local $mycolorLabel = GUICtrlCreateGraphic( -1,-1,300,10) ; a blank GRAPHIC color bar GUICtrlSetResizing($mycolorLabel, $ws_sizebox);$GUI_DOCKMENUBAR);$GUI_DOCKAUTO) ;$GUI_DOCKBORDERS) GUICtrlSetBkColor($mycolorLabel,$sColorformFile) ; set the color for the label Specifically my issue is with that $mycolorLabel
      Thanks, Skysnake
       
    • KimberlyJillPereira
      By KimberlyJillPereira
      I am a newbie in AutoIt. May I know what is the code used to expand the width and height of excel cells because I want to insert pictures in the cell.I tried AutoFit but that doesnt work as I cant specify for the width and height. Only for column width I could expand by using .ColumnWidth but for the row I am not able to expand the row? How to do?? What is the code used ??Please help me and thank you.
    • KimberlyJillPereira
      By KimberlyJillPereira
      I am a newbie in AutoIt. May I know what is the code used to expand the width and height of excel cells because I want to insert pictures in the cell.I tried AutoFit but that doesnt work as I cant specify for the width and height. Only for column width I could expand by using .ColumnWidth but for the row I am not able to expand the row? How to do?? What is the code used ??Please help me and thank you.
    • Jewtus
      By Jewtus
      I am using the following code to create a Gui and a progress bar that I can minimize:
      Global $Home = GUICreate("Intake", 1366,768, 192, 114, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX)) ProgressOn("Processing...", "Backing up", "Please wait...", 0, 0, $DLG_MOVEABLE + $DLG_NOTONTOP)  
      This works, but the part that I'm trying to fix is that there is a GUI where you press the button to kick off the progress and I'm wondering if there is a way to nest the progress bar into that gui so its movable, but when I minimize the GUI, the progress window also minimized (same for if its clicked... pull both the GUI and progress window up together). Right now, I get the Gui window and no Progress window on the task bar, but when I alt+Tab i can see both. This makes it so sometimes the progress bar is pushed to the background and the GUI sits on top preventing you from seeing the progress window.
       
      Any easy way of doing this?