Recent

Author Topic: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw  (Read 2511 times)

Researching

  • Full Member
  • ***
  • Posts: 121
Good Day!
Have a Tform > TPanel > [ TGroupBox > (TMemo + TCheckbox + TEdit + TButon )]
There are some records in the DB. With different count of fields and different size of text.
Question:
1. (Main?!!) Need to show automatically [TGroupBox> (.....)] for each field in record,
If possible, please step by step.

Sample project in attachment.

2. (less important) need to calculate(??) and set size for TMemo based on text size
3. (less important) need to show scroll bars at TPanel (if possible... ), if the screen is too small (Maybe Add a TScrollBox on a tab??)


// Extra questions:
* How to Link ShellTreeView and ShellListView??
* is it difficult (for NewBie) to change Lazarus IDE interface to MDI ot tabbed?
* [SOLVED] how to handle 500+ char-long string in console application? Dynamic Array of Chars?
use AnsiString. They can have (virtually) unlimited length. You can either declare your strings as AnsiString or use {$H+} to make String mean AnsiString.

Don't let the "Ansi" in the name mislead you; you can use almost any single- and multi-byte character set in AnsiStrings, including UTF 8. Read the documentation.

You may also find these wiki pages useful:
Character and string types : http://wiki.freepascal.org/Character_and_string_types
and FPC Unicode support   : http://wiki.freepascal.org/FPC_Unicode_support

* how to use Console Application for functions testing: test in console use in GUI application
* is there a ready application src to run some compiled console app several times, with different data (sored in txt file) and collect output (in txt file) ?

MDI interface - internal window, (Found in other source than forum )
Code: Pascal  [Select][+][-]
  1. begin
  2.   Form3:= TForm3.Create(Self); //HOWTO: Create form object
  3.   Form1.InsertControl(Form3);  //HOWTO: insert created object inside form
  4.   Form3.Show;                  //HOWTO: draw created object
  5. end;                                                          
  6.  

People! arn't you dissappointed with the whole situation? Hundreds of community members, About 100-300 Professionals, but still many easy questions are not easily solvable neither by wiki neither by forum !!

Really - seems sensible to invest a little effort in improving the general approach to building th forum... OK.. maybe - am wrong about possibility, but seems needed.
Let's say - some kind of extra point system that will lead to more organized forum.
Remember baskets in the shop? Since people have to insert a coin - they put baskets in place THEMSELVES!!

Moderators and Administrators are welcome to ask me questions and discuss solutions. Some thoughts are present.

Sorry if broke someone's mood!
Have a good day!
« Last Edit: November 13, 2018, 01:46:47 pm by Researching »

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #1 on: November 12, 2018, 04:22:56 pm »
Sample project in attachment.

Can you please also provide the sample db?

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #2 on: November 12, 2018, 04:44:30 pm »
* how to handle 500+ char-long string in console application? Dynamic Array of Chars?

This one has a quick answer: use AnsiString. They can have (virtually) unlimited length. You can either declare your strings as AnsiString or use {$H+} to make String mean AnsiString.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Researching

  • Full Member
  • ***
  • Posts: 121
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #3 on: November 12, 2018, 05:30:05 pm »
Provide DB...

It does not matter what the DB is: The wuetion is about:
Code: [Select]
EntArr : Array of Entities;
ArrFormElement : Array of Elements;
foreach of Entity do begin   
   CreateAGroupBox (GroupBox, TMemo, TButton);
   TMemo.text := EntArr[i].text;
   ArrFormElement[i]:=(GroupBox);
   end;

foreach of ArrFormElement[i] do begin
     AddElement (Tform.TPanel; ArrFormElement[i] );
   end;

Procedure   AddElement (Tform.TPanel; ArrFormElement[i] )
begin
   calculate size;
   if SUMofSize > TPanelSize then begin
       show TPanel.Tab.scrollbar.Show;
end;

(Shure this is pseudocode!)


Quote
AnsiString
Yes, but with AnsiString - I can not use UTF-8...
And if use of AnsiString - How to use ciryllic alphabet?
Actually, what was found: LCL provides UTF8( not yet had a try) But this is not for Console Application.
« Last Edit: November 12, 2018, 05:35:07 pm by Researching »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #4 on: November 12, 2018, 06:32:53 pm »
Yes, but with AnsiString - I can not use UTF-8...
And if use of AnsiString - How to use ciryllic alphabet?
Actually, what was found: LCL provides UTF8( not yet had a try) But this is not for Console Application.

Don't let the "Ansi" in the name mislead you; you can use almost any single- and multi-byte character set in AnsiStrings, including UTF 8. Read the documentation.

You may also find these wiki pages useful: Character and string types and FPC Unicode support
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Researching

  • Full Member
  • ***
  • Posts: 121
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #5 on: November 12, 2018, 07:51:35 pm »
Great!
Updated to the head of topic.

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: HowTo: Automatically create Grouped Controls on TForm? Controls Auto Draw
« Reply #6 on: November 13, 2018, 12:18:23 am »
as for the IDE, I believe if you install the anchor docking package you get close to what you want..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018