sololie还有问题请教你 就是我想在状态栏内显示进度条,照网上的做法能做但就是遇到了一个问题,比如说我想将它放在第二个Panel中,在OnDrawPanel中我已经正确的设置了进度条的相关left,top,bottom,right属性,但它始终只能处于第一个Panel中,并且当窗口最大化时它就不见了,有时位置变了不知道什么原因! procedure TForm1.FormCreate(Sender: TObject); var ProgressBarStyle : integer; begin With nRect Do begin left := 0; top := 218; right := 0; bottom := 0; end; ProgressBar1.Parent := StatusBar1; ProgressBarStyle := GetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE); ProgressBarStyle := ProgressBarStyle - WS_EX_STATICEDGE; SetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE,ProgressBarStyle); StatusBar1DrawPanel(StatusBar1,StatusBar1.Panels.Items[1],nRect); end;procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); begin if Panel = StatusBar.Panels.Items[1] Then begin with ProgressBar1 Do begin Top := Rect.Top; Left := 160; width := 160; height := StatusBar.Height; end; end; end;
Sololie MessageBox能用下面的方式成功的显示中文 MessageBox(0,PChar(UTF8ToAnsi('正常显示中文')),PChar(UTF8ToAnsi('提示')),MB_OK or MB_ICONEXCLAMATION);
Note: This property is not stored with the menu item if it is supplied by a TAction object.
如果没有给菜单项指定一个Action,这个hint是没有效的
按这个来吧
http://hi.baidu.com/haitun3721/item/8548764a0a1f2a0d6dc2f098
按这个来吧
http://hi.baidu.com/haitun3721/item/8548764a0a1f2a0d6dc2f098这个我也百度到过,但觉得好复杂啊!!对于新手来说有点困难,还有你说的用Action方法做我试了下,好像也不能显示,是我操作错了,还是怎么回事。
都是用灵格斯翻译试了下,无论如何就是不能显示hint的,这个hint做样子的是给状态栏用的,所以还是按照上面地址上的方法,用THintWindow来实现
Email:[email protected]
谢谢啦!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;type
TForm1 = class(TForm)
mm1: TMainMenu;
N1: TMenuItem;
O1: TMenuItem;
S1: TMenuItem;
N2: TMenuItem;
X1: TMenuItem;
N3: TMenuItem;
A1: TMenuItem;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WndProc(var m: TMessage); override;
end;var
Form1: TForm1;implementation{$R *.dfm}
var
hintWnd: THintWindow;procedure TForm1.FormCreate(Sender: TObject);
begin
// 创建一个hint窗体实例
Application.CreateForm(HintWindowClass, hintWnd);
end;// 覆盖窗口过程,在这里处理消息
procedure TForm1.WndProc(var m: TMessage);
var
mi: TMenuItem;
pt: TPoint;
rect: TRect;
mCaption: array[0..255] of Char;
i: Integer;
txtSize: SIZE;
begin
inherited; // 处理 WM_MENUSELECT 消息,该消息表示当前菜单项被选中
if m.Msg = WM_MENUSELECT then
begin
// 找出当前选中的菜单的标题(Caption),在后面使用它来判断是哪一个菜单项
// WM_MENUSELECT 消息的 WParam 参数的低位Word保存的是当前选中菜单项的索引
GetMenuString(mm1.Handle, m.WParamLo, mCaption, Length(mCaption),
MF_BYCOMMAND and MF_BYPOSITION); // 菜单项的标题不为空才认为是一个有效的菜单项
if mCaption <> '' then
begin
GetCursorPos(pt); // 获取当前鼠标坐标
// hint 窗体的背景色,clInfoBk 是默认色,可自行定义
hintWnd.Color := clInfoBk; // 遍历窗体上的所有组件
for i := 0 to ComponentCount - 1 do
begin
// 如果当前组件是一个 TmenuItem
if Components[i] is TMenuItem then
begin
// 那么将当前组件转为 TmenuItem
mi := Components[i] as TMenuItem;
// 做些判断,关键在于当前菜单项的Caption与找出的mCaption一致
if (mi <> nil) and (mi.Caption = mCaption)
and (mi.Hint <> '') then
begin
// 得到hint的宽度和高度保存在 txtSize 中
GetTextExtentPoint32(Canvas.Handle, PChar(mi.Hint), Length(mi.Hint),
txtSize);
// 计算出hint窗体的矩形区域
// txtSize.cx 为宽,cy为高,这里只需要宽度
rect := hintWnd.CalcHintRect(txtSize.cx, mi.Hint, nil);
Inc(pt.X, 14); // 适当做些偏移,似 hint 不至于遮住菜单项
Inc(pt.Y, 12);
OffsetRect(rect, pt.x, pt.y); // 偏移 hint 窗体显示区域
hintWnd.ActivateHint(rect, mi.Hint); // 显示 hint 窗体
Break; // 找到对应的菜单项就退出遍历
end
else
hintWnd.ReleaseHandle; // 销毁 hint 句柄
end;
end;
end; // 如果菜单关闭或点击了,那么也销毁 hint窗体
// WM_MENUSELECT 消息的 LParam = 0 表示菜单项被点击
// 或退出菜单选择后菜单窗口关闭
if m.LParam = 0 then
begin
if hintWnd <> nil then
hintWnd.ReleaseHandle; // 销毁 hint 句柄
end;
end;
end;end.
大神真要开坛作法了,还是乱码!!
MessageBox(handle,Pchar('胡浩'),'error',MB_OK or MB_ICONEXCLAMATION);
MessageBoxEx(Form1.Handle,'胡浩','提示',MB_OK,MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED));
也不行,不知是不是和我的电脑有关,我记得我之前的电脑XP的好像是可以的!
还有最重要的问题请教,大神你精力好好啊,昨天3点都还在帮我回帖,今天这么早就起了啊!
MB_OK, GetSystemDefaultLangID);
还是不行,是不是我的IDE那里要进行设置啊!
就是我想在状态栏内显示进度条,照网上的做法能做但就是遇到了一个问题,比如说我想将它放在第二个Panel中,在OnDrawPanel中我已经正确的设置了进度条的相关left,top,bottom,right属性,但它始终只能处于第一个Panel中,并且当窗口最大化时它就不见了,有时位置变了不知道什么原因!
procedure TForm1.FormCreate(Sender: TObject);
var
ProgressBarStyle : integer;
begin
With nRect Do
begin
left := 0;
top := 218;
right := 0;
bottom := 0;
end;
ProgressBar1.Parent := StatusBar1; ProgressBarStyle := GetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE);
ProgressBarStyle := ProgressBarStyle - WS_EX_STATICEDGE;
SetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE,ProgressBarStyle); StatusBar1DrawPanel(StatusBar1,StatusBar1.Panels.Items[1],nRect);
end;procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
if Panel = StatusBar.Panels.Items[1] Then
begin
with ProgressBar1 Do
begin
Top := Rect.Top;
Left := 160;
width := 160;
height := StatusBar.Height;
end;
end;
end;
Sololie MessageBox能用下面的方式成功的显示中文
MessageBox(0,PChar(UTF8ToAnsi('正常显示中文')),PChar(UTF8ToAnsi('提示')),MB_OK or MB_ICONEXCLAMATION);