>>>1000分求1.金山词霸的菜单效果(400$)2.XP中鼠标移上去可以变色的按扭(400$)3.象流光一样的进度条效果(200$) 的原代码.
关键是效果一样就行了,要求说明详细点。其他不需要
我的邮箱[email protected] QQ:40604933(8:00后) 在线等待的问题。当然你也可以直接写在帖子上。
***长时间关注***
****保证给分****
****绝对正版****
关键是效果一样就行了,要求说明详细点。其他不需要
我的邮箱[email protected] QQ:40604933(8:00后) 在线等待的问题。当然你也可以直接写在帖子上。
***长时间关注***
****保证给分****
****绝对正版****
2、处理mouseenter和mouseleave消息
3、用fillrect将整个大区域分为一些小区域来填充,再用定时器进行FILLRECT,或者直接SLEEP。
1、肯定是要自画菜单了,请高人...
procedure TForm1.menuFileNewAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
var
MenuHeight,BmpPos:Integer;//菜单项的高度;菜单中所画图标的边距
TempMenuItem:TMenuItem; //调用此过程的菜单项
DrawIco:TIcon; //图标对象,用以画出菜单项的图标
TempRect:TRect; //临时的矩形区域,程序中多次使用
ShowCaption:String; //菜单项的标题
ImageList:TCustomImageList; //菜单项所使用的图标列表控件
begin
TempMenuItem:=(Sender as TMenuItem);//获取调用此过程的菜单项
ShowCaption:=TempMenuItem.Caption; //获取菜单标题
DrawIco:=TIcon.Create; //创建图标对象with ACanvas,ARect do
begin
MenuHeight:=25; //此数值与在 OnMeasureItem 事件中设置的Height属性值相同
BmpPos:=(MenuHeight-16) div 2;{
计算所画的图标边距,所显示的图标尺寸一般为16,所以此处取值也为16,
可根据实际更改此数值。} Brush.Color :=RGB(255,251,247);//设置菜单的背景色,此处设为奶白色,可根据需要更改
FillRect(Arect); //填充背景
Brush.Color:=RGB(223,215,207);//设置菜单项图标区域的背景色,可根据需要更改
TempRect:=Rect(Left,Top,MenuHeight,Bottom);//设置图标背景的矩形区域
FillRect(TempRect);//填充图标背景 if TempMenuItem.Caption='-' then
begin
Pen.Color:=RGB(175,183,207);
MoveTo(Left+MenuHeight+5,Top+((Bottom-Top) div 2)-1);
LineTo(Right,Top+((Bottom-Top) div 2)-1);
Pen.Color:=clWhite;//RGB(175,183,207);
MoveTo(Left+MenuHeight+5,Top+((Bottom-Top) div 2));
LineTo(Right,Top+((Bottom-Top) div 2));
Exit;
end;{以上程序判断该菜单项是否为分隔线,
如果是,则画出分隔线样式后退出此过程。可根据需要更改其效果} ImageList:=TempMenuItem.GetImageList;//获取所使用的图标列表控件
if ImageList<>nil then //如果主菜单关联了图标列表控件
if (TempMenuItem.Imageindex<>-1) then //如果该菜单项指定了图标
begin
ImageList.GetIcon(TempMenuItem.ImageIndex,DrawIco);//从图标列表控件中获取图标
if TempMenuItem.Checked then //如果该菜单项有复选标记则画出一个蓝色框
begin
brush.Color:=RGB(175,183,207);
Pen.Color :=clBlack;
RoundRect(Left+1,Top+2,MenuHeight-2,Bottom-2,0,0);
end;
end
else //如果该菜单项没有指定图标
if TempMenuItem.Checked then Imagelist.GetIcon(11,DrawIco);
{如果菜单项有复选标记,则从图标列表控件中获取一个表示复选的图标
数字11是该图标的索引号,可根据实际更改;如没有该图标,可将这两句删除} if (odSelected in State) {and (Not (odDisabled in State))} then
{如果该菜单项处于被选择状态,则画出以下选择样式
注释的一句加上的话表示如果菜单项处于无效状态则光标指向时无任何效果} begin //以下程序画出一个蓝色框以表示该菜单项处于被选择状态
Inc(Left,2);Inc(Top,2);
Brush.Style:=bsSolid;
brush.Color:=clGray;//RGB(110,120,180);
Pen.Color:=clMenu;
RoundRect(Left,Top,Right,Bottom,5,5);
{以上四句画出蓝色框的阴影} brush.Color:=RGB(175,183,207);
Dec(Left,2);Dec(Top,2);
Dec(Right,2);Dec(Bottom,2);
Pen.Color :=clBlack;
RoundRect(Left,Top,Right,Bottom,3,3);
{以上四句画出蓝色框} Draw(BmpPos,Top+BmpPos,DrawIco);
//画出图标阴影(我不知道怎样把图标颜色变成灰度,只好原样画上)
Dec(BmpPos,1);
end; Draw (BmpPos,Top+BmpPos,DrawIco);//画出图标
DrawIco.Free; //图标已画出,可以释放图标对象
TempRect:=Rect(Left+MenuHeight+10,Top,Right,Bottom);//设置菜单标题的矩形区域
Brush.Style:=bsClear;//设置画刷的填充样式为透明,这样画出的菜单标题就为透明底色
with Font do //根据菜单项的状态设置字体样式
begin
if (odDisabled in State) then Color :=clgray else Color :=clblack;
{设置菜单项在有效或无效状态时的字体颜色,具体的颜色可根据实际更改} if TempMenuItem.Default then Style:= Style+[fsBold];
{如果菜单项为默认,则设置字体为粗体}
end;
DrawText(Handle,PChar(ShowCaption),-1,TempRect,DT_LEFT or DT_SINGLELINE or DT_VCENTER);
{最后画出菜单项的标题}
end;
end;
//此过程为菜单项的尺寸设置列表事件
procedure TForm1.menuFileNewMeasureItem(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
begin
if TMenuItem(Sender).Caption<>'-' then Height:=25;
//如果菜单项不是分隔线则设置其高度,可根据需要更改,更改后注意将高级自画事件中的 MenuHeight 变量设置为相同数值
end;
//此过程为主菜单项的高级自画事件,主要是画出一个带阴影的矩形框
procedure TForm1.menuFileAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; State: TOwnerDrawState);
var
TempMenuItem:TMenuItem;
TempRect:TRect;
ShowCaption:String;
begin
TempMenuItem:=(Sender as TMenuItem);
ShowCaption:=TempMenuItem.Caption;
with acanvas,arect do
begin
FillRect(ARect);
Inc(Left,1);
if (odSelected in State) then //如果该菜单项处于被选择状态
begin
Brush.Color:=RGB(189,190,189);
TempRect:=Rect(Left,Top+3,Right,Bottom);
FillRect(TempRect); Brush.Color:=RGB(181,182,181);
TempRect:=Rect(Left,Top+2,Right-1,Bottom);
FillRect(TempRect); Brush.Color:=RGB(165,162,165);
TempRect:=Rect(Left,Top+1,Right-2,Bottom);
FillRect(TempRect);
//以上三段分别画出阴影 Inc(Bottom,5);
Pen.Color:=RGB(99,97,99);
Brush.Color:=clMenu;
RoundRect(Left,Top,Right-3,Bottom,5,5);
Dec(Bottom,5);
TempRect:=Rect(Left,Bottom,Right,Bottom+5);
FillRect(TempRect);
//画出边框颜色为灰色的矩形框
end;
DrawText(Handle,pchar(ShowCaption),-1,ARect,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
//最后画出菜单标题
end;
end;
but_OwnerDraw: TBitBtn; private
{ Private declarations }
procedure WMDrawItem(var Message: TWMDrawItem); message WM_DrawItem;procedure TForm1.WMDrawItem(var Message: TWMDrawItem);
var
Brush1: THandle;
begin
Message.Result := 1;
if Message.Ctl <> but_OwnerDraw.Handle then
inherited else
begin
SelectObject(Message.DrawItemStruct.hDC, but_OwnerDraw.Font.Handle);
if Message.DrawItemStruct.itemState = ODS_DISABLED then
begin
{test the itemState to see if disabled
this is painting for a Disabled button
a Grey color}
SetBkColor(Message.DrawItemStruct.hDC, $00BBBBBB);
FillRect(Message.DrawItemStruct.hDC, Message.DrawItemStruct.rcItem, GetStockObject(LTGRAY_BRUSH));
SetBkMode(Message.DrawItemStruct.hDC,TRANSPARENT);
SetTextColor(Message.DrawItemStruct.hDC,$00DDDDDD);
TextOut(Message.DrawItemStruct.hDC,8,8,PChar(but_OwnerDraw.Caption),Length(but_OwnerDraw.Caption));
SetTextColor(Message.DrawItemStruct.hDC,$00666666);
TextOut(Message.DrawItemStruct.hDC,6,6,PChar(but_OwnerDraw.Caption),Length(but_OwnerDraw.Caption));
end else
begin
{this is painting for a normal button
an Yellow color}
Brush1 := CreateSolidBrush($0000FFFF);
SetBkColor(Message.DrawItemStruct.hDC, $0000FFFF);
FillRect(Message.DrawItemStruct.hDC, Message.DrawItemStruct.rcItem, Brush1);
DeleteObject(Brush1);
TextOut(Message.DrawItemStruct.hDC,6,6,PChar(but_OwnerDraw.Caption),Length(but_OwnerDraw.Caption));
end;
if (Message.DrawItemStruct.itemState and ODS_SELECTED) <> 0 then
DrawEdge(Message.DrawItemStruct.hDC, Message.DrawItemStruct.rcItem, EDGE_SUNKEN, BF_RECT)
else
DrawEdge(Message.DrawItemStruct.hDC, Message.DrawItemStruct.rcItem, EDGE_RAISED, BF_RECT);
if Message.DrawItemStruct.itemState = ODS_FOCUS then
begin
InflateRect(Message.DrawItemStruct.rcItem,-4,-4);
DrawFocusRect(Message.DrawItemStruct.hDC, Message.DrawItemStruct.rcItem);
{make the rcRect smaller and draw a focus Rect}
end;
end;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ImgList;type
TForm1 = class(TForm)
ToolbarImages: TImageList;
MainMenu: TMainMenu;
FileMenu: TMenuItem;
FileNewItem: TMenuItem;
FileOpenItem: TMenuItem;
FileSaveItem: TMenuItem;
FileSaveAsItem: TMenuItem;
N1: TMenuItem;
FileExitItem: TMenuItem;
EditMenu: TMenuItem;
EditUndoItem: TMenuItem;
N2: TMenuItem;
EditCutItem: TMenuItem;
EditCopyItem: TMenuItem;
EditPasteItem: TMenuItem;
N5: TMenuItem;
miEditFont: TMenuItem;
LanguageMenu: TMenuItem;
LanguageEnglish: TMenuItem;
LanguageFrench: TMenuItem;
LanguageGerman: TMenuItem;
HelpMenu: TMenuItem;
HelpAboutItem: TMenuItem;
PopupMenu1: TPopupMenu;
Copy1: TMenuItem;
Paste1: TMenuItem;
Cut1: TMenuItem;
N3: TMenuItem;
SelectAll1: TMenuItem;
procedure DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure FormCreate(Sender: TObject);
private
procedure MenueDrawItemX(xMenu: TMenu);
public
end;
procedure MenueDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
begin
MenueDrawItem(Sender, ACanvas, ARect, Selected);
end;procedure TForm1.MenueDrawItemX(xMenu: TMenu);
var
i: integer;
B: TBitmap;
FMenuItem: TMenuItem;
begin
B := TBitmap.Create;
B.Width := 1;
B.Height := 1;
for i := 0 to ComponentCount - 1 do
if Components[i] is TMenuItem then
begin
FMenuItem := TMenuItem(Components[i]);
FMenuItem.OnDrawItem := DrawItem;
if (FMenuItem.ImageIndex = -1) and
(FMenuItem.Bitmap.width = 0) and (xMenu <> nil) then
if FMenuItem.GetParentComponent.Name <> xMenu.Name then
FMenuItem.Bitmap.Assign(b);
end;
B.Free;
DrawMenuBar(handle);
end;
procedure MenueDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
var
txt: string;
B: TBitmap; IConRect, TextRect: TRect;
FBackColor, FIconBackColor, FSelectedBkColor, FFontColor, FSelectedFontColor,
FDisabledFontColor, FSeparatorColor, FCheckedColor: TColor; i, X1, X2: integer;
TextFormat: integer;
HasImgLstBitmap: boolean;
FMenuItem: TMenuItem;
FMenu: TMenu;begin
FMenuItem := TMenuItem(Sender);
FMenu := FMenuItem.Parent.GetParentMenu; FBackColor := $00E1E1E1;
FIconBackColor := $00D1D1D1;
FSelectedBkColor := $00DCCFC7; FFontColor := clBlack;
FSelectedFontColor := clNavy;
FDisabledFontColor := clGray;
FSeparatorColor := $00D1D1D1;
FCheckedColor := clGray; if FMenu.IsRightToLeft then
begin
X1 := ARect.Right - 20;
X2 := ARect.Right;
end
else
begin
X1 := ARect.Left;
X2 := ARect.Left + 20;
end;
IConRect := Rect(X1, ARect.Top, X2, ARect.Bottom); TextRect := ARect;
txt := ' ' + FMenuItem.Caption; B := TBitmap.Create; B.Transparent := True;
B.TransparentMode := tmAuto; HasImgLstBitmap := false;
if (FMenuItem.Parent.GetParentMenu.Images <> nil) or
(FMenuItem.Parent.SubMenuImages <> nil) then
begin
if FMenuItem.ImageIndex <> -1 then
HasImgLstBitmap := true
else
HasImgLstBitmap := false;
end; if HasImgLstBitmap then
begin
if FMenuItem.Parent.SubMenuImages <> nil then
FMenuItem.Parent.SubMenuImages.GetBitmap(FMenuItem.ImageIndex, B)
else
FMenuItem.Parent.GetParentMenu.Images.GetBitmap(FMenuItem.ImageIndex, B)
end
else
if FMenuItem.Bitmap.Width > 0 then
B.Assign(TBitmap(FMenuItem.Bitmap)); if FMenu.IsRightToLeft then
begin
X1 := ARect.Left;
X2 := ARect.Right - 20;
end
else
begin
X1 := ARect.Left + 20;
X2 := ARect.Right;
end;
TextRect := Rect(X1, ARect.Top, X2, ARect.Bottom); ACanvas.brush.color := FBackColor;
ACanvas.FillRect(TextRect); if FMenu is TMainMenu then
for i := 0 to FMenuItem.GetParentMenu.Items.Count - 1 do
if FMenuItem.GetParentMenu.Items[i] = FMenuItem then
begin
ACanvas.brush.color := FIConBackColor;
ACanvas.FillRect(ARect);
if (FMenuItem.ImageIndex = -1) and (FMenuItem.Bitmap.width = 0) then
begin
TextRect := ARect;
break;
end;
end; ACanvas.brush.color := FIconBackColor;
ACanvas.FillRect(IconRect); if FMenuItem.Enabled then
ACanvas.Font.Color := FFontColor
else
ACanvas.Font.Color := FDisabledFontColor; if Selected then
begin
ACanvas.brush.Style := bsSolid;
ACanvas.brush.color := FSelectedBkColor;
ACanvas.FillRect(TextRect); ACanvas.Pen.color := FSelectedFontColor; ACanvas.Brush.Style := bsClear;
ACanvas.RoundRect(TextRect.Left, TextRect.top, TextRect.Right,
TextRect.Bottom, 6, 6); if FMenuItem.Enabled then
ACanvas.Font.Color := FSelectedFontColor;
end; X1 := IConRect.Left + 2;
if B <> nil then
ACanvas.Draw(X1, IConRect.top + 1, B); if FMenuItem.Checked then
begin
ACanvas.Pen.color := FCheckedColor;
ACanvas.Brush.Style := bsClear;
ACanvas.RoundRect(IconRect.Left, IconRect.top, IconRect.Right,
IconRect.Bottom, 3, 3);
end; if not FMenuItem.IsLine then
begin
SetBkMode(ACanvas.Handle, TRANSPARENT); ACanvas.Font.Name := 'Tahoma';
if FMenu.IsRightToLeft then
ACanvas.Font.Charset := ARABIC_CHARSET; if FMenu.IsRightToLeft then
TextFormat := DT_RIGHT + DT_RTLREADING
else
TextFormat := 0;
if FMenuItem.Default then
begin
Inc(TextRect.Left, 1);
Inc(TextRect.Right, 1);
Inc(TextRect.Top, 1);
ACanvas.Font.color := clGray;
DrawtextEx(ACanvas.Handle,
PChar(txt),
Length(txt),
TextRect, TextFormat, nil); Dec(TextRect.Left, 1);
Dec(TextRect.Right, 1);
Dec(TextRect.Top, 1); ACanvas.Font.color := FFontColor;
end; DrawtextEx(ACanvas.Handle,
PChar(txt),
Length(txt),
TextRect, TextFormat, nil); txt := ShortCutToText(FMenuItem.ShortCut) + ' '; if FMenu.IsRightToLeft then
TextFormat := DT_LEFT
else
TextFormat := DT_RIGHT; DrawtextEx(ACanvas.Handle,
PChar(txt),
Length(txt),
TextRect, TextFormat, nil);
end
else
begin
ACanvas.Pen.Color := FSeparatorColor;
ACanvas.MoveTo(ARect.Left + 10,
TextRect.Top +
Round((TextRect.Bottom - TextRect.Top) / 2));
ACanvas.LineTo(ARect.Right - 2,
TextRect.Top +
Round((TextRect.Bottom - TextRect.Top) / 2))
end;
B.free;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
MenueDrawItemX(Menu);
end;end.
http://snpack.fykj.com
就要出2.0支持数据库了。