问题如下:
1 delphi 把windows的TMsg记录中的信息映射为:TMessage记录:
type TMessage = packed record Msg: Cardinal; case Integer of 0: ( WParam: Longint; LParam: Longint; Result: Longint); 1: ( WParamLo: Word; WParamHi: Word; LParamLo: Word; LParamHi: Word; ResultLo: Word; ResultHi: Word); end; 我想问下 'case Integer of ' 是什么意思,为什么有个Integer?
2.通知消息是怎么处理的,要是能给个实例就好了
3.在TForm1中定义的通知消息处理过程procedure NoticeMsgHandle(var Msg:TMessage);message BN_CLICKED;
为什么报错:[Error] NoticeMsg.pas(15): Illegal message method index
1 delphi 把windows的TMsg记录中的信息映射为:TMessage记录:
type TMessage = packed record Msg: Cardinal; case Integer of 0: ( WParam: Longint; LParam: Longint; Result: Longint); 1: ( WParamLo: Word; WParamHi: Word; LParamLo: Word; LParamHi: Word; ResultLo: Word; ResultHi: Word); end; 我想问下 'case Integer of ' 是什么意思,为什么有个Integer?
2.通知消息是怎么处理的,要是能给个实例就好了
3.在TForm1中定义的通知消息处理过程procedure NoticeMsgHandle(var Msg:TMessage);message BN_CLICKED;
为什么报错:[Error] NoticeMsg.pas(15): Illegal message method index
解决方案 »
- 登陆菜单单击后重新调出登陆界面
- delphi 谁能帮我简化这段IF语句.或者有另一种能实现这IF语句的办法.
- 请指出个地点
- 酒店管理系统,一个人做,唉!!!用了一年可是,,,,,,进来,,散分了!
- 用tsocketconnection连接,如何把它集成到服务端?
- 哪位可以说一下enumdisplaysettings()这个函数的用法?
- 用backup database备份数据库的时候如何获取SQL返回的操作信息
- 关于ADOQuery的filter
- 用不了SkinEngine,怎么回事?
- 各位,请问DBDatetimepicker控件哪里有下载?拜托了!
- RichEdit中的文本存入txt文件的问题?
- Delphi 中怎么将Excel 单元格中的数据水平与垂直方向都居中显示?
case integer of 没有什么别的意思,不知道你是否了解C语言里面的共用体.
case integer of,这种语法,就是来做共用体定义的.2.通知消息是怎么处理的?不太明白你的意思. 你是说怎么样写消息响应函数来响应这个消息?直接在TForm1里面加个成员函数: procedure WMYourMsg(var msg: TMessage); message WM_YourMsg;就行了.
private, protected, public都行
3.不知道
procedure TApplication.Run;
begin
FRunning := True;
try
AddExitProc(DoneApplication);
if FMainForm <> nil then
begin
case CmdShow of
SW_SHOWMINNOACTIVE: FMainForm.FWindowState := wsMinimized;
SW_SHOWMAXIMIZED: MainForm.WindowState := wsMaximized;
end;
if FShowMainForm then
if FMainForm.FWindowState = wsMinimized then
Minimize else
FMainForm.Visible := True;
repeat
try
HandleMessage;
except
HandleException(Self);
end;
until Terminated;
end;
finally
FRunning := False;
end;
end;procedure TApplication.HandleMessage;
var
Msg: TMsg;
begin
if not ProcessMessage(Msg) then Idle(Msg);
end;function TApplication.ProcessMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
Handled := False;
if Assigned(FOnMessage) then FOnMessage(Msg, Handled);
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True;
end;
end;
在DispatchMessage(Msg);之后,消息被分发到各对应的窗体,然后由注册的窗体函数来处理消息,可以看看tform的
procedure WndProc(var Message: TMessage); override;
第三个问题,可能是不能截BN_CLICKED=0吧.
对1补充一下,case integer of 相当与C语言里 union (共同体)
他和struct/packed record 的最大区别就是节省空间,即:分配时按照最大的分配。
s:string;
begin
s:='abc';
sentmessage(edit1.handle,WM_SETTEXT,0,pchar(s));
end;
wParam: 就是你想要的BN_CLICKED
lParam: 按钮的句柄