• Welcome to Jose's Read Only Forum 2023.
 

How To Handle High DPI Awareness With COM ActiveX Dll

Started by Frederick J. Harris, January 05, 2015, 07:30:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frederick J. Harris

Hi Jose!

     I'm attempting to make my COM based grid control High DPI Aware.  And I'm wondering how to do that.  What I've done in the host/client app that will be using the grid control is to set the app High DPI Aware through the manifest technique.  Will that be sufficient with regard to the COM Dll?  In the WM_CREATE handler code of the client app I execute the required code to get my scaling ratios for use there.  The way I see it, in the Dll I simply need to do the same thing in terms of geting the scaling ratios for use in building the grid.  Of course there are GUI elements that need to be sized and scaled there too.  But do I need to also include a manifest for the dll (I've never done that), or call SetProcessDPIAware() there?  I seem to recall that business about creating a race condition so on and so forth.  But as I've said, it works in the client/host to set the process Hight DPI Aware with a manifest, and that's what I'm doing.

So the way I see it - and please correct me if I'm wrong, all I need to do in the Dll is get my scaling ratios the same way I do in the client, which is already set to High DPI Aware.  I'm assuming all this simply because if a client process is High DPI Aware, then any Dlls loaded into it must also inherit that state???

José Roca

#1
IMO, the controls should be agnostic. It is the main application who must decide the use of High DPI, visual styles, etc., and resize the control and choose the fonts to be used.

What if a programmer makes his application High DPI aware but does not want to scale it? If the main application does not scale and your control scales, the result will be... funny?


Frederick J. Harris

OK, thanks!  I'll see how it goes!  And I do hope it goes well.  This code is important to me.   :)

José Roca

Or if you want to do the resizing in the control, then do it only if the user tells it to do it and using the ratios passed by the user.

Frederick J. Harris

#4
Not completely done yet, but so far so good.  What its beginning to look like is that I don't have much to do in the grid itself, as most of the dimensions are scaled first in the client/host before being passed from the client to the grid.  The only thing that isn't are the grid column widths, which are passed in through my funky string setup, which kind of looks like so...

"Col1:150, Col2:200, Col3:525..........."

and that gets parsed apart in the grid code.  So i'll need to size them (the column widths) with a scaling factor. 

The only mysterious thing I've encountered though is that in the client and in the dll, when I call IsProcessDPIAware(), I'm getting a TRUE return even when neither my client nor my dll are calling SetProcessDPIAware(), and there aren't any manifests either where I'm setting this.  Above I stated I was using a manifest to set this, but in the test code I'm working with now before moving to my main app, there isn't any manifest. 

Also, at the moment I'm working with my C++ version of the grid control and doing C++ code.  Also 64 bit.  I don't know if that has anything to do with it, like possibly all 64 bit compiles end up being high DPI aware.  I need to look into this further.