* * *

Recent Posts

Pages: [1] 2 3 ... 10
General / Re: Can someone recommend the best RTF component
« Last post by BeniBela on Today at 08:54:15 pm »
I can't see a good RTF component for lazarus - can anyone
suggest the best one to use.

Mac OS X / Re: TTrayIcon, memory leak
« Last post by Hansaplast on Today at 08:48:55 pm »
Sorry for the late response, but you might be on to something.
I use the Tray Icon in one of my Mac applications and the used memory definitely seems to be increasing - just not sure if Tray Icon is causing this.
I've never worked with HeapTrc, and hint on how to work with that?
General / Re: Dynamically change button properties with loops
« Last post by howardpc on Today at 06:45:50 pm »
Code: Pascal  [Select]
  1.     tbutton(findcomponent(btnNameID+IntToStr(counterBtn))).font.style:=[];

But, there is a way to "refine" this search to make it quicker?

FindComponent relies on a string comparison of button names, so will be slow for a form with scores of buttons.
Since you know in advance what buttons you have, you can list the ones of font-change interest (as  RAW says) to do a more instantaneous lookup.

As an example: create a new project, generate an OnCreate handler for the main form, and complete the code as follows:
Code: Pascal  [Select]
  1. unit Unit1;
  3. {$mode objfpc}{$H+}
  5. interface
  7. uses
  8.   Classes, SysUtils, Forms, Graphics, StdCtrls, ExtCtrls;
  10. type
  11.   TButtonArray = array[1..5] of TButton;
  13.   TForm1 = class(TForm)
  14.     procedure FormCreate(Sender: TObject);
  15.   private
  16.     CBtnArray,
  17.     DBtnArray,
  18.     JBtnArray: TButtonArray;
  19.     BtnGroupRG: TRadioGroup;
  20.     EmboldenCB: TCheckBox;
  21.     procedure BtnGroupRGSelectionChange(Sender: TObject);
  22.     procedure CreateButtons;
  23.     procedure CreateRadioGroup;
  24.     procedure CreateCheckBox;
  25.     procedure ButtonGroupEmbolden(aGroup: Integer);
  26.     procedure EmboldenCBChange(Sender: TObject);
  27.   end;
  29. var
  30.   Form1: TForm1;
  32. implementation
  34. {$R *.lfm}
  36. procedure TForm1.FormCreate(Sender: TObject);
  37. begin
  38.   SetInitialBounds(0, 0, 670, 210);
  39.   Caption:='Fast button access demo';
  40.   CreateButtons;
  41.   CreateRadioGroup;
  42.   CreateCheckBox;
  43. end;
  45. procedure TForm1.CreateButtons;
  46. var
  47.   c: Char;
  48.   i: Integer;
  49.   btn: TButton;
  51.   function CreateButton: TButton;
  52.   var
  53.     s: String;
  54.   begin
  55.     Result:=TButton.Create(Self);
  56.     with Result do begin
  57.       Str(i, s);
  58.       Name:=c + s;
  59.       Left:=10 + (Ord(c) - Ord('C')) * 80;
  60.       Top:=10 + Pred(i) * 30;
  61.     end;
  62.   end;
  64. begin
  65.   for c:='C' to 'J' do
  66.     for i:=Low(TButtonArray) to High(TButtonArray) do begin
  67.       btn:=CreateButton;
  68.       case c of
  69.         'C': CBtnArray[i]:=btn;
  70.         'D': DBtnArray[i]:=btn;
  71.         'J': JBtnArray[i]:=btn;
  72.       end;
  73.       btn.Parent:=Self;
  74.     end;
  75. end;
  77. procedure TForm1.BtnGroupRGSelectionChange(Sender: TObject);
  78. var
  79.   rg: TRadioGroup absolute Sender;
  80. begin
  81.   if Sender is TRadioGroup then
  82.     ButtonGroupEmbolden(rg.ItemIndex);
  83. end;
  85. procedure TForm1.CreateRadioGroup;
  86. begin
  87.   BtnGroupRG:=TRadioGroup.Create(Self);
  88.   with BtnGroupRG do begin
  89.     Caption:='Select button group';
  90.     Items.CommaText:='"Group C","Group D","Group J"';
  91.     Columns:=3;
  92.     AutoSize:=True;
  93.     SetInitialBounds(10, 165, 80, 40);
  94.     OnSelectionChanged:=@BtnGroupRGSelectionChange;
  95.     Parent:=Self;
  96.   end;
  97. end;
  99. procedure TForm1.CreateCheckBox;
  100. begin
  101.   EmboldenCB:=TCheckBox.Create(Self);
  102.   with EmboldenCB do begin
  103.     Caption:='Embolden button group (set to normal if unchecked)';
  104.     SetInitialBounds(240, 182, 2, 2);
  105.     AutoSize:=True;
  106.     Checked:=True;
  107.     OnChange:=@EmboldenCBChange;
  108.     Parent:=Self;
  109.   end;
  110. end;
  112. procedure TForm1.ButtonGroupEmbolden(aGroup: Integer);
  113. var
  114.   ba: TButtonArray;
  115.   b: TButton;
  116. begin
  117.   if not aGroup in [0..2] then
  118.     Exit;
  119.   case aGroup of
  120.     0: ba:=CBtnArray;
  121.     1: ba:=DBtnArray;
  122.     2: ba:=JBtnArray;
  123.   end;
  124.   for b in ba do
  125.     case EmboldenCB.Checked of
  126.       False: b.Font.Style:=[];
  127.       True:  b.Font.Style:=[fsBold];
  128.     end;
  129. end;
  131. procedure TForm1.EmboldenCBChange(Sender: TObject);
  132. begin
  133.   if (Sender is TCheckBox) and (BtnGroupRG.ItemIndex > -1) then
  134.       ButtonGroupEmbolden(BtnGroupRG.ItemIndex);
  135. end;
  137. end.
