Activex resizing ?

L

lionel letoffet

Hello,

I wrote an ActiveX in MFC. I use it in a C# application (forms).

My computer has a screen resolution of 1280x1024 with 96PPP (Important !!)

I insert my activex in a form, I compile and run all is ok !!

But now I want to use my application in an other computer with screen
resolution of 1280x1024 but with 120 PPP.

The size of my activeX is not correct !! External size is biggest than what
I design!

I suppose it's a problem of physical and logical size, but i d'ont know how
to be independant of the ppp value.

I want to design my form on any computer and obtain the same look on an
other, I suppose it's not a dream ?

Can you help me please ?
 
N

Nathan Neitzke

Mr. Letoffet,
I am curious as to why you have your other computer at 120 dpi? As far as I
have tested, 120 dpi makes lots of Windows apps look bad :)

But to get to your question, yes the size is not going to be correct. The
only way I can suggest for you to fix this is to modify the drawing code
within your ActiveX object so that it detects the DPI of a system and
adjusts accordingly.

This should be easy to do in GDI if I am not mistaken (if that is what you
are using).

I am going to point you to the following article. Let me know if it helps!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/highdpiapp.asp

Take care.
 
L

lionel letoffet

Thank you for your article, it helps me a lot !

I used ColeControl::GetRectInContainer(&rc) and
ColeControl::SetRectInContainer(&rc) to scale my ActiveX.

To calculate the scale factor I save, in a hidden propertie, the dpi value
at design and compute it with the current runtime value.

My current problem is that in the OnCreate function GetRectInContainer and
SetRectInContainer are not correct. So I put the scale correction in
OnDraw with a boolean to do it just one time. But I think it's not a good
place to do this. May be you know a function or a message between
WM_CREATE and WM_PAINT?

A funny effect is if my design dpi is lower than runtime dpi (96 and 120 for
example), I need to do the correction.
But if it is higgest no !
An ActiveX designed and sized at 120 dpi looks good at 96. I can't explain
it yet, and you?

For your question: Why I want to use 120 dpi? I just could say: because...

I don't know settings of the user of my application, but I know that my
application must look good on its computer ! That's all.

In your article the author says tomorrow ;-) the screen will be in 200 dpi,
I have no time to design everyday my software.

An other tips: if you want to do this in C# and forms don't forget to set
the AutoScale propertie of your form to false!

Thank you very much for your help!

Bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top