News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Dialog Coords convert for Bitblt

Started by Raistlin, December 29, 2017, 07:39:21 PM

Previous topic - Next topic

Raistlin

Hi all,

So normally all the examples around do this in WM_PAINT :
invoke BitBlt, hdc, 0, 0, rect.right, rect.bottom, hMemDC, 0, 0, SRCCOPY

But what if we did'nt want to paint at top-left coord 0,0 inside our window client area?

Say we had a dialog window at 540x180 (so dialog coord 0,0 // 539,179) in size and
wanted to paint at dialog coord 220,90 (x,y) - for an arbitrarily placed dialog window (ex.center screen, top left, normal)
Obviously just substituting these values in BitBlt wont work correctly, as they need to be pixel coords.

Any idea what the convoluted formula for these conversions would be ?

Thanks
R
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

jj2007

Your questions is not entirely clear to me, but maybe GetDialogBaseUnits and this one are of interest:The MapDialogRect function converts (maps) the specified dialog box units to screen units (pixels). The function replaces the coordinates in the
specified RECT structure with the converted coordinates, which allows the structure to be used to create a
dialog box or position a control within a dialog box.

BOOL MapDialogRect(

    HWND hDlg, // handle of dialog box
    LPRECT lpRect // address of structure with rectangle
   );


Parameters

hDlg

Identifies a dialog box. This function accepts only handles for dialog boxes created by one of the dialog box creation functions;
handles for other windows are not valid.

lpRect

Points to a RECT structure that contains the dialog box coordinates to be converted.

Return Values

If the function succeeds, the return value is nonzero.

Raistlin

Thanks JJ2007 - works like a charm !  :t
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...