Sign in to follow this  
Followers 0
Nova

Gui relative positioning of images

7 posts in this topic

#1 ·  Posted (edited)

Ok so ive been writing my first GUI with autoit over the last 2 days and ive hit a small problem.

Heres a simple example of my problem.

Imagine that you have 2 pictures the first picture is a stick mans head and the second is his body. :)

GUICreate ( "Head" ,250 ,300 ,-1 ,-1 ,$WS_POPUP ,-1 ,-1)
$Head=GUICtrlCreatePic("C:\Pictures\Head.bmp",-1,-1, 250,300)
GUISetState (@SW_SHOW)

GUICreate ( "Body" ,123 ,53 ,-1,291 ,$WS_POPUP ,-1 ,-1)
$Body=GUICtrlCreatePic("C:\Pictures\Body.bmp", -1, -1,125 ,55)
GUISetState (@SW_SHOW)

Ok the above code will align the 2 images with the head sitting on the body.

But if you change your screen reslution the head moves away from the body.

This is obviously because the x y coordinates for the picture of the head are relative to your screen and not to the picture of the body.

So finally down to the question how do I align 1 picture to another using the GUI ? :)

Edited by nova

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

GUICtrlSetResizing

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

My gui isnt resizable !

I ment that I have image 1 set to default position perfectly centered on screen x cord = -1 and y cord = -1

the second image at the moment is set to default x cord = -1 but the y cord = 200

Lets say my screen res is 1600x1200

Then my 2nd pic is centered on the x axis and is 200units down the Y axis relative to the top of my screen.

So when the screen res is changed to 800x600 the first pic is still centered on screen with its default values

But the 2nd pic although its still 200units down the Y axis relative to the top of my screen the y axis is now only half the size it use to be (because the screen res has been halfed) so now pic 2 is overlapping pic 1.

Thats my problem :)

Edited by nova

Share this post


Link to post
Share on other sites

There is no automatic solution to your problem. You have to compute pos/size according the gui size you are choosing. I cannot think of a coordinate system which will do that for you. :)

Share this post


Link to post
Share on other sites

I know it isn't an answer, but if you are making a hangman, why not make one pic with the whole body, and then save, remove a part, save, remove more, save, etc. Keep them all the same size, and just change the pic each time a wrong answer is done?


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

To center a window on the screen you would use the following calculation:

$winWidth = 300
$winHeight = 200

$xPos = (@DesktopWidth - $winWidth) / 2
$yPos = (@DesktopHeight - $winHeight) / 2

SplashTextOn("Example", "", $winWidth, $winHeight, $xPos, $yPos)
sleep(2000)

Hope that helps you get started....


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

To center a window on the screen you would use the following calculation:

$winWidth = 300
$winHeight = 200

$xPos = (@DesktopWidth - $winWidth) / 2
$yPos = (@DesktopHeight - $winHeight) / 2

SplashTextOn("Example", "", $winWidth, $winHeight, $xPos, $yPos)
sleep(2000)

Hope that helps you get started....

<{POST_SNAPBACK}>

Beat me to what I was going to say :) Good job.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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