Author Topic: Dialog Coords convert for Bitblt  (Read 215 times)


  • Member
  • ***
  • Posts: 300
Dialog Coords convert for Bitblt
« 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 ( 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 ?



  • Member
  • *****
  • Posts: 8226
  • Assembler is fun ;-)
    • MasmBasic
Re: Dialog Coords convert for Bitblt
« Reply #1 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:
Code: [Select]
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



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.


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.


  • Member
  • ***
  • Posts: 300
Re: Dialog Coords convert for Bitblt
« Reply #2 on: December 29, 2017, 08:11:19 PM »
Thanks JJ2007 - works like a charm !  :t