with Message.DrawItemStruct^ do
是啥意思???????
是啥意思???????
解决方案 »
- 各位delphi开发人员都来讨论下,平时都是怎么做界面的?
- 在使用 键盘接口 的 条码扫描器时如何 识别是键盘输入的还是条码扫描器输入的????????????????? 急!!!!!!!!!
- 如何获取已打开的ie的句柄?
- 高分求:动态创建组件问题?
- 急!!请问:为何DELPHI7无法向ACCESS97中输入数据?ACCESS97数据库结构能在DELPHI中更改吗?
- 如何实现带有checkbox的ttreeviw,我是想做个类似瑞兴杀毒的那个操作界面。
- 有一个困扰了小妹很久的问题,请大虾们指教一二!
- help:Required package 'TEE' not found
- 有同感的兄弟们,帮我发泄一下吧!(上者有分)
- 我解决了几乎所有Delphi+Access同仁的问题—动态创建、压缩Access数据库(*.MDB)
- 如何偏历本目录下或指定目录下的所有文件? 并对这些文件进行改名?
- 李煜全集二
如果该该指针指向的东西是具有成员的,如对象,结构等,就可在其后语句里省略描述这个东西,而直接写出这个东西的成员名就可以操纵该成员了。
2、设置TPopupMenu的Images
3、设置TMenuItem的OnMeasureItem和OnDrawItem分别指向两个例程。procedure TfrmMain.pmTrayPopup(Sender: TObject);
begin
pmTray.Tag := 1; //对于左边的位图保证只绘制一次
end;procedure TfrmMain.MenuMeasureItem(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
begin
if (Sender as TMenuItem).IsLine then
Height := 4 //分隔条
else
Height := Canvas.TextHeight('高') + 6;
//const BMWidth = 位图宽度
Inc(Width, BMWidth + 7); //为左边的位图保留一些空间
end;procedure TfrmMain.MenuDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
var ABitmap: TBitmap;
Item: TMenuItem;
Rc: TRect;
nLeft, nTop: Integer;
Ico: HICON;
begin
Item := Sender as TMenuItem;
ABitmap := TBitmap.Create;
try
//对于左边的位图保证只绘制一次
if (pmTray.Tag = 1) and (Item.MenuIndex = 0) then
begin
pmTray.Tag := 0;
ABitmap.LoadFromResourceID(hInstance, PostMan); //左边图形的ResourceID
CopyRect(Rc, ACanvas.ClipRect);
Rc.Left := BMWidth + 2;
CopyRect(Rc, ACanvas.ClipRect);
Rc.Right := Rc.Left + BMWidth + 2;
//用图形左下的颜色填充矩形
ACanvas.Brush.Color := ABitmap.Canvas.Pixels[0, ABitmap.Height - 1];
ACanvas.FillRect(Rc);
//绘制一个凹下的矩形框
Frame3D(ACanvas, Rc, clBtnShadow, clBtnHighlight, 1);
ACanvas.Draw(Rc.Left, Rc.Top, ABitmap);
//绘制Application图标
Ico := LoadImage(hInstance, PChar(szMainIcon), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
nLeft := (BMWidth - 16) div 2 + 1;
DrawIconEx(ACanvas.Handle, nLeft, Rc.Bottom - nLeft - 16,
Ico, 16, 16, 0, 0, DI_NORMAL);
DestroyIcon(Ico);
ACanvas.Brush.Color := clBtnFace;
end;
CopyRect(Rc, ARect);
Inc(Rc.Left, BMWidth + 2);
nTop := Grade + Ord(Selected);
//绘制背景图形
ABitmap.LoadFromResourceID(hInstance, nTop); ***********************************************************
ACanvas.CopyRect(Rc, ABitmap.Canvas, Rect(0, 0, ABitmap.Width, ABitmap.Height));
if Item.IsLine then //绘制菜单分隔条
begin
nTop := (ARect.Bottom + ARect.Top) div 2 - 1;
ACanvas.Pen.Color := clBtnShadow;
ACanvas.MoveTo(BMWidth + 3, nTop);
ACanvas.LineTo(ARect.Right, nTop);
ACanvas.Pen.Color := clBtnHighlight;
ACanvas.MoveTo(BMWidth + 3, nTop + 1);
ACanvas.LineTo(ARect.Right, nTop + 1);
end else
begin
nTop := (Rc.Bottom + Rc.Top - imglstState.Height) div 2;
nLeft := Rc.Left + (Rc.Bottom - Rc.Top - imglstState.Width) div 2 + 2;
if Selected then //绘制被选择菜单的外观
begin
with Rc do
Right := Left + Bottom - Top;
DrawEdge(ACanvas.Handle, Rc, BDR_RAISEDINNER, BF_RECT);
Inc(Rc.Left, Rc.Bottom - Rc.Top + 1);
Rc.Right := ARect.Right;
DrawEdge(ACanvas.Handle, Rc, BDR_SUNKENOUTER, BF_RECT);
end;
//绘制菜单前面的小图形,一个TImageList
imglstState.Draw(ACanvas, nLeft - 1, nTop, Item.ImageIndex, Item.Enabled);
CopyRect(Rc, ARect);
InflateRect(Rc, -1, -1);
Inc(Rc.Left, BMWidth + ARect.Bottom - ARect.Top + 6);
ACanvas.Brush.Style := bsClear;
if not Item.Enabled then
begin
OffsetRect(Rc, 1, 1);
ACanvas.Font.Color := clBtnHighlight;
end else
with ACanvas.Font do
if Selected then Color := clRed else Color := clBtnText;
ACanvas.Brush.Style := bsClear;
if Item.Enabled or (not Selected) then
DrawText(ACanvas.Handle, PChar(Item.Caption), Length(Item.Caption), Rc,
DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
if not Item.Enabled then
begin
OffsetRect(Rc, -1, -1);
ACanvas.Font.Color := clBtnShadow;
DrawText(ACanvas.Handle, PChar(Item.Caption), Length(Item.Caption), Rc,
DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
end;
end;
finally
ABitmap.Free;
end;
end;
应在下面的位置procedure TfrmMain.pmTrayPopup(Sender: TObject);
begin
pmTray.Tag := 1; //对于左边的位图保证只绘制一次
end;procedure TfrmMain.MenuMeasureItem(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
begin
if (Sender as TMenuItem).IsLine then
Height := 4 //分隔条
else
Height := Canvas.TextHeight('高') + 6;
//const BMWidth = 位图宽度
Inc(Width, BMWidth + 7); //为左边的位图保留一些空间
end;procedure TfrmMain.MenuDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
var ABitmap: TBitmap;
Item: TMenuItem;
Rc: TRect;
nLeft, nTop: Integer;
Ico: HICON;
begin
Item := Sender as TMenuItem;
ABitmap := TBitmap.Create;
try
//对于左边的位图保证只绘制一次
if (pmTray.Tag = 1) and (Item.MenuIndex = 0) then
begin
pmTray.Tag := 0;
ABitmap.LoadFromResourceID(hInstance, PostMan); //左边图形的ResourceID********************************************************************************************************
CopyRect(Rc, ACanvas.ClipRect);
Rc.Left := BMWidth + 2;
CopyRect(Rc, ACanvas.ClipRect);
Rc.Right := Rc.Left + BMWidth + 2;
//用图形左下的颜色填充矩形
ACanvas.Brush.Color := ABitmap.Canvas.Pixels[0, ABitmap.Height - 1];
ACanvas.FillRect(Rc);
//绘制一个凹下的矩形框
Frame3D(ACanvas, Rc, clBtnShadow, clBtnHighlight, 1);
ACanvas.Draw(Rc.Left, Rc.Top, ABitmap);
//绘制Application图标
Ico := LoadImage(hInstance, PChar(szMainIcon), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
nLeft := (BMWidth - 16) div 2 + 1;
DrawIconEx(ACanvas.Handle, nLeft, Rc.Bottom - nLeft - 16,
Ico, 16, 16, 0, 0, DI_NORMAL);
DestroyIcon(Ico);
ACanvas.Brush.Color := clBtnFace;
end;
CopyRect(Rc, ARect);
Inc(Rc.Left, BMWidth + 2);
nTop := Grade + Ord(Selected);
//绘制背景图形
ABitmap.LoadFromResourceID(hInstance, nTop);
ACanvas.CopyRect(Rc, ABitmap.Canvas, Rect(0, 0, ABitmap.Width, ABitmap.Height));
if Item.IsLine then //绘制菜单分隔条
begin
nTop := (ARect.Bottom + ARect.Top) div 2 - 1;
ACanvas.Pen.Color := clBtnShadow;
ACanvas.MoveTo(BMWidth + 3, nTop);
ACanvas.LineTo(ARect.Right, nTop);
ACanvas.Pen.Color := clBtnHighlight;
ACanvas.MoveTo(BMWidth + 3, nTop + 1);
ACanvas.LineTo(ARect.Right, nTop + 1);
end else
begin
nTop := (Rc.Bottom + Rc.Top - imglstState.Height) div 2;
nLeft := Rc.Left + (Rc.Bottom - Rc.Top - imglstState.Width) div 2 + 2;
if Selected then //绘制被选择菜单的外观
begin
with Rc do
Right := Left + Bottom - Top;
DrawEdge(ACanvas.Handle, Rc, BDR_RAISEDINNER, BF_RECT);
Inc(Rc.Left, Rc.Bottom - Rc.Top + 1);
Rc.Right := ARect.Right;
DrawEdge(ACanvas.Handle, Rc, BDR_SUNKENOUTER, BF_RECT);
end;
//绘制菜单前面的小图形,一个TImageList
imglstState.Draw(ACanvas, nLeft - 1, nTop, Item.ImageIndex, Item.Enabled);
CopyRect(Rc, ARect);
InflateRect(Rc, -1, -1);
Inc(Rc.Left, BMWidth + ARect.Bottom - ARect.Top + 6);
ACanvas.Brush.Style := bsClear;
if not Item.Enabled then
begin
OffsetRect(Rc, 1, 1);
ACanvas.Font.Color := clBtnHighlight;
end else
with ACanvas.Font do
if Selected then Color := clRed else Color := clBtnText;
ACanvas.Brush.Style := bsClear;
if Item.Enabled or (not Selected) then
DrawText(ACanvas.Handle, PChar(Item.Caption), Length(Item.Caption), Rc,
DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
if not Item.Enabled then
begin
OffsetRect(Rc, -1, -1);
ACanvas.Font.Color := clBtnShadow;
DrawText(ACanvas.Handle, PChar(Item.Caption), Length(Item.Caption), Rc,
DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS);
end;
end;
finally
ABitmap.Free;
end;
end;