General / Re: fpspreadsheetgrid
« Last post by wp on Today at 06:23:07 pm »
This is a rarely-used way of loading a workbook, and therefore this bug remained unnoticed. Should be fixed in r6076. If you don't use the trunk version of fpspreadsheet you can fix it easily in your local version: Open fpspreadsheet.pas, find procedure TsWorkbook.ReadFromStream (the second overloaded version). Immediately after "finally" add the line "FReadWriteFlag := rwfNormal;"; the entire procedure should be like this:

Code: Pascal  [Select]
  1. procedure TsWorkbook.ReadFromStream(AStream: TStream; AFormatID: TsSpreadFormatID;
  2.   APassword: String = ''; AParams: TsStreamParams = []);
  3. var
  4.   AReader: TsBasicSpreadReader;
  5.   ok: Boolean;
  6. begin
  7.   AReader := CreateSpreadReader(self, AFormatID);
  8.   try
  9.     PrepareBeforeReading;
  10.     FReadWriteFlag := rwfRead;
  11.     ok := false;
  12.     inc(FLockCount);
  13.     try
  14.       AStream.Position := 0;
  15.       AReader.ReadFromStream(AStream, APassword, AParams);
  16.       ok := true;
  17.       UpdateCaches;
  18.       if (boAutoCalc in Options) then
  19.         Recalc;
  20.       FFormatID := AFormatID;
  21.     finally
  22.       FReadWriteFlag := rwfNormal;   // <---- NEW
  23.       dec(FLockCount);
  24.       if ok and Assigned(FOnOpenWorkbook) then
  25.         FOnOpenWorkbook(self);  
  26.     end;
  27.   finally
  28.     AReader.Free;
  29.   end;
  30. end;

A comment on your code referring to format sfExcelXML. Are you sure that this is the correct format? Or do you mean then xlsx file format. sfExcelXML is a very rarely xml format introduced by Microsoft during the Office2003 times, xlsx was created later for Office2007, its fpspreadsheet identifier is sfOOXML. sfExcelXML was added to fpspreadsheet for testing its extendability to other formats; currently it is only supported for writing.
Eventually I suceeded in installing fpc3.
The thing seems to be that it now supports long file names (LFN).
The installation procedure checks for support of LFN by the OS it is installed on.
As my MSDOS 6.0 does not support LFN, it is switched off. However, this also means that by default some required parts are not installed, like the CRT unit. As a result I could not compile my program.
Only after setting the list of parts to be installed such that required parts are installed as well, the compilation with fpc3 on MSDOS 6.0 does work.

The next point is that, due to LFN support and/or UniCode support, the internal structure of TextRec has been changed. This causes a compilation error, since I do access its field "Name" with the StrIComp() function, which expects an array of char, but meets an array of widechar.
When all this has been solved (and anything else that may pop up) I may check for the compiler behaviour with respect to the original problem :-)

Until then, thank you for your support.
General / Re: Can someone recommend the best RTF component
« Last post by JuhaManninen on Today at 06:15:06 pm »
Sorry that method of software distribution is unacceptable here.
Why is it unacceptable?
General / Re: Dynamically change button properties with loops
« Last post by RAW on Today at 06:03:16 pm »
Why don't you use a Button-Array or a Button-List? Isn't that a lot easier if you need to access these buttons regularly?
Third party / Re: TWebBrowser control for LCL Cocoa
« Last post by Soner A. on Today at 06:00:43 pm »
I get it but I have now another problem.
I continue here http://forum.lazarus.freepascal.org/index.php/topic,39057.0.html
LCL / How to resolve WMSize loop error?
« Last post by Soner A. on Today at 05:58:40 pm »
I create Internet-Explorer part for Phils TWebbrowser control http://forum.lazarus.freepascal.org/index.php/topic,37458.0.html.

Now I can create and show html-page, but I get WMSize loop error.
Does anyone know how to resolve this error?

General / Re: Dynamically change button properties with loops
« Last post by douglas.cast on Today at 05:09:57 pm »
Both ways work like a charm, thanks very much.

In the end I used Josh line, considering that I don't have any need to a nil verification (It will always exist at least one button in the form), I'll use a "try" later to fix any process problem.

Code: Pascal  [Select]
  1.     tbutton(findcomponent(btnNameID+IntToStr(counterBtn))).font.style:=[];

But, there is a way to "refine" this search to make it quicker? I'm using a panel to store the buttons, there is a:

Code: [Select]
   tbutton ( findcomponent "inside panel / range " ( btnNameID+IntToStr(counterBtn))).font.style:=[];

Maybe with Pareting or something like it or a with (inside) panel do search

Code: Pascal  [Select]
  1.    with panel do
  2.       tbutton(findcomponent(btnNameID+IntToStr(counterBtn))).font.style:=[];
  3.    end;

I'm just asking because the application have a lot of buttons, 5 searchs on a 100 (or more) buttons list, will be a lot of searching. I also need another awsers before call this procedure, with a lot of buttons I'll probably increase the response time.

Once more, Thanks
Pages: [1] 2 3 ... 10


Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus