1 #include "Layouts.h"
2 
3 #define LAYOUTFILE <Layouts/layoutfile2.lay> // Layouts will be local to main.cpp
4 #include <CtrlCore/lay.h>
5 
FirstTabDlg()6 FirstTabDlg::FirstTabDlg() // Constructor needs to be in .cpp
7 {
8 	CtrlLayout(*this); // Places widgets into positions
9 }
10 
11 struct SecondTabDlg : WithSecondTabLayout<ParentCtrl> { // Local to main.cpp
12 	typedef SecondTabDlg CLASSNAME;
13 	SecondTabDlg();
14 };
15 
SecondTabDlg()16 SecondTabDlg::SecondTabDlg()
17 {
18 	CtrlLayout(*this);
19 }
20 
21 struct MainDlg : WithMainLayout<TopWindow> { // Local to main.cpp
22 	typedef MainDlg CLASSNAME;
23 
24 	FirstTabDlg  tab1;
25 	SecondTabDlg tab2;
26 
27 	void DoDialog();
28 
29 	MainDlg();
30 };
31 
DoDialog()32 void MainDlg::DoDialog()
33 {
34 	WithDialogLayout<TopWindow> dlg; // Variant without class, good for simple modal dialogs
35 	CtrlLayoutOK(dlg, "Dialog"); // OK means dialog has normal 'ok' button that needs setting up
36 	dlg.info = String().Cat() << "Today is: " << GetSysDate();
37 	if(dlg.Execute() != IDOK)
38 		return;
39 }
40 
MainDlg()41 MainDlg::MainDlg()
42 {
43 	CtrlLayout(*this, "Layouts");
44 	tabs.Add(tab1.SizePos(), "Tab1"); // SizePos() means dialog fills the whole are of tab
45 	tabs.Add(tab2.SizePos(), "Tab2");
46 
47 	tab1.dialog <<= THISBACK(DoDialog); // When pushing 'dialog' button, DoDialog is invoked
48 }
49 
50 GUI_APP_MAIN
51 {
52 	MainDlg().Run();
53 }
54