Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ej52_ToolBarIncrustada
- Ejemplo de como poner una toolbar junto con Coolbar */
- #include <radc++.h>
- Form form1("Cool Bar con Toolbar - RAD C++ Ejemplo");
- //create a coolbar
- CoolBar cool(AUTO_ID,form1);
- /*
- NOTE:
- If you need to add a toolbar to a coolbar control, you will have to follow:
- 1.first we create a new form with no style
- 2.then create a toolbar and add to the newly created form
- 3.then add this new form to coolbar
- */
- //Create another form with no style, we will add toolbar to this form
- Form form2("",0,0,200,40,RCP_NONE,true,true,false,false,false,form1,true);
- //create toolbar as child of form2 which has no borders and style
- ToolBar tools(AUTO_ID,form2);
- //create toolbar button objects to track clicks
- ToolBarItem btn_exit, btn_about;
- //one more object for coolbar
- Track trk(AUTO_ID,0,0,100,20,form1,30);
- //main form procedure
- FormProcedure mproc(FormProcArgs);
- //procedure for the child form containing toolbar
- FormProcedure cproc(FormProcArgs);
- rad_main()
- form1.procedure = mproc;
- form2.procedure = cproc;
- //create iconlist for toolbar
- IconList icl(RCP_SMALL);
- //add some icons to icon list
- icl.add(Icon::Icon(IDI_APPLICATION));
- icl.add(Icon::Icon(IDI_EXCLAMATION));
- icl.add(Icon::Icon(IDI_HAND));
- icl.add(Icon::Icon(IDI_QUESTION));
- //attach iconlist with toolbar
- tools.setIconList(icl);
- //show text with icons
- tools.captions=true;
- //don't push icons to next line when not enough space
- tools.wrapable=false; //test compile after removing this line and decrease form width
- //add buttons to toolbar
- tools.add("Item 1",0,AUTO_ID); //second argument is icon id in iconlist
- tools.add("Item 2",1,AUTO_ID);
- btn_exit =tools.add("Salida" ,2,AUTO_ID);
- btn_about=tools.add("Acerca" ,3,AUTO_ID);
- //add the form2 which had not style, to coolbar so that toolabr remains in place properly
- cool.add("",form2);
- //add track to coolbar
- cool.add("",trk);
- rad_end()
- //implementation of forms' procedures
- FormProcedure cproc(FormProcArgs) {
- //forward toolbar commands to form1 so that it can take action
- FORWARD_COMMANDS(form1);
- //adjust toolbar properly when form is resized
- ON_RESIZE()
- tools.adjust();
- return 0;
- }
- FormProcedure mproc(FormProcArgs) {
- ON_CLOSE() Application.close();
- ON_COMMAND_BY(btn_exit)
- Application.close();
- ON_COMMAND_BY(btn_about)
- form1.infoBox("RAD C++ Coolbar y Toolbar Ejemplo.");
- //adjust coolbar properly when form is resized
- ON_RESIZE()
- cool.adjust();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement