菜单的自画。<br>function DrawBmpMenu(itemMenu : DRAWITEMSTRUCT):BOOL;<br>var<br> orgrect, rG, rect: TRect;<br> p : TPoint;<br> DC : HDC;<br> bmpDC : HDC;<br> lb : LOGBRUSH;<br> oldBrush,Brush : HBRUSH;<br> oldbmp,bmp,bufBmp : HBITMAP;<br> BKcolor,txtColor : DWORD;<br> oldRight : integer;<br> i : integer;<br>begin<br> rect := itemMenu.rcItem;<br> //DC := CreateCompatibleDC(itemMenu.hDC);<br> DC := itemMenu.hDC;<br> {<br> bufBmp := CreateCompatibleBitmap(DC,<br> rect.right - rect.left,rect.bottom-rect.top);<br> SelectObject(DC,bufBmp);<br> }<br> //Brush := CreateSolidBrush(GetSysColor(COLOR_MENU));<br> //SelectObject(DC,brush);<br> //DeleteObject(brush);<br> //DC := itemMenu.hDC;<br> orgrect := rect;<br> {<br> rect.Bottom := rect.Bottom -rect.Top;<br> rect.Right := rect.Right - rect.left;<br> rect.top := 0;<br> rect.left := 0;<br> }<br> bmpDC := CreateCompatibleDC(DC);<br> if (itemMenu.itemAction = ODA_DRAWENTIRE) then begin<br> BKcolor := GetSysColor(COLOR_MENU);<br> txtColor := GetSysColor(COLOR_MENUTEXT);<br> end<br> else if itemMenu.itemAction = ODA_SELECT then begin<br> if not BOOL(itemMenu.itemState and ODS_SELECTED) then begin<br> BKcolor := GetSysColor(COLOR_MENU);<br> txtColor := GetSysColor(COLOR_MENUTEXT);<br> end<br> else begin<br> BKcolor := GetSysColor(COLOR_HIGHLIGHT);<br> txtColor := GetSysColor(COLOR_HIGHLIGHTTEXT);<br> end;<br> end;<br><br> {<br> rG := rect;<br> Inc(rG.Left, 20);<br> if BKColor = GetSysColor(COLOR_HIGHLIGHT) then begin<br> for i:= 1 to 120 do begin<br> Brush := CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT) +<br> i*(Abs(GetSysColor(COLOR_HIGHLIGHT)-GetSysColor(COLOR_MENU)) div 120));<br> rG.Left := rg.Left +(rect.right-rect.left-20) div 120;<br> rG.right := rG.Left + (rect.right - rect.left - 20) div 120;<br> FillRect(DC,rG,Brush);<br> DeleteObject(Brush);<br> end;<br> end else begin }<br> Brush := CreateSolidBrush(DWORD(BKcolor));<br> FillRect(DC,rect,Brush);<br> DeleteObject(Brush);<br> { end; }<br> rG := rect;<br> rG.Right := rect.Left +19;<br> Brush := CreateSolidBrush(GetSysColor(COLOR_MENU));<br> FillRect(DC,rG,Brush);<br> DeleteObject(Brush);<br> bmp := LoadBitmap(hInstance,'BITMAP_MENUCLKSET');<br> oldbmp := SelectObject(bmpDC,bmp);<br> Bitblt(DC,rect.left+3,rect.top+4,12,12,bmpDC,0,0,SRCCOPY);<br> SetBkColor(DC,BKcolor);<br> SetTextColor(DC,txtColor);<br> TextOut(DC,rect.left + 22,rect.top+2,'Clock setting',13);<br> if BKColor = GetSysColor(COLOR_HIGHLIGHT) then<br> begin<br> Brush := CreateSolidBrush(RGB(255,0,0));<br> Inc(rect.Left,18);<br> FrameRect(DC,rect,Brush);<br> DeleteObject(Brush);<br> Dec(rect.Left,18);<br> OldRight := rect.Right;<br> rect.Right := rect.Left + 17;<br> DrawEdge(DC,rect,EDGE_RAISED,BF_RECT);<br> rect.Right := OldRight;<br> end;<br> {<br> BitBlt(itemMenu.hDC,orgrect.Left,orgrect.Top,<br> orgrect.Right - orgrect.Left,<br> orgrect.Bottom - orgrect.top,<br> DC,rect.Left,rect.top,SRCCOPY);<br> }<br> SelectObject(bmpDC,oldbmp);<br> DeleteDC(bmpDC);<br> {DeleteDC(DC);}<br> {DeleteObject(bufBmp);}<br> DeleteObject(bmp);<br><br>end;<br>