The MASM Forum

General => The Campus => Topic started by: Raistlin on December 29, 2017, 07:39:21 PM

Title: Dialog Coords convert for Bitblt
Post by: Raistlin on December 29, 2017, 07:39:21 PM
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
Title: Re: Dialog Coords convert for Bitblt
Post by: jj2007 on December 29, 2017, 07:57:09 PM
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.
Title: Re: Dialog Coords convert for Bitblt
Post by: Raistlin on December 29, 2017, 08:11:19 PM
Thanks JJ2007 - works like a charm !  :t