954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Find the dimensions of a button

How do i find the dimensions of a button?
Example:
I want to find the width of the start button, and the height and then
assign them to seperate ints.

int width=WindowWidth(Start);
int height=WindowHeight(Start);

The abbove functions are totally made up, so they are just
examples...

Brent.tc
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 10
Solved Threads: 1
 

You mean the start button on the windows menu?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Yes, that is what I mean, but sadly the dimensions change with the resolution, so I can't have just one good dimension.

Brent.tc
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 10
Solved Threads: 1
 

GetClientRect() returns a RECT object with the coordinated, then simple subtraction will give you height and width.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I am totally clueless here, so how do i put the x value (width) into x and y value (height) into y
(where x and y are int datatypes)

Brent.tc
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 10
Solved Threads: 1
 
I am totally clueless here, so how do i put the x value (width) into x and y value (height) into y (where x and y are int datatypes)

did you read the link? First create a RECT object and pass a pointer to it to the GetClientRect() function. After that just assign x and y with simple subtraction of the RECT left, right, top and bottom integers. If you can't figure that much out then I doubt your ability to write a program that uses win32 api functions at all. Start with something a lot simpler.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
If you can't figure that much out then I doubt your ability to write a program that uses win32 api functions at all. Start with something a lot simpler.



And your right in doing so, but you must understand that daniweb is the only good tutorial I have ever found, and it's not even a tutorial... So if you could give me a link to a godd (Prefferably downloadable) Windows API tutorial and/or helpfiles. I would be quite grateful!

(Next year I'll be taking Visual Basic, and C++, so hopefully haveing some actual classes will help. (If they don't then, well... maybe there is something wrong with me:cheesy:

Brent.tc
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 10
Solved Threads: 1
 

please read through the Read Me posts at the top of this board -- they contain a wealth of information.

Here is a link to good win32 api tutorial

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks for all the help, not to complain, but some of you are very bad at answering a question.
I must also take part of the blame, as I am not to good at stating what I mean.
To clarify, I wanted to know how the structure RECT worked (as in what were the parts of it)

I found this out by looking at some source code.

Ancient Dragon - That tutorial you showed me is quite a help.

Brent.tc
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 10
Solved Threads: 1
 

There is no one tutorial for all win32 api functions because there are hundreds, if not thousands, of them. Tutorials are ok for very beginners, but you will quickly out-grow them and will need to invest in a few good (but expensive) books.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You