如何隐藏子窗体
解决方案 »
- 满分送上 谁能帮我解决 如何实现当dbcheckbox选中时 ,dbgrid中相对应的行也同时被选中?如何用一个按扭(button)实现全选?急!!!!!!!!!
- 哪里有组件开发的书籍下载
- IndyTCPServer的问题,在线等,急急急!!!
- procedure WMMouseDOWN(var message:TWMLBUTTONDOWN); message WM_LBUTTONDOWN;
- 已知一个窗体的句柄(例如是:99999),请问如何捕捉这个窗体的最小化事件?是否要用到钩子程序?
- 如何编译控件呢?在线等,请大哥们指教
- 我想问一下,怎么样通过程序,将SQL备份文件,恢复到数据库中?
- 执行外部程序并等待其结束的源程序
- dbgrid控件隐藏或显示标题栏dbgrid控件隐藏或显示标题栏
- 能够倒序读取文件?
- 如何监控一个表的所有改表
- 100分阿,如何让MDI子窗体最大化的时候只有父窗体工作区那么大,而不是潜入到父窗体中
或者 子窗体名称.visual:=false;
MDI子窗体是不允许使用这种方法的
或者 子窗体名称.visual:=false;
SetWindowPos(Form1.MDIChildren[要隐藏的子窗体].Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE or SWP_SHOWWINDOW);
int nCmdShow // show state of window
);
ParametershWndIdentifies the window. nCmdShowSpecifies how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values: Value Meaning
SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Return ValuesIf the window was previously visible, the return value is nonzero.
If the window was previously hidden, the return value is zero. ResThe first time a program calls ShowWindow, it uses the WinMain function's nCmdShow parameter as its nCmdShow parameter. Subsequent calls to ShowWindow must use one of the values in the given list, instead of the one specified by the WinMain function's nCmdShow parameter.
As noted in the discussion of the nCmdShow parameter, the nCmdShow value is ignored in the first call to ShowWindow if the program that launched the application specifies startup information in the STARTUPINFO structure. In this case, ShowWindow uses the information specified in the STARTUPINFO structure to show the window. On subsequent calls, the application must call ShowWindow with nCmdShow set to SW_SHOWDEFAULT to use the startup information provided by the program that launched the application. For example, Program Manager specifies that applications start with a minimized main window. This behavior is designed for the following situations: ?Applications create their main window by calling CreateWindow with the WS_VISIBLE flag set.
?Applications create their main window by calling CreateWindow with the WS_VISIBLE flag cleared, and later call ShowWindow with the SW_SHOW flag set to make it visible. See AlsoCreateProcess, CreateWindow, ShowOwnedPopups, STARTUPINFO, WinMain
子窗体:=NIL;
Show时动态创建
在你关闭一个子窗体的时候,他要消失或释放,这个看你怎么处理
但是当用户再点击按纽要显示这个窗体时候
如果子窗体被释放要重新创建并显示
如果子窗体未被释放要显示在最前面现在我要做一个子窗体类
让其他的子窗体都从我这个类继承出去
而不是TFORM
谢谢各位关注特将代码上传,供大家观看unit fChildForm;interface
uses Forms,fMenuAboutForm,Menus,fIAddDeleteMenu,fIIUD,Dialogs,messages,fINextPrev;type
TChildForm = class(TForm,IIUD)
private
state:integer;
lastLeft:integer;
lastTop:integer;
lastWidth:integer;
lastHeight:integer;
public
friendMenuItem : TMenuItem;
parent : IAddDeleteMenu;
constructor create(var theParent :IAddDeleteMenu);
destructor destroy(); procedure notify(Sender: TObject);virtual;
procedure closeOperation(Sender: TObject; var Action: TCloseAction);virtual;
procedure addVO(); virtual;
procedure updateVO(); virtual;
procedure deleteVO(); virtual; procedure moveNext(); virtual;
procedure movePrev(); virtual; procedure WndProc(var message:Tmessage);override;end;
implementationprocedure TChildForm.WndProc(var message:TMessage);
begin if (message.Msg = WM_SYSCOMMAND) and ((message.WParam = 61488) or (message.WParam = 61490)) then
begin
if state = 0 then //原壮
begin
//存储原尺寸
lastLeft := self.Left;
lastTop := self.Top;
lastWidth := self.Width;
lastHeight := self.Height;
//设置最大尺寸
self.Width := parent.getWorkWidth ;
self.Height := parent.getWorkHeight ;
self.Left := 0;
self.Top := 0;
state := 1;//状态为最大化
end
else
begin
self.Left := lastLeft;
self.Top := lastTop;
self.Width := lastWidth;
self.Height := lastHeight;
state := 0;//状态为原态
end;
end
else
inherited WndProc(message);
end;
action:=free
子窗体:=nil
这个问题我用单例模式已经解决了
unit fSubject;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, dxtrprds, Grids, DBGridEh ,
Menus, dxmdaset, StdCtrls,fChildForm,fIAddDeleteMenu,fSubjectVO, RzPanel,
fDataModule, DBActns, ActnList;type
TSubjectSetForm = class(TChildForm)
ctlDBGridEh: TDBGridEh;
DataSource: TDataSource;
Label1: TLabel;
RzPanel1: TRzPanel;
ADOQuery: TADOQuery;
procedure FormCreate(Sender: TObject);
class function getInstance(var theParent :IAddDeleteMenu):TSubjectSetForm;
private
constructor create(var theParent :IAddDeleteMenu);
{ Private declarations }
public
procedure closeOperation(Sender: TObject; var Action: TCloseAction);override;
destructor destroy(); procedure addVO(); override;
procedure updateVO(); override;
procedure deleteVO(); override; procedure moveNext(); override;
procedure movePrev(); override;
{ Public declarations }
end;
var subjectSetForm : TSubjectSetForm;
implementation
uses fAddUpdateSubjectForm,fSubjectDAO;{$R *.dfm}procedure TSubjectSetForm.moveNext();
begin
if self.ADOQuery.RecordCount >0 then
begin
ADOQuery.Next ;
if ADOQuery.Eof then
ADOQuery.First;
end;
end;procedure TSubjectSetForm.movePrev();
begin
if self.ADOQuery.RecordCount >0 then
begin
ADOQuery.Prior ;
if ADOQuery.Bof then
ADOQuery.Last ; end;
end;class function TSubjectSetForm.getInstance(var theParent :IAddDeleteMenu):TSubjectSetForm;
begin
if subjectSetForm = nil then
subjectSetForm := create(theParent);
Result := subjectSetForm;end;procedure TSubjectSetForm.closeOperation(Sender: TObject; var Action: TCloseAction);
begin
subjectSetForm := nil;
inherited;
end;constructor TSubjectSetForm.create(var theParent : IAddDeleteMenu);
begin
inherited create(theParent);
subjectSetForm := self;
ADOQuery.Connection := ZDataModule.sqlConnection;
ADOQuery.SQL.Text := 'select subject_id ,memo from subject';
ADOQuery.Active := true;
end;destructor TSubjectSetForm.destroy();
begin
inherited;
end;
procedure TSubjectSetForm.addVO();
var subjectSetForm:TAddUpdateSubject;
begin
subjectSetForm := TAddUpdateSubject.create();
subjectSetForm.ShowModal;
ADOQuery.Close;
ADOQuery.Open;
end;procedure TSubjectSetForm.updateVO();
var subjectVO:TSubjectVO;
var subjectEditForm:TAddUpdateSubject;
begin if self.ADOQuery.RecordCount >0 then
begin
subjectVO := TSubjectVO.Create();
subjectVO.setSubjectID(ctlDBGridEh.Fields[0].AsInteger );
subjectVO.setMemo(ctlDBGridEh.Fields[1].AsString);
subjectEditForm := TAddUpdateSubject.create(subjectVO);
subjectEditForm.ShowModal;
ADOQuery.Close;
ADOQuery.Open;
subjectVO.Free;
end;end;procedure TSubjectSetForm.deleteVO();
var subject_id :Integer;
begin
if self.ADOQuery.RecordCount >0 then
begin
if application.MessageBox('确定删除指定的科目吗?','删除确认',MB_OKCANCEL) = IDCANCEL THEN
exit;
subject_id := ctlDBGridEh.Fields[0].AsInteger;
ZDataModule.SubjectDAO.deleteSubjectVO(subject_id);
ADOQuery.Close;
ADOQuery.Open;
end;
end;procedure TSubjectSetForm.FormCreate(Sender: TObject);
begin
ADOQuery.Active := true;
end;end.