CFont clFont ;
clFont.CreateStockObject(DEFAULT_GUI_FONT);
//
这样获得的clFont的高度和宽度等信息如何获得?

解决方案 »

  1.   

    BOOL GetTextExtentPoint32(
      HDC hdc,           // handle to device context
      LPCTSTR lpString,  // pointer to text string
      int cbString,      // number of characters in string
      LPSIZE lpSize      // pointer to structure for string size
    );
     
    Parameters
    hdc 
    Handle to the device context. 
    lpString 
    Pointer to the string of text. The string does not need to be zero-terminated, since cbString specifies the length of the string. 
    cbString 
    Specifies the number of characters in the string. 
    lpSize 
    Pointer to a SIZE structure in which the dimensions of the string are to be returned.
      

  2.   

    SIZE
    The SIZE structure specifies the width and height of a rectangle. typedef struct tagSIZE { // siz 
        LONG cx; 
        LONG cy; 
    } SIZE; 
     
    Members
    cx 
    Specifies the rectangle's width. 
    cy 
    Specifies the rectangle's height.