Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 168

CreateEnhMetafile hDC DPI

$
0
0
I'm using the CreateEnhMetafile function, defined as follows:

Code:

Private Declare Function CreateEnhMetaFile Lib "gdi32.dll" Alias "CreateEnhMetaFileA" (ByVal hdcRef As Long, ByVal lpFileName As String, ByRef lpRect As RECT, ByVal lpDescription As String) As Long
For the hdcRef parameter, I can pass the Printer.Hdc and get a high-DPI (say, 300DPI) for my drawing operations. The result in my particular case is the EM_FORMATRANGE calls on a RichEdit handle produce "correct" kerning results in the resultant EMF.

However, if a user doesn't have a printer installed (admittedly rare, but occasionally the case) then I have to pass 0 for the hdcRef parameter, and this uses the display driver for the compatible DC. Typically this results in a DPI of 96 (depending of course on the display DPI settings), and the results of my EM_FORMATRANGE calls become poor (kerning goes off for certain character pairs in certain fonts, such as Arial 8pt, "fi" for example).

So my question is, is there any way to create a high DPI DC without having a printer driver installed, which I could then pass to the hdcRef parameter of the CreateEnhMetafile function? I've done a bit of searching, but my Google-fu is failing me on this one (I suspect "DPI" is the wrong term when dealing with DCs, and most of the results are populated with things about changing the Printer DPI which is not what I need to do).

Thanks in advance for any advice.

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>