解决方案 »

  1.   

    比如我要查CreatePointFont,我只能查到MFC的,查不到API的
      

  2.   

    比如我要查CreatePointFont,我只能查到MFC的,查不到API的
    查找win32的 CreateFont or CreateFontIndirect
      

  3.   

    比如我要查CreatePointFont,我只能查到MFC的,查不到API的
    查找win32的 CreateFont or CreateFontIndirect
    CreateFont用过,好像不能自定义字体类型,比如Arial、Impact、Verdana之类的字体
    我就是想要改变字体类型,所以想知道CreatePointFont封装了哪些API
      

  4.   

    可以,MFC不是开源的,但是可以看到部分代码。
      

  5.   

    比如我要查CreatePointFont,我只能查到MFC的,查不到API的
    查找win32的 CreateFont or CreateFontIndirect
    CreateFont用过,好像不能自定义字体类型,比如Arial、Impact、Verdana之类的字体
    我就是想要改变字体类型,所以想知道CreatePointFont封装了哪些API这就是MSDN的解释http://msdn.microsoft.com/en-us/library/windows/desktop/dd183499(v=vs.85).aspx
    里面的示例代码如下:LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        int wmId, wmEvent;
        PAINTSTRUCT ps;
        HDC hdc;
        switch (message)
        {
        
        
        case WM_PAINT:
            {
            RECT rect;
            HBRUSH hBrush;
            HFONT hFont;
            hdc = BeginPaint(hWnd, &ps);            
                //Logical units are device dependent pixels, so this will create a handle to a logical font that is 48 pixels in height.
                //The width, when set to 0, will cause the font mapper to choose the closest matching value.
                //The font face name will be Impact.
                hFont = CreateFont(48,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                    CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY, VARIABLE_PITCH,TEXT("Impact"));
                SelectObject(hdc, hFont);
                
                //Sets the coordinates for the rectangle in which the text is to be formatted.
                SetRect(&rect, 100,100,700,200);
                SetTextColor(hdc, RGB(255,0,0));
                DrawText(hdc, TEXT("Drawing Text with Impact"), -1,&rect, DT_NOCLIP);
                            //Logical units are device dependent pixels, so this will create a handle to a logical font that is 36 pixels in height.
                //The width, when set to 20, will cause the font mapper to choose a font which, in this case, is stretched.
                //The font face name will be Times New Roman.  This time nEscapement is at -300 tenths of a degree (-30 degrees)
                hFont = CreateFont(36,20,-300,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                    CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY, VARIABLE_PITCH,TEXT("Times New Roman"));
                SelectObject(hdc,hFont);
                
                //Sets the coordinates for the rectangle in which the text is to be formatted.
                SetRect(&rect, 100, 200, 900, 800);
                SetTextColor(hdc, RGB(0,128,0));
                DrawText(hdc, TEXT("Drawing Text with Times New Roman"), -1,&rect, DT_NOCLIP);
                
                    
                //Logical units are device dependent pixels, so this will create a handle to a logical font that is 36 pixels in height.
                //The width, when set to 10, will cause the font mapper to choose a font which, in this case, is compressed. 
                //The font face name will be Arial. This time nEscapement is at 250 tenths of a degree (25 degrees)
                hFont = CreateFont(36,10,250,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                    CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Arial"));
                SelectObject(hdc,hFont);            //Sets the coordinates for the rectangle in which the text is to be formatted.
                SetRect(&rect, 500, 200, 1400, 600);
                SetTextColor(hdc, RGB(0,0,255));
                DrawText(hdc, TEXT("Drawing Text with Arial"), -1,&rect, DT_NOCLIP);
                DeleteObject(hFont);    
            
            EndPaint(hWnd, &ps);
            break;
            }
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        return 0;
    }重申我1楼所说的:查msdn
      

  6.   

    许多mfc函数实际和api函数名称相同,只是参数不同,但有一些mfc函数没有对应的api,具体可以差msdn,装个msdn6吧,这个可以很方便的查到各个mfc函数及api函数
      

  7.   

    名字都是相通的, 
    你稍变通一个, 比如在msdn里面搜索:  CreateFont  就会看到很多个API  (注意, 请使用索引模式搜索).
      

  8.   

    你可以在Debug下按F11进入函数内部,可以看到部分代码
      

  9.   

    实际上有部分函数只是对SDK中的函数进行了薄封装,比如CFont的Create*Font之类的。可能只是让你少传递了几个参数而已。
      

  10.   

    MFC的大部分函数都可以看到源码的, VS在安装的时候有选项, 选择MFC源码
    然后在VS中可以看到源码, 建议用插件 VAssistX, 看源码比较方便
      

  11.   

    不是所有的 MFC 封装都是有对应的 API,既然是封装,就隐藏了复杂性。BOOL CFont::CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC)
    {
    ASSERT(AfxIsValidString(lpszFaceName)); LOGFONT logFont;
    memset(&logFont, 0, sizeof(LOGFONT));
    logFont.lfCharSet = DEFAULT_CHARSET;
    logFont.lfHeight = nPointSize;
    Checked::tcsncpy_s(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE); return CreatePointFontIndirect(&logFont, pDC);
    }// pLogFont->nHeight is interpreted as PointSize * 10
    BOOL CFont::CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC)
    {
    ASSERT(AfxIsValidAddress(lpLogFont, sizeof(LOGFONT), FALSE));
    HDC hDC;
    if (pDC != NULL)
    {
    ASSERT_VALID(pDC);
    ASSERT(pDC->m_hAttribDC != NULL);
    hDC = pDC->m_hAttribDC;
    }
    else
    hDC = ::GetDC(NULL); // convert nPointSize to logical units based on pDC
    LOGFONT logFont = *lpLogFont;
    POINT pt;
    // 72 points/inch, 10 decipoints/point
    pt.y = ::MulDiv(::GetDeviceCaps(hDC, LOGPIXELSY), logFont.lfHeight, 720);
    pt.x = 0;
    ::DPtoLP(hDC, &pt, 1);
    POINT ptOrg = { 0, 0 };
    ::DPtoLP(hDC, &ptOrg, 1);
    logFont.lfHeight = -abs(pt.y - ptOrg.y); if (pDC == NULL)
    ReleaseDC(NULL, hDC); return CreateFontIndirect(&logFont);
    }
      

  12.   


    CreatePointFont只是MFC的函数,不是系统API
    它是实现对一个 LOGFONT的填充,最后调用CreateFontIndirect来创建字体 (15楼已经列出相关代码,可以参阅)
      

  13.   

    调试的时候,进入函数内部,一步一步的调试,会发现很多API函数的,祝你好运