Jump to content

GuiCreate & WinGetPos


Recommended Posts

There is script:

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

; Gui variables
Global $hWndValid, $hWndInValid
Global $WinW = 500, $WinH = 400
Global $Title = "Test of GUICreate"

; Create GUI window
$hWndValid = GUICreate($Title, $WinW, $WinH, 0, 0, $WS_OVERLAPPEDWINDOW)

;get GUI sizes
$Pos = WinGetPos($Title, "")
$Label0 = GuiCtrlCreateLabel(" Gui was created by GuiCreate:", 80, 20, $WinW - 80, 20)
$Label1 = GuiCtrlCreateLabel(" $WinW = " & $WinW & " $WinH = " & $WinH, 80, 50, $WinW - 80, 20)
$Label2 = GuiCtrlCreateLabel(" However it returns by WinGetPos", 80, 80, $WinW - 80, 20)
$Label3 = GuiCtrlCreateLabel(" $Pos[2] = " & $Pos[2] & " $Pos[3] = " & $Pos[3], 80, 110, $WinW - 80, 20)
;resize GUI
WinMove ($Title, "", 0, 0, $WinW, $WinH)

;get GUI sizes once more
$Pos = WinGetPos($Title, "")
$Label0 = GuiCtrlCreateLabel(" Now Gui was resized by WinMove:", 80, 150, $WinW - 80, 20)
$Label1 = GuiCtrlCreateLabel(" $WinW = " & $WinW & " $WinH = " & $WinH, 80, 180, $WinW - 80, 20)
$Label2 = GuiCtrlCreateLabel(" and it returns  by WinGetPos", 80, 210, $WinW - 80, 20)
$Label3 = GuiCtrlCreateLabel(" $Pos[2] = " & $Pos[2] & " $Pos[3] = " & $Pos[3], 80, 240, $WinW - 80, 20)
GUISetState()

GUISetState()
While 1
  $Msg = GUIGetMsg(1)
  Switch $Msg[0]
   Case $GUI_EVENT_CLOSE
    Exit
   Case else
  EndSwitch
WEnd

The size of GUI moved is different than after GuiCreate. Why?

This is GUI shot.

post-9395-0-37910700-1313659221_thumb.gi

The point of world view

Link to comment
Share on other sites

  • Moderators

ValeryVal,

GUICreate sets the size of the client area of the GUI - the useful area less the borders and title bar. The Win* functions affect the whole GUI not just the client area. :)

Here is your script slightly modified to explain what is happening - look in the SciTE console for the data: :mellow:

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

; Gui variables
Global $hWndValid, $hWndInValid
Global $WinW = 500, $WinH = 400
Global $Title = "Test of GUICreate"

; Create GUI window
$hWndValid = GUICreate($Title, $WinW, $WinH)

;get GUI sizes
$Pos = WinGetPos($Title, "")
$Client = WinGetClientSize($Title, "")
ConsoleWrite("Gui was created by GuiCreate:" & @CRLF & _
        "$WinW = " & $WinW & " $WinH = " & $WinH & @CRLF & _
        "However it returns by WinGetPos:" & @CRLF & _
        "$Pos[2] = " & $Pos[2] & " $Pos[3] = " & $Pos[3] & @CRLF & _
        "But the client size is still:" & @CRLF & _
        "$Client[1] = " & $Client[0] & " $Client[1] = " & $Client[1] & @CRLF & @CRLF)

;resize GUI
WinMove($Title, "", 0, 0, $WinW, $WinH)

;get GUI sizes once more
$Pos = WinGetPos($Title, "")
$Client = WinGetClientSize($Title, "")
ConsoleWrite("Now Gui was resized by WinMove:" & @CRLF & _
        "$WinW = " & $WinW & " $WinH = " & $WinH & @CRLF & _
        "And it returns by WinGetPos:" & @CRLF & _
        "$Pos[2] = " & $Pos[2] & " $Pos[3] = " & $Pos[3] & @CRLF & _
        "But the client size is now only:" & @CRLF & _
        "$Client[1] = " & $Client[0] & " $Client[1] = " & $Client[1] & @CRLF & @CRLF)

GUISetState()
While 1
    $Msg = GUIGetMsg(1)
    Switch $Msg[0]
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
    EndSwitch
WEnd

All clear? :)

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

All clear?

Yes. It's clear.

:mellow:

It's dark with AutoIt Help having the following (GuiCreate description):

width [optional] The width of the window.

height [optional] The height of the window.

Thank you for respond

The point of world view

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...