[C#]
FontStyle fs =labelMSG.Font.Style;
FontFamily fm = new FontFamily(labelMSG.Font.Name);
Font f = new Font(fm, fontsize, fs);
labelMSG.Font = f;
[/C#]
標籤: 動態
Delphi 動態呼叫ODBC連結對話框
Delphi 動態取得fastreport下物件
在Delphi下如何取得fastreport的元件及做值的修改?
[pascal]
var i:integer;
begin
frxreport1.LoadFromFile(‘test.fr3’);
frxreport1.Report.PrintOptions.Printer := ‘Adobe PDF’;
for i:=0 to frxreport1.ComponentCount -1 do begin //取得報表內所有物件
if frxreport1.Components[i].ClassName = ‘TfrxMemoView’ then begin // 找到TfrxMemoView
//ExtractFileName(frxreport1.FileName); 取得目前報表名稱
//frxreport1.Components[i].Name; 取得元件名稱
Tfrxmemoview(frxreport1.Components[i]).Text := ‘hello world’;
end;
end;
frxreport1.Report.PrintOptions.ShowDialog := false; // 不顯示對話框
frxreport1.Report.ShowProgress := False; // 不顯示列印進度
frxReport1.PrintOptions.Copies:=3; // 列印份數
frxreport1.Report.PrepareReport(true);
frxreport1.Print;
// 線上編輯報表
// frxreport1.DesignReport;
end;
[/pascal]
Delphi執行時拖拉、改變元件大小
應要求在程式執行時還要可以拉拖、改變元件大家~
分享一個不錯的函數
[pascal]
procedure DragResizeControl(WinControl: TControl; Shift: TShiftState;X, Y, Precision: integer);
var
SC_MANIPULATE: Word;
begin
if (X<=Precision) and (Y>Precision) and (Y<WinControl.Height-Precision) then begin
SC_MANIPULATE := $F001;
WinControl.Cursor := crSizeWE;
end else if (X>=WinControl.Width-Precision)
and (Y>Precision) and (Y<WinControl.Height-Precision) then begin
SC_MANIPULATE := $F002;
WinControl.Cursor := crSizeWE;
end else if (X>Precision)
and (X<WinControl.Width-Precision) and (Y<=Precision) then begin
SC_MANIPULATE := $F003;
WinControl.Cursor := crSizeNS;
end else if (X>Precision)
and (X<WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then begin
SC_MANIPULATE := $F006;
WinControl.Cursor := crSizeNS;
end else if (X<=Precision) and (Y<=Precision) then begin
SC_MANIPULATE := $F004;
WinControl.Cursor := crSizeNWSE;
end else if (X>=WinControl.Width-Precision) and (Y<=Precision) then begin
SC_MANIPULATE := $F005;
WinControl.Cursor := crSizeNESW ;
end else if (X<=Precision) and (Y>=WinControl.Height-Precision) then begin
SC_MANIPULATE := $F007;
WinControl.Cursor := crSizeNESW;
end else if (X>=WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then begin
SC_MANIPULATE := $F008;
WinControl.Cursor := crSizeNWSE;
end else if (X>5) and (Y>5) and (X<WinControl.Width-5)
and (Y<WinControl.Height-5) then begin
SC_MANIPULATE := $F009;
WinControl.Cursor := crSizeAll;
end else begin
SC_MANIPULATE := $F000;
WinControl.Cursor := crDefault;
end;
if Shift=[ssLeft] then begin
ReleaseCapture;
WinControl.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;
[/pascal]
如用方法很簡單,在元件的MouseMove裡加上
[pascal]
DragResizeControl((Sender as TWinControl),Shift,X,Y,10);
[/pascal]