Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <radc++.h>
- /*
- It is suggested that you try understanding Simple Form and Menus examples first
- and then get to this example.
- NOTE: This program may crash if file size is larger than 65535 (65.5 kb), becuase
- richtextbox by default accomodates 65535 bytes. Use RichTextBox::setLimit() to accomodate
- number of characters.
- */
- Form form1("Ejemplo Mini NotePad - RAD C++ Ejemplo");
- Menu menu(form1);
- MenuItem __File,__Open,__Save,__Exit,__Help,__About;
- RichTextBox txt("", AUTO_ID, 0, 0, 0, 0, form1);
- FormProcedure form1Proc(FormProcArgs) {
- ON_CLOSE() Application.close();
- ON_COMMAND_BY(__Exit) Application.close();
- ON_COMMAND_BY(__About)
- form1.infoBox("Ejemplo Mini NotePad - RAD C++ 1.2\r\n\r\nby www.radcpp.com");
- ON_COMMAND_BY (__Open) {
- if(form1.open()) { //yes user selected file
- BinaryData bin;
- bin.loadFile(form1.fileName); //load selected file
- txt.text = bin.c_str(); //get NULL terminated string only
- bin.clear(); //release the memory
- form1.caption = form1.fileName;
- }
- }
- ON_COMMAND_BY (__Save) {
- if(form1.save()) { //yes user selected file to save
- BinaryData bin;
- String data = txt.text;
- bin.add((UCHAR *)data.c_str(),data.length); //get NULL terminated string and save to file
- bin.writeFile(form1.fileName);
- bin.clear(); //release the memory
- form1.caption = form1.fileName;
- }
- }
- ON_RESIZE() txt.fitExact();
- return 0;
- }
- rad_main()
- form1.procedure = form1Proc;
- txt.fitExact();
- //main menus
- __File = menu.add("&Archivo");
- __Help = menu.add("A&yuda");
- //sub-menus tracked
- __Open = __File.add("&Abrir",AUTO_ID);
- __Save = __File.add("&Guardar",AUTO_ID);
- __File.addSeparator();
- __Exit = __File.add("&Salida",AUTO_ID);
- __About = __Help.add("&Acerca de...",AUTO_ID);
- rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement