如题:)

解决方案 »

  1.   

    自绘界面控件。Menu,Toolbar等。
    下面是一段自绘菜单项目的代码,可供参考(用API写的,在MFC中你可以让MainFrame窗口处理消息WM_MEASUREITEM,WM_DRAWITEM来实现。)
    int CChargeChildView::OnMeasureItem(WPARAM wParam,LPARAM lParam)
    {
    MEASUREITEMSTRUCT* lpmis=(MEASUREITEMSTRUCT*)lParam;
    if(lpmis!=NULL)
    {
    if(lpmis->CtlType==ODT_MENU)
    {
    lpmis->itemWidth=160;
    if(lpmis->itemID==0)
    lpmis->itemHeight=3;
    else
    lpmis->itemHeight=22;
    return TRUE;
    }
    }
    return FALSE;
    }
    int CChargeChildView::OnDrawItem(WPARAM wParam,LPARAM lParam)
    {
    HBRUSH hbr=NULL,hbrLeft=NULL,hbrSel=NULL,hbrOrg=NULL;
    HICON hIcon=NULL;
    HFONT hfOrg=NULL;
    char szMenuItem[50];
    RECT rc;
    DRAWITEMSTRUCT* lpdis=(DRAWITEMSTRUCT*)lParam;
    if(lpdis!=NULL)
    {
    if(lpdis->CtlType==ODT_MENU)
    { hbr=CreateSolidBrush(RGB(249,248,247));
    hbrLeft=CreateSolidBrush(RGB(219,216,209));
    FillRect(lpdis->hDC,&lpdis->rcItem,hbr);
    CopyRect(&rc,&lpdis->rcItem);
    rc.right=rc.left+20;
    FillRect(lpdis->hDC,&rc,hbrLeft); if(lpdis->itemID==0)
    {
    HPEN hpen,hpenOrg;
    hpen=CreatePen(PS_SOLID,1,RGB(166,166,166));
    hpenOrg=(HPEN)SelectObject(lpdis->hDC,hpen);
    MoveToEx(lpdis->hDC,24,lpdis->rcItem.top+1,NULL);
    LineTo(lpdis->hDC,lpdis->rcItem.right,lpdis->rcItem.top+1);
    SelectObject(lpdis->hDC,hpenOrg);
    DeleteObject(hpen); DeleteObject(hbrLeft);
    DeleteObject(hbr);
    return TRUE;
    } SetBkMode(lpdis->hDC,TRANSPARENT); switch(lpdis->itemID)
    {
    case IDM_SAVE:
    {
    hIcon=LoadIcon(app.m_hInstance,MAKEINTRESOURCE(IDI_SAVE));
    GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
    }
    break;
    case IDCANCEL:
    {
    hIcon=LoadIcon(app.m_hInstance,MAKEINTRESOURCE(IDI_CANCEL));
    GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
    }
    break;
    default:
    {
    GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
    }
    } CopyRect(&rc,&lpdis->rcItem);
    if(hIcon!=NULL)
    DrawIconEx(lpdis->hDC,lpdis->rcItem.left+2,lpdis->rcItem.top+2,hIcon,16,16,0,NULL,DI_NORMAL); lpdis->rcItem.left=24;
    hfOrg=(HFONT)SelectObject(lpdis->hDC,m_hfMenuItem);
    DrawText(lpdis->hDC,szMenuItem,-1,&lpdis->rcItem,DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    SelectObject(lpdis->hDC,hfOrg); DeleteObject(hbr);
    DeleteObject(hbrLeft); if(lpdis->itemState & ODS_SELECTED)
    {
    //Draw select item bar
    int nROP;
    nROP=SetROP2(lpdis->hDC,R2_MASKPEN); lpdis->rcItem.left=rc.left;
    CopyRect(&rc,&lpdis->rcItem);
    hbrSel=CreateSolidBrush(RGB(182,189,210));
    hbrOrg=(HBRUSH)SelectObject(lpdis->hDC,hbrSel);
    Rectangle(lpdis->hDC,rc.left,rc.top,rc.right,rc.bottom);
    SelectObject(lpdis->hDC,hbrOrg);
    DeleteObject(hbrSel);
    SetROP2(lpdis->hDC,nROP); }
    SetBkMode(lpdis->hDC,OPAQUE);
    return TRUE;
    }
    } return FALSE;
    }
      

  2.   

    有没有通用的方法,比如说对MFC中的某些类做处理,然后子类继承后让界面显示一致的特殊风格(如office2003)
      

  3.   

    当然有。你可以在设置hook,重置需要draw的窗口的新窗口过程。
      

  4.   

    用一些现成的控件吧,如BCG等。
    http://community.csdn.net/Expert/topic/4419/4419124.xml?temp=.2382318