有2个问题我找了好久没例子;1) 比方说我在一个对话框上显示一串文字(dc.DrawText)。怎么得到字体的坐标范围(矩形范围)?2)我想在OnMouseMove里,当鼠标移动在一个按扭范围或得到的字体的范围上时,才响应一些事情!

解决方案 »

  1.   

    1)BOOL GetTextExtentPoint32(
      HDC hdc,           // handle to DC
      LPCTSTR lpString,  // text string
      int cbString,      // characters in string
      LPSIZE lpSize      // string size
    );2)
    BOOL PtInRect(
      CONST RECT *lprc,  // rectangle
      POINT pt           // point
    );
    or
    BOOL PtInRegion(
      HRGN hrgn,  // handle to region
      int X,      // x-coordinate of point
      int Y       // y-coordinate of point
    );
      

  2.   


    看了MSDN。。BOOL GetTextExtentPoint32(
      HDC hdc,           // handle to DC
      LPCTSTR lpString,  // text string
      int cbString,      // characters in string
      LPSIZE lpSize      // string size
    );这个只能获得他的宽度。而不能获得CRect坐标