Jump to content

  • Log In with Google      Sign In   
  • Create Account

How do I calculate width&height with dpi in win32


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1   Members   -  Reputation: 917

Like
0Likes
Like

Posted 27 February 2014 - 02:55 PM

So I want to create a tab control in a window,but the CreateWindow function in win32 expect me to send the width&height in device coords...

I know the screen coords size(480x800),but I have no ideea how to convert that.

 

I tried with: LPtoDP() but after the call it doesn't change the point structure so it still leaves me with (480x800)....

 



#2   Members   -  Reputation: 1358

Like
0Likes
Like

Posted 27 February 2014 - 04:14 PM

You can use

double ratio = GetDeviceCaps(myhdc, LOGPIXELSX) / 96.0;

And then multiply your pixel values with that.

#3   Members   -  Reputation: 917

Like
0Likes
Like

Posted 27 February 2014 - 06:26 PM

i get ratio = 1??



#4   Members   -  Reputation: 1358

Like
0Likes
Like

Posted 27 February 2014 - 06:31 PM

Then perhaps you need to tell Windows that your application is DPI
aware, you can do that either via a manifest or by simply calling SetProcessDPIAware.

#5   Members   -  Reputation: 917

Like
0Likes
Like

Posted 27 February 2014 - 06:58 PM

that worked






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS