the Handled parameter indicates whether the event handler responded to the message. Set Handled to True if the message has been completely handled, to prevent subsequent processing of the message.
也就是表示处理完了
也就是表示处理完了
procedure TForm_OvertimeInput.ApplicationEvents1Message(var Msg: tagMSG;var Handled: Boolean);/////////////////////////
if Msg.hwnd=(DBGrid_OVERTIMETABLE.Components[0] as TWinControl).handle then
这判定语句是判定如果传递给本过程的消息(Msg)是从TWinControl类继承下来的具有窗口句柄(Handle)的话那么就执行下面的语句.
//////////////////
这段过程好像是DBGrid中还添加了其它的控件,如PopMenu和其它的具有Handl的从TWinControl下继承下来的控件.
//////////////
没有菜单的原因是它只在用户选中"GlTime"字段时才出现.多试一下吧.
if Str_FieldName='G1TIME' then
begin
G_FieldNo:=1;
Pm_OT.Popup(Msg.pt.x,Msg.pt.y);
end
var Handled: Boolean);
Var
Str_FieldName:String;
begin
if (ActiveControl=DBGrid_OVERTIMETABLE)and(msg.message = WM_RBUTTONUP)then //活动的控件与右键;
begin
Handled:=True;//处理完毕;
if Msg.hwnd=(DBGrid_OVERTIMETABLE.Components[0] as TWinControl).handle then //是向该控件发送消息;
begin
Str_FieldName:=DBGrid_OVERTIMETABLE.SelectedField.FieldName;
//得到选定的列名;
if Str_FieldName='G1TIME' then
begin //如果是这个东西
G_FieldNo:=1;
Pm_OT.Popup(Msg.pt.x,Msg.pt.y); //弹出菜单;
end
else ....
//好象是这样的~~~~~~~
1. Handled:=True; 是什麼处理完毕??
2. Components[0] 是不是的dbgrid第1列字段呀 ?
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;Components[0]; //就是DBGrid上的编辑框
1. Handled:=True; Handled是一个返回值,也就是说你执行完这个实践后,把Handled返回给系统,系统根据Handled的值决定下一步做什么!Handled含义你可以从帮助里查,(我不记得了,不好意思)
2dbgrid的每一列都是一个类,有自己得句柄,一个字短一般是一个数租。
var Handled: Boolean);
begin
Handled := True; //测试这个代码看看//明白了吧
end;
其实DBGrid上只有一个编辑框
如果每一个区都有编辑框
系统资源不是耗大了吗!
var Handled: Boolean);
begin
Handled := True; //测试这个代码看看//明白了吧
end;
其实DBGrid上只有一个编辑框
如果每一个区都有编辑框
系统资源不是耗大了吗!
var Handled: Boolean);
begin
Handled := True; //测试这个代码看看//明白了吧
end;
其实DBGrid上只有一个编辑框
如果每一个区都有编辑框
系统资源不是耗大了吗!
1.没有特别的意思,只是一个标识而已,即执行到这里时Handled的值为True
2.你看一下是否有部分控件设定其Parant属性是否设为DBGrid,这句语句的意思是BDGrid下包含的控件数组 Components[0]表示第一个控件.
你可以试一试下面的语句
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Parent:=DBGrid1;
end;
button是不是跑到DBGrid1里面去了?
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
~~~~~~~~~~~not Handled 不处理TranslateMessage(Msg),DispatchMessage(Msg);
DBGrid_OVERTIMETABLE.Components[0]
DBGrid_OVERTIMETABLE.Components[1]
你说 “0”和“1” 有什么区别
自己做测试,自己看帮助努力工作中.......................
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
~~~~~~~~~~~not Handled 不处理TranslateMessage(Msg),DispatchMessage(Msg);
DBGrid_OVERTIMETABLE.Components[0]
DBGrid_OVERTIMETABLE.Components[1]
你说 “0”和“1” 有什么区别
自己做测试,自己看帮助努力工作中.......................
var e : TEdit;
begin
e := TEdit.Create(form1);
e.Parent := dbgrid1;
end;
那么dbgrid1.ComponentCount=1,而dbgrid1.Components[0].ClassName就是TEdit。
var e : TEdit;
begin
e := TEdit.Create(form1);
e.Parent := dbgrid1;
end;
那么dbgrid1.ComponentCount=1,而dbgrid1.Components[0].ClassName就是TEdit。
我還是不理解???
我還是不理解???
我還是不理解???
Components[0]; //就是DBGrid上的编辑框,其实DBGrid上只有一个编辑框
程序中DBGrid顯示8個字段,我測試代碼的情況是;
@(1)只在任何一個字段上點鼠標右鍵,執行到
Msg.hwnd=(DBGrid_OVERTIMETABLE.Components[0] as TWinControl).handle
其值為False,
@(2)在任何一個字段上雙擊鼠標,使此字段為編輯狀態,再點鼠標右鍵時Msg.hwnd=(DBGrid_OVERTIMETABLE.Components[0] as TWinControl).handle
其值為true, 才可能有上下文菜單但我又有疑問;
對@(1) (ActiveControl=DBGrid_OVERTIMETABLE) and (msg.message = WM_RBUTTONUP) 為true ,不就是說
msg的句柄是DBGrid_OVERTIMETABLE的句柄嗎 ?? 既然如此的話 Msg.hwnd=(DBGrid_OVERTIMETABLE.Components[0] as TWinControl).handle
其值為什麼不是true呢 ??
在你的程序中,这是最外层的条件,只有它满足以后才考虑其他的条件;