bangnaga

Delphi MDI ChildForm (2 Cara)

Sep 7th, 2015
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type
  2.   TForm1 = class(TdxRibbonForm)
  3.     dxRibbon1Tab1: TdxRibbonTab;
  4.     dxRibbon1: TdxRibbon;
  5.     dxSkinController1: TdxSkinController;
  6.     dxBarManager1: TdxBarManager;
  7.     dxBarManager1Bar1: TdxBar;
  8.     dxBarButton1: TdxBarButton;
  9.     dxBarButton2: TdxBarButton;
  10.     dxBarButton3: TdxBarButton;
  11.     procedure dxBarButton1Click(Sender: TObject);
  12.     procedure dxBarButton2Click(Sender: TObject);
  13.     procedure dxBarButton3Click(Sender: TObject);
  14.   private
  15.    procedure  SwitchToChild(AMain, AChild: TForm);
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26.  
  27. {$R *.dfm}
  28.  
  29. procedure TForm1.SwitchToChild(AMain, AChild: TForm);
  30. begin
  31.   SendMessage(AMain.ClientHandle, WM_SETREDRAW, 0, 0);
  32.   AChild.Show;
  33.   SendMessage(AMain.ClientHandle, WM_SETREDRAW, 1, 0);
  34.   RedrawWindow(AMain.ClientHandle, nil, 0,
  35.     RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_UPDATENOW);
  36. end;
  37.  
  38.  
  39. procedure TForm1.dxBarButton1Click(Sender: TObject);
  40. begin
  41.     SwitchToChild(Self, ChildForm1);
  42. end;
  43.  
  44. procedure TForm1.dxBarButton2Click(Sender: TObject);
  45. begin
  46.     SwitchToChild(Self, ChildForm2);
  47. end;
  48.  
  49. procedure TForm1.dxBarButton3Click(Sender: TObject);
  50. begin
  51.     SwitchToChild(Self, ChildForm3);
  52. end;
  53.  
  54.  
  55. //Cara Ke II
  56. procedure TFrmMenuUtama.dxBarLargeButton52Click(Sender: TObject);
  57. begin
  58.  
  59.   try
  60.     if application.findcomponent('FrmBroBarang')=nil then
  61.     begin
  62.       SendMessage(Application.MainForm.ClientHandle,WM_SETREDRAW,0,0);
  63.       FrmBroBarang := TFrmBroBarang.Create(application);
  64.       FrmBroBarang.FormStyle:=fsMDIChild;
  65.       FrmBroBarang.Show;
  66.     end
  67.     else
  68.     begin
  69.       FrmBroBarang.BringToFront;
  70.     end;
  71.   finally
  72.     SendMessage(Application.MainForm.ClientHandle,WM_SETREDRAW,1,0);
  73.     RedrawWindow(Application.MainForm.ClientHandle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_NOINTERNALPAINT);
  74.   end;
  75. end;
  76.  
  77.  
  78. end.
RAW Paste Data