用代碼控制程式最小化和恢復

版权声明:原创文章转载时请附上原文链接 https://blog.csdn.net/aniven/article/details/556265

1.發送一條Windows消息到主視窗的Handle屬性或 Application->Handle:

    SendMessage(Application->Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);//最小化
    SendMessage(Application->Handle,WM_SYSCOMMAND,SC_RESTORE,0);//恢復

2.調用 ShowWindow API 函數。 你必需發送Application物件控制碼到ShowWindow函數。如果你發送到ShowWindow函數的句柄是主窗口,那么主窗口將最小化到桌面(desktop)而不是任務欄(taskbar)。

    ShowWindow(Application->Handle,SW_MINIMIZE);
    ShowWindow(Application->Handle,SW_RESTORE);

3.調用Application對象的Minimize或Restore函數

    Application->Minimize();
    Application->Restore();

阅读更多

關於代碼復用,問一下這兩段代碼怎麼才能復用

11-09

rnrn我一有兩個QR報表的頁面,初始基本代碼如下:我想知道它能不能復用rnprocedure TprodDayReportFrm1.ReportPrint(node: TTreeNode; total: boolean);rnbeginrn if node = nil then exit;rn case rg1.ItemIndex ofrn 0:rn with TdayProdAcceptRep.Create(nil) dorn beginrn seldate.Caption := formatdatetime('從 yyyy年mm月dd日', ds.Date) +rn formatdatetime(' 到 yyyy年mm月dd日', de.Date);rn pridate.Caption :=rn formatdatetime('打印日期:yyyy-mm-dd HH:mm:ss', getdbdatetime);rn adoquery1.Close;rn ADOQuery1.Parameters.ParamByName('sd').Value := ds.Date;rn ADOQuery1.Parameters.ParamByName('ed').Value := de.Date;rn ADOQuery1.Parameters.ParamByName('prodid').Value := mstr(node.Text);rn ADOQuery1.Parameters.ParamByName('level').Value := node.Level;rn ADOQuery1.Parameters.ParamByName('total').Value := total;rn if total thenrn beginrn //QRGroup1.Expression := '';rn QRBand1.Free;rn end;rn ADOQuery1.Open;rn QuickRep1.Prepare;rn QuickRep1.Preview;rn ADOQuery1.Close;rn close;rn free;rn end;rn 1:rn with TdayProdDrawRep.Create(nil) dorn beginrn seldate.Caption := formatdatetime('從 yyyy年mm月dd日', ds.Date) +rn formatdatetime(' 到 yyyy年mm月dd日', de.Date);rn pridate.Caption :=rn formatdatetime('打印日期:yyyy-mm-dd HH:mm:ss', getdbdatetime);rn adoquery1.Close;rn ADOQuery1.Parameters.ParamByName('sd').Value := ds.Date;rn ADOQuery1.Parameters.ParamByName('ed').Value := de.Date;rn ADOQuery1.Parameters.ParamByName('prodid').Value := mstr(node.Text);rn ADOQuery1.Parameters.ParamByName('level').Value := node.Level;rn ADOQuery1.Parameters.ParamByName('total').Value := total;rn if total thenrn beginrn //QRGroup1.Expression := '';rn QRBand1.Free;rn end;rn ADOQuery1.Open;rn QuickRep1.Prepare;rn QuickRep1.Preview;rn ADOQuery1.Close;rn close;rn free;rn end;rn 2: ;rn end;rnend;rn

没有更多推荐了,返回首页