Jump to content

Unit of Measure for Forms/Controls (Move Forms Around)


zbatev
 Share

Recommended Posts

Hi,

I want to move my forms around. so I'm using WinMove to achieve that, my problem is that I believe the units return by the WinGetPos(pixel) is different from the units used by forms, i'm not sure thought but does it use twips?

Is there a way to convert the form's/control's size to pixels?

This is what I'm trying to accomplish I want both forms to end up in-lined at the bottom. but my code doesn't do that.

***Please don't mind the GUI management, I'm just trying to show what I want to accomplish, this is not the actual code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
Global $Form2
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 307, 511)
$Label1 = GUICtrlCreateLabel("Move this window around and click the button below", 10, 10, 253, 17)
$Button1 = GUICtrlCreateButton("Move the other window beside me aligned at the bottom", 10, 40, 280, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_SideBySideBottom()
While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
        Case $Form1
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $Button1
                    GUIDelete($Form2)
                    _SideBySideBottom()
            EndSwitch

        Case $Form2
            Switch $nMsg[0]

                Case $GUI_EVENT_CLOSE

            EndSwitch

    EndSwitch
WEnd


Func _SideBySideBottom()
    $Form2 = GUICreate("", 488, 306)
    GUISetBkColor(0xFFFFFF)
    $editor = GUICtrlCreateEdit("", 8, 8, 465, 289, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    $frm1pos = WinGetPos($Form1)
    $frm2pos = WinGetPos($Form2)
    WinMove($Form2,"", $frm1pos[0] - $frm2pos[2], $frm1pos[3] - $frm2pos[3] )

EndFunc
Edited by zbatev
Link to comment
Share on other sites

It's all pixels, you are just doing the math wrong. Not sure what you want, maybe this?

WinMove($Form2,"", $frm1pos[0] - $frm2pos[2], $frm1pos[1] + $frm1pos[3] - $frm2pos[3])
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...