/packages/xforms/examples/longlabel.pp

https://github.com/slibre/freepascal · Puppet · 58 lines · 46 code · 12 blank · 0 comment · 0 complexity · 42526e058ef4fd5ef58f0641ac501053 MD5 · raw file

  1. { Demo of the Use of a very long label }
  2. program longlabel;
  3. uses xforms;
  4. Const
  5. label1 : pchar = 'This demo shows the use of some very'#10+
  6. 'long labels. The dynamic storage allocation'#10+
  7. 'for such long labels should guarantee that'#10+
  8. 'all of this works without any problem.';
  9. { This shows a funny bug in FPK 0.9.1 :) MVC.}
  10. label2 : pchar ='This is the second string that should again'#10+
  11. 'be a bit larger such that a new, larger amount'#10+
  12. 'of storage has to be allocated for the label.'#10+
  13. 'This is of course no problem. By the way,'#10+
  14. 'dynamic allocation of storage saves a lot'#10+
  15. 'of memory because for most objects the label'#10+
  16. 'is much shorter than the 64 bytes that were'#10+
  17. 'allocated for it in the previous version of'#10+
  18. 'the Forms Library';
  19. label3 : pchar ='And now back to the first one:'#10#10+
  20. 'This demo shows the use of some very'#10+
  21. 'long labels. The dynamic storage allocation'#10+
  22. 'for such long labels should guarantee that'#10+
  23. 'all of this works without any problem.';
  24. var
  25. form : PFL_FORM;
  26. strobj, but : PFL_OBJECT;
  27. begin
  28. fl_initialize(@argc, argv, 'FormDemo', nil, 0);
  29. form := fl_bgn_form(FL_UP_BOX,400,300);
  30. strobj := fl_add_box(FL_DOWN_BOX,10,10,380,240,'Press Next');
  31. fl_set_object_lsize(strobj,FL_NORMAL_SIZE);
  32. but := fl_add_button(FL_NORMAL_BUTTON,160,260,80,30,'Next');
  33. fl_end_form();
  34. fl_set_form_hotobject(form, but);
  35. fl_show_form(form,FL_PLACE_HOTSPOT,FL_TRANSIENT,nil);
  36. fl_do_forms();
  37. fl_set_object_label(strobj,label1);
  38. fl_do_forms();
  39. fl_set_object_label(strobj,label2);
  40. fl_do_forms();
  41. fl_set_object_label(strobj, 'Now we turn to a short label');
  42. fl_do_forms();
  43. fl_set_object_label(strobj,label3);
  44. fl_set_object_label(but,'Quit');
  45. fl_do_forms();
  46. end.