I have an ActiveX control which I need to render to a report. The control has a method which accepts a device context handle. So I think I can do this using the PRP_GetDC() function of PSHR170.DLL, something like this;
long ll_printjob
ulong lul_hdc
ll_printjob = PrintOpen( "Print Test" )
lul_hdc = PRP_GetDC( ll_printjob )
ole_map.OutputMap( lul_hdc, ... )
PrintClose( ll_printjob )
However when I test this, the print-page is rendered blank.
My declaration of PRP_GetDC() is this;
FUNCTION ulong PRP_GetDC (long printjob) library "PBSHR170.dll"
I have attempted to render a bitmap using StretchBlt() to the print page based on code that I know works, and that also seems to be rendered blank. So at this point I suspect that my hDC value is not valid, or the way I am using it is not valid. However the value is non-zero, and reasonable values seem to be returned by from calls to get attributes of the hDC using GetDeviceCaps() e.g.
constant long LOGPIXELSX = 88
long LOGPIXELSY = 90
GetDeviceCaps( lul_hdc ,LOGPIXELSX)
Does anyone have any pointers on getting this working?
(I am using Powerbuilder 2017R3)
The cause of the issue I experienced is that PB printing uses Windows GDI map-mode MM_HIENGLISH ("Each logical unit is mapped to 0.001 inch. Positive x is to the right; positive y is up.").
To resolved this I used the SetMapMode() GDI function to set the map-mode of my drawing-context (hdc) to the default map mode of MM_TEXT ( "Each logical unit is mapped to one device pixel. Positive x is to the right; positive y is down." ).
I could then call the method of my ActiveX control to render using the map mode it was expecting.
This allowed me to mix PB PrintText(), PrintLine() etc. statements on the same print page as my ActiveX control drew to.