MapDisplayDC

#include "BIDISP.H"

 

void CALLBACK MapDisplayDC( HDC      hDC,
LPDISPLAYSTRUCT  cb)

Description

Prepare Window DC to identify Bitmap pixels in the window.

Parameters

HDC

hDC

Identifies the handle of a device context.

LPDISPLAYSTRUCT

cb

Display information structure.

Return values

None.

Programming notes

The scroll position in the scroll range is stored in the DISPLAYSTRUCT

The Mapped DC logical coordinates are bitmap pixels

Device coordinates in device (display) pixels

Convert Bitmap coordinates to screen coordinates

LPtoDP()  Windows API function  

Convert Device coordinates to Bitmap coordinates

DPtoLP  Windows API function

Requirements

Header :     Declared in BIDisp.h; include BIDisp.h.

Library :    Use BIDisp.lib.

DLLs :       BIDisp.dll.

Code example

Example code to convert mouse pointer to bitmap pixel

POINT ptStartScroll , ptStartMouse;

BOOL bDown;

 

LRESULT WndProc(HWND hWNd,UINT iMessage,WPARAM    wParam,LPARAM lParam)

{

   switch (iMessage)

   {

   case WM_MOUSEMOVE:

      POINT ptWindow;

      POINT ptBitmap;

      HDC    hDC;

 

      hDC = GetDC(hWnd);

      MapDisplayDC(hDC,&sDisplay);

      ptWindow = (POINT) lParam;

 

       ptBitmap = ptWindow;

       // Convert Window coordinate to Bitmap coordinate

       DPtoLP(hDC,&ptBitmap,1);

       ReleaseDC(hWnd,hDC);

     break;

   }

}