SetFont()可以重新设置控件的字体,但风格是统一的。
现在想把按钮的一部分字体设置的大点,一部分设置的小点。
请问高手如何实现?

解决方案 »

  1.   

    BOOL CALLBACK OwnDrawProc(HWND hDlg, UINT message, WPARAM wParam, 
                              LPARAM lParam) 

        HDC hdcMem; 
        LPDRAWITEMSTRUCT lpdis; 
     
        switch (message) 
        { 
            case WM_INITDIALOG: 
     
                // hinst, hbm1 and hbm2 are defined globally. 
                hbm1 = LoadBitmap((HANDLE) hinst, "OwnBit1"); 
                hbm2 = LoadBitmap((HANDLE) hinst, "OwnBit2"); 
                return TRUE; 
     
            case WM_DRAWITEM: 
                lpdis = (LPDRAWITEMSTRUCT) lParam; 
                hdcMem = CreateCompatibleDC(lpdis->hDC); 
     
                if (lpdis->itemState & ODS_SELECTED)  // if selected 
                    SelectObject(hdcMem, hbm2); 
                else 
                    SelectObject(hdcMem, hbm1); 
     
                // Destination 
                StretchBlt( 
                    lpdis->hDC,         // destination DC 
                    lpdis->rcItem.left, // x upper left 
                    lpdis->rcItem.top,  // y upper left 
     
                    // The next two lines specify the width and 
                    // height. 
                    lpdis->rcItem.right - lpdis->rcItem.left, 
                    lpdis->rcItem.bottom - lpdis->rcItem.top, 
                    hdcMem,    // source device context 
                    0, 0,      // x and y upper left 
                    32,        // source bitmap width 
                    32,        // source bitmap height 
                    SRCCOPY);  // raster operation 
     
                DeleteDC(hdcMem); 
                return TRUE; 
     
            case WM_COMMAND: 
                if (wParam == IDOK 
                    || wParam == IDCANCEL) 
                { 
                    EndDialog(hDlg, TRUE); 
                    return TRUE; 
                } 
                if (HIWORD(wParam) == BN_CLICKED) 
                { 
                    switch (LOWORD(wParam)) 
                    { 
                        case IDC_OWNERDRAW: 
     
                            // application-defined processing 
     
                            break; 
                    } 
                } 
                break; 
     
            case WM_DESTROY: 
                DeleteObject(hbm1);  // delete bitmaps 
                DeleteObject(hbm2); 
     
                break; 
     
        } 
        return FALSE; 
            UNREFERENCED_PARAMETER(lParam);