Advertisement
idsystems

CPP_RAD_Ejercicio23

May 19th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. /* ej23_TanControl
  2. Para mostrar el uso del control Tab */
  3. #include <radc++.h>
  4.  
  5. Form form1("Tab Control - RAD C++ Ejemplo");
  6. //create new tab control
  7. Tab         t("",AUTO_ID,0,0,form1.cwidth,form1.cheight,form1);
  8. //add 3 pages to tab control
  9. TabPage     p1=t.addPage("Pag1");
  10. TabPage     p2=t.addPage("Pag2");
  11. TabPage     p3=t.addPage("Pag3");
  12.  
  13. //4 controls to attach with tab pages
  14.  
  15. Form form2("Hijo de Tab",0,0,100,100,RCP_NONE,true,true,false,false,false,form1,true,0);
  16.  
  17. Button      b1 ("Boton para tab1",              AUTO_ID,0,10,100,50,form2);
  18. TableView   b12("1",                            AUTO_ID,0,70,100,100,form2);
  19. Button      b2("para tab 2",                        AUTO_ID,0,0,10,10,form1);
  20. RichTextBox b3 ("Soy tab 3 anclado a objeto",   AUTO_ID,0,0,10,10,form1);
  21.  
  22. FormProcedure childformproc(FormProcArgs) {
  23.  
  24.     ON_RESIZE() {
  25.         b1.fitToWidth();
  26.         b12.fitToWidth();
  27.     }
  28.     ON_COMMAND_BY(b1) form1.msgBox("btn1");
  29.     ON_COMMAND_BY(b12) form1.msgBox("btn2");
  30.     return 0;
  31. }
  32.  
  33. FormProcedure proc(FormProcArgs) {
  34.     ON_CLOSE() Application.close();
  35.  
  36.     //now check of p1 and p2 of tabcontrol 't' are selected
  37.     //Even if not processing events, just put semi collin after,
  38.     //but make sure to write them down to show attached Objects properly
  39.     ON_TAB_SELECT(t,p1); //t is tab control p1 is tab page
  40.     ON_TAB_SELECT(t,p2);
  41.     ON_TAB_SELECT(t,p3);
  42.    
  43.     ON_RESIZE() { //when form is resized
  44.         //resize tab control and fit to entire form area
  45.         t.fitExact();
  46.        
  47.         //also resize and adjust attached objects of pages, each individually
  48.         p1.adjust();
  49.         p2.adjust();
  50.         p3.adjust();
  51.     }
  52.     return 0;
  53. }
  54.  
  55. rad_main()
  56.     form1.procedure = proc;
  57.     form2.procedure = childformproc;
  58.  
  59.     b12.addColumn("Nombre");
  60.     b12.addColumn("Email");
  61.     b12.addColumn("Edad");
  62.    
  63.     b12.addRow("abcd");
  64.     b12.addRow("abcd");
  65.     b12.addRow("abcd");
  66.     b12.addRow("abcd");
  67.    
  68.     p1.attachObject(form2);
  69.     p2.attachObject(b2);
  70.     p3.attachObject(b3);
  71.    
  72.     //since p1 is first tab, so it's contents need to be adjusted manually (just once)
  73.     p1.adjust();
  74. rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement