问题描述:
当我重载了被调用窗体的CreateParams 过程时,然后用Showmodal 来显体窗体后。此时我一用鼠标指向我被调窗体上的ToolButton1时,然后一移动鼠标从一个toolbutton移向,或是鼠标箭头停在toolbutton区时,这时被调窗体就会自动跑到调用窗体的后面去了,鼠标在toolbutton区以外不会,而在toolbutton上又没有写什么代码。两个窗体都是普通非模式的窗体(fsNormal)。困扰多日,望多位帮帮。代码如下:---------调用窗体
unit Main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB;type
TfrmMain = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
frmMain: TfrmMain;implementationuses Unit3;{$R *.dfm}
procedure TfrmMain.Button2Click(Sender: TObject);
var
Form3: TForm3;
begin
Form3 := TForm3.Create(Self);//,ADOQuery1,'xx','xx');
Form3.ShowModal;
end;end.---被调窗体unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ImgList;type
TForm3 = class(TForm)
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton6: TToolButton;
ToolButton5: TToolButton;
ToolButton9: TToolButton;
ToolButton4: TToolButton;
ToolButton7: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton8: TToolButton;
private
procedure CreateParams(var Params: TCreateParams); override;
{ Private declarations }
public
{ Public declarations }
end;implementation{$R *.dfm}procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent := GetDesktopWindow();
end;end.
当我重载了被调用窗体的CreateParams 过程时,然后用Showmodal 来显体窗体后。此时我一用鼠标指向我被调窗体上的ToolButton1时,然后一移动鼠标从一个toolbutton移向,或是鼠标箭头停在toolbutton区时,这时被调窗体就会自动跑到调用窗体的后面去了,鼠标在toolbutton区以外不会,而在toolbutton上又没有写什么代码。两个窗体都是普通非模式的窗体(fsNormal)。困扰多日,望多位帮帮。代码如下:---------调用窗体
unit Main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB;type
TfrmMain = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
frmMain: TfrmMain;implementationuses Unit3;{$R *.dfm}
procedure TfrmMain.Button2Click(Sender: TObject);
var
Form3: TForm3;
begin
Form3 := TForm3.Create(Self);//,ADOQuery1,'xx','xx');
Form3.ShowModal;
end;end.---被调窗体unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ImgList;type
TForm3 = class(TForm)
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton6: TToolButton;
ToolButton5: TToolButton;
ToolButton9: TToolButton;
ToolButton4: TToolButton;
ToolButton7: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton8: TToolButton;
private
procedure CreateParams(var Params: TCreateParams); override;
{ Private declarations }
public
{ Public declarations }
end;implementation{$R *.dfm}procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent := GetDesktopWindow();
end;end.
解决方案 »
- 有没有好的表格控件介绍一下?!急用!
- rave报表 打印预览 死循环,高手门帮忙看下(在线等...)
- 请教datetimepicker高手
- sql备份还原问题?
- dll使用问题~~~
- 探讨短信开发的流程
- ★Delphi的控制台程序中有没有方法直接判断按下的按键,就像是TP7.0中的readkey,而不用输入回车键?
- 求软件文档写作方法 急需?
- 分,分,分--如何对ACCESS数据库进行导入导出备份(在DELPHI5中)
- 在delphi下运行程序时,有时候会出现Access violation at address 77FA1032 in module 'ntdll.dll'. Write of address 00000030错误
- 如何调用IE下载?
- 应用程序在当前操作中使用了错误类型的值
建议楼主自己可以重新做一下验证,就用两个FORM,form2上面放toolbutton,然后一个调用另一个,好像是不会那样。
如果确实没出现你说的那种情况,则说明应该是其他地方的问题。
unit BaseFrm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ImgList, ComCtrls, ToolWin, ExtCtrls, DBCtrls, StdCtrls,
Buttons, GridsEh, DBGridEh, DB, ADODB, IniFiles, cxImage, cxDBEdit,
cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxControls, cxContainer,
cxEdit, cxTextEdit, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid;type
TfrmBase = class(TForm)
Menu1: TMainMenu;
D1: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N1: TMenuItem;
N9: TMenuItem;
M1: TMenuItem;
N2: TMenuItem;
Excel1: TMenuItem;
ext1: TMenuItem;
T1: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
X1: TMenuItem;
X2: TMenuItem;
ImageL1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
btnAdd: TToolButton;
btnQuery: TToolButton;
btnEdit: TToolButton;
btnDelete: TToolButton;
btnPrint: TToolButton;
btnReFresh: TToolButton;
btnYes: TToolButton;
btnNo: TToolButton;
btnTodo: TToolButton;
btnNodo: TToolButton;
DBNavigator1: TDBNavigator;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
btnCut: TToolButton;
btnFolder: TToolButton;
btnDesign: TToolButton;
ToolButton5: TToolButton;
btnTrace: TToolButton;
PopupMenu1: TPopupMenu;
btnExit: TToolButton;
btnHelp: TToolButton;
StatusBar1: TStatusBar;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btnQueryClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure btnYesClick(Sender: TObject);
procedure btnNoClick(Sender: TObject);
procedure btnTodoClick(Sender: TObject);
procedure btnNodoClick(Sender: TObject);
procedure ToolBar1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); protected
procedure CreateParams(var Params: TCreateParams); override; private
{ Private declarations } public
Purview: array [1..16] of Boolean;
// Purview[1] -- 查询权限
// Purview[2] -- 修改权限
// Purview[3] -- 删除权限
// Purview[4] -- 审核权限
// Purview[5] -- 撤消审核权
// Purview[6] -- 打印权限
// Purview[7] -- 成本权限
// Purview[8] -- 售价权限
// Purview[9] -- 新增权限
// Purview[10] --送签权限
// Purview[11] --出纳权限
// Purview[12] --作废权限
FilePath: String;
UserName: String;
CompanyName: string;
UserGroup:String;
QXFlag:boolean;
ButID : integer;
procedure SetComReadOnly(IsRead: boolean);//设置FROM 中的可编辑控件的可读属性
procedure SetButEnab(s: integer); //设置按钮的可用性 end;implementation{$R *.dfm}{ TfrmBase }procedure TfrmBase.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent := GetDesktopWindow;
end;procedure TfrmBase.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// Action := Cafree;
end;procedure TfrmBase.btnExitClick(Sender: TObject);
begin
Close;
end;
var
i:integer;
begin
for i :=0 to ComponentCount -1 do
begin
if (Components[i] is TEdit) then
begin
TEdit(Components[i]).ReadOnly := IsRead;
end;
if (Components[i] is TButton) then
begin
TButton(Components[i]).Enabled := IsRead;
end;
if (Components[i] is TSpeedButton) then
begin
TSpeedButton(Components[i]).Enabled := IsRead;
TSpeedButton(Components[i]).Flat := true;
end;
if (Components[i] is TTreeView) then
begin
TTreeView(Components[i]).ReadOnly := IsRead;
end;
if (Components[i] is TDBEdit) then
begin
TDBEdit(Components[i]).ReadOnly := IsRead;
end ;
if (Components[i] is TDBMemo) then
begin
TDBMemo(Components[i]).ReadOnly := IsRead;
end;
if (Components[i] is TDBCheckBox) then
begin
TDBCheckBox(Components[i]).ReadOnly := IsRead;
end;
if (Components[i] is TSpeedButton) then
begin
TSpeedButton(Components[i]).Enabled := IsRead;
end;
if (Components[i] is TDBGridEh) then
begin
TDBGridEh(Components[i]).ReadOnly := IsRead;
end;
if (Components[i] is TcxDBTextEdit) then
begin
TcxDBTextEdit(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBMaskEdit) then
begin
TcxDBMaskEdit(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBMemo) then
begin
TcxDBMemo(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBComboBox) then
begin
TcxDBComboBox(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBCheckBox) then
begin
TcxDBCheckBox(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBImageComboBox) then
begin
TcxDBImageComboBox(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBTimeEdit) then
begin
TcxDBTimeEdit(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBDateEdit) then
begin
TcxDBDateEdit(Components[i]).Properties.ReadOnly := IsRead;
end;
if (Components[i] is TcxDBImage) then
begin
TcxDBImage(Components[i]).Properties.ReadOnly := IsRead;
end;
{if (Components[i] is TcxGridDBColumn) then
begin
TcxGridDBColumn(Components[i]).Options.Editing := not IsRead;
end; }
if (Components[i] is TcxGridDBTableView) then //TcxGridDBTableView
begin
TcxGridDBTableView(Components[i]).OptionsData.Appending := not IsRead;
TcxGridDBTableView(Components[i]).OptionsData.CancelOnExit := not IsRead;
TcxGridDBTableView(Components[i]).OptionsData.Deleting := not IsRead;
TcxGridDBTableView(Components[i]).OptionsData.Editing := not IsRead;
TcxGridDBTableView(Components[i]).OptionsData.Inserting := not IsRead;
TcxGridDBTableView(Components[i]).OptionsData.DeletingConfirmation := not IsRead;
end;
end;
end;procedure TfrmBase.SetButEnab(s: integer);
begin
case s of
1:begin //新增
btnAdd.Enabled := False ;
btnQuery.Enabled := False ;
btnEdit.Enabled := False ;
btnDelete.Enabled := False ;
btnPrint.Enabled := False ;
btnReFresh.Enabled := False ;
btnYes.Enabled := True ;
btnNo.Enabled := True ;
btnTodo.Enabled := False ;
btnNodo.Enabled := False ;
btnCut.Enabled := False ;
DBNavigator1.Enabled := False;
end; 2:begin //修改
btnAdd.Enabled := False ;
btnQuery.Enabled := False ;
btnEdit.Enabled := False ;
btnDelete.Enabled := False ;
btnPrint.Enabled := False ;
btnReFresh.Enabled := False ;
btnYes.Enabled := True ;
btnNo.Enabled := True ;
btnTodo.Enabled := False ;
btnNodo.Enabled := False ;
btnCut.Enabled := False ;
DBNavigator1.Enabled := False;
end; 3:begin //查询
StatusBar1.Panels[1].Text := '' ;
btnAdd.Enabled := True and Purview[9];
btnQuery.Enabled := True ;
DBNavigator1.Enabled := True;
btnEdit.Enabled := TRUE and Purview[2];
btnPrint.Enabled := TRUE and Purview[11];
btnDelete.Enabled := Purview[3] ;
btnReFresh.Enabled := False ;
btnYes.Enabled := False ;
btnNo.Enabled := False ;
btnTodo.Enabled := False ;
btnNodo.Enabled := False ;
btnCut.Enabled := False ; end;
4: //删除
begin
btnAdd.Enabled := true and Purview[9];
btnQuery.Enabled := true and Purview[1];
btnEdit.Enabled := True and Purview[2];
btnPrint.Enabled := TRUE and Purview[11];
btnYes.Enabled := false;
btnNo.Enabled := false;
btnTodo.Enabled := False ;
btnNodo.Enabled := False ;
btnCut.Enabled := False ;
//btnScr.Enabled := True;
end;
5: //保存/取消保存
begin
btnAdd.Enabled := true and Purview[9];
btnQuery.Enabled := true and Purview[1];
btnEdit.Enabled := True and Purview[2];
btnYes.Enabled := false;
btnNo.Enabled := false;
btnTodo.Enabled := true ;
btnNodo.Enabled := False ;
btnCut.Enabled := False ;
DBNavigator1.Enabled := True;
end ;
6: //审核/撤消审核
begin
btnAdd.Enabled := true and Purview[9];
btnQuery.Enabled := true and Purview[1];
btnEdit.Enabled := True and Purview[2];
btnYes.Enabled := false;
btnNo.Enabled := false;
btnTodo.Enabled := not btnNodo.Enabled ;
btnNodo.Enabled := not btnTodo.Enabled ;
btnCut.Enabled := False ;
// btnScr.Enabled := True;
end;
end;
end;procedure TfrmBase.FormCreate(Sender: TObject);
begin
// SetComReadOnly(false);
end;procedure TfrmBase.FormShow(Sender: TObject);
begin
//btnAdd.Enabled := Purview[9];
//btnQuery.Enabled := Purview[1];
end;procedure TfrmBase.btnAddClick(Sender: TObject);
begin
SetButEnab(1);
end;procedure TfrmBase.btnQueryClick(Sender: TObject);
begin
SetButEnab(3);
end;procedure TfrmBase.btnEditClick(Sender: TObject);
begin
SetButEnab(2);
end;procedure TfrmBase.btnDeleteClick(Sender: TObject);
begin
SetButEnab(4);
end;procedure TfrmBase.btnYesClick(Sender: TObject);
begin
SetButEnab(5);
end;procedure TfrmBase.btnNoClick(Sender: TObject);
begin
SetButEnab(5);
end;procedure TfrmBase.btnTodoClick(Sender: TObject);
begin
SetButEnab(6);
end;procedure TfrmBase.btnNodoClick(Sender: TObject);
begin
SetButEnab(6);
end;procedure TfrmBase.ToolBar1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
showmessage(inttostr(x));
end;end.
你就按我说的,什么都不放,就两个Form1,Form2,然后form2 override createparams函数,再在form2上面放toolbutton,然后你运行程序,也会出现你说的那样的情况吗?
你给那么多代码,我也不可能拿来弄啊。
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses Unit2;
{$R *.DFM}procedure TForm1.btn1Click(Sender: TObject);
var
form2:TForm2;
begin
form2:=tform2.Create(self);
form2.ShowModal;
end;end.unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin;type
TForm2 = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
private
{ Private declarations }
procedure CreateParams(var Params: TCreateParams);override;
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.DFM}{ TForm2 }procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent:=GetDesktopWindow();
end;end.
看你类名TfrmBase应该是作基类的,如果后又加了新的控件类型,又你重写了,而且还不是虚方法
http://topic.csdn.net/u/20101214/11/6b178b54-325e-4f2a-821d-9001e0bc0ac9.html