![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
KOL-CE Form.ControlByName
magi6162 © (2010-01-04 13:31:00)for i:=0 to count do
begin
Self.ControlByName('v' + IntToStr(i)).Hint := 'AAAAA';
i := i +1
end;
Does not recognize ControByName
Help me
thanks
Jon (2010-01-08 15:45:00) [21]You need to add another conditional define: USE_MHTOOLTIP
So now you will have: -dUSE_NAMES -dUSE_MHTOOLTIP
Then rebuild. The correct syntax for tooltips is Hint.Text:
procedure TForm1.Button1Click(Sender: PObj);
var
i: Integer;
c: PObj;
begin
for i := 1 to 20 do
begin
c := Form.FindObj('Label'+Int2Str(i));
if c <> nil then
PControl(c).Hint.Text := 'Label'+Int2Str(i);
end;
MsgOK('Label hints added!');
end;
magi6162 (2010-01-08 15:11:00) [22]Ok!!! great!!!
Now...
v1..vxx: TKOLLabel
for i := 1 to nMesi do
begin
c := Form.FindObj('v' + Int2Str(i)); <--- Error here
if c <> nil then
PControl(c).Hint :='zzz'
end;
fmain.pas(213,19) Error: identifier idents no member "hint"
"Hint" the property I need to store string data relating to the control.
thanks
Jon (2010-01-08 14:41:00) [23]Looks like a bug with Lazarus. In Lazarus IDE do this:
- Menu: Package >> Open loaded package...
- Select: MirrorKOLPackage >> Open...
- Click Compiler Options >> Other
- In Custom optionsadd: -dUSE_NAMES
- Click OK
- Click Compile
- When compile completed, close package window and try again
magi6162 (2010-01-08 10:55:00) [24]I did as you have written, but:
fmain_1.inc(19,17) Error: identifier idents no member "SetName"
thanks for all the help
Дмитрий К (2010-01-05 21:03:00) [25]In Lazarus Project - Compiler options... - Other - Custom options
Add -dUSE_NAMES
magi6162 (2010-01-05 19:57:00) [26]Go to project options and define a new conditional of USE NAMES
In project options where insert USE NAMES?
sorry my bad english
magi6162 (2010-01-05 19:47:00) [27]v1,v2.... are TKOLLabel
magi6162 (2010-01-05 19:32:00) [28]{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit fmain;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TMain }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TMain = class; PMain = TMain; {$ELSE OBJECTS} PMain = ^TMain; {$ENDIF CLASSES/OBJECTS}
TMain = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Form: PControl;
KOLMain: TKOLForm;
KOLProject: TKOLProject;
v1
v2
-
-
-
-
v19
v20
-
-
-
procedure KOLMainFormCreate(Sender: PObj);
private
{ private declarations }
public
{ public declarations }
procedure CaricaDatiCalendario;
end;
var
Main {$IFDEF KOL_MCK} : PMain {$ELSE} : TMain {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewMain( var Result: PMain; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I fmain_1.inc}
{$ENDIF}
{ TMain }
-
-
-
procedure TMain.CaricaDatiCalendario;
var
i,k,x: Integer;
sQuery,sTmp: String;
c:PObj;
begin
-
-
-
for i := 1 to nMesi do
begin
c := Form.FindObj('v' + Int2Str(i)); <--- Error here
if c <> nil then
PControl(c).Text :='zzz'
end;
-
-
-
end;
error in compiling: Error: identifier idents no member "FindObj"
Jon (2010-01-05 18:03:00) [29]You can use design time creation, that is not a problem.
Download this MCK project: http://www.sendspace.com/file/el3izp
Let me know if it makes sense to you.
magi6162 (2010-01-05 16:37:00) [30]I designed the GUI using the controls of the bar KOL.
As I understand I should not use the controls at design time, but
create them at runtime?
Use of controls at design time is not possible in my case?
thanks a lot for the time you've spent.
Jon (2010-01-05 15:44:00) [31]Maybe you didn't understand my previous reply.
Go to project options and define a new conditional of USE NAMES
Here is a test using KOL only (not the MCK):
program Test;
uses KOL;
type
PForm1 = ^TForm1;
TForm1 = object(TObj)
Form,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,V20,Butt on: PControl;
public
procedure ButtonClick(Sender: PObj);
end;
var
Form1: PForm1;
procedure NewForm1(var Result: PForm1; AParent: PControl);
begin
New(Result,Create);
with Result^ do
begin
Form := NewForm(AParent,'Test');
V1 := NewLabel(Form,'v1');
V2 := NewLabel(Form,'v2').PlaceRight;
V3 := NewLabel(Form,'v3').PlaceRight;
V4 := NewLabel(Form,'v4').PlaceRight;
V5 := NewLabel(Form,'v5').PlaceRight;
V6 := NewLabel(Form,'v6').PlaceDown;
V7 := NewLabel(Form,'v7').PlaceRight;
V8 := NewLabel(Form,'v8').PlaceRight;
V9 := NewLabel(Form,'v9').PlaceRight;
V10 := NewLabel(Form,'v10').PlaceRight;
V11 := NewLabel(Form,'v11').PlaceDown;
V12 := NewLabel(Form,'v12').PlaceRight;
V13 := NewLabel(Form,'v13').PlaceRight;
V14 := NewLabel(Form,'v14').PlaceRight;
V15 := NewLabel(Form,'v15').PlaceRight;
V16 := NewLabel(Form,'v16').PlaceDown;
V17 := NewLabel(Form,'v17').PlaceRight;
V18 := NewLabel(Form,'v18').PlaceRight;
V19 := NewLabel(Form,'v19').PlaceRight;
V20 := NewLabel(Form,'v20').PlaceRight;
V1.SetName(Form,'V1');
V2.SetName(Form,'V2');
V3.SetName(Form,'V3');
V4.SetName(Form,'V4');
V5.SetName(Form,'V5');
V6.SetName(Form,'V6');
V7.SetName(Form,'V7');
V8.SetName(Form,'V8');
V9.SetName(Form,'V9');
V10.SetName(Form,'V10');
V11.SetName(Form,'V11');
V12.SetName(Form,'V12');
V13.SetName(Form,'V13');
V14.SetName(Form,'V14');
V15.SetName(Form,'V15');
V16.SetName(Form,'V16');
V17.SetName(Form,'V17');
V18.SetName(Form,'V18');
V19.SetName(Form,'V19');
V20.SetName(Form,'V20');
Button := NewButton(Form,'Test').PlaceDown;
Button.OnClick := ButtonClick;
end;
end;
procedure TForm1.ButtonClick(Sender: PObj);
var
i: Integer;
c: PObj;
begin
for i := 1 to 20 do
begin
c := Form.FindObj('V'+Int2Str(i));
if c <> nil then
PControl(c).Text := 'zzz';
end;
c.Free;
end;
begin
Applet := NewApplet('Test');
NewForm1(Form1,Applet);
Run(Applet);
end.
magi6162 (2010-01-05 11:24:00) [32]I'm making an application for WinCE.
I use lazarus 9.28.2 for Windows, and Kol-CE 2.80.3
I have a form with about 20 items TKOLLabel.
I need to run this code
per i: = 0 count-1 do
begin
Self.ControlByName ( 'v' + IntToStr (i)).Hint : = 'AAAAA'; //Self is the form
i: = i +1
end;
When completed (target = arm wince widget = SO = WinCE compiler = ppcrossarm)
Error: identifier idents no member "ControByName"
This code without using KOLCE work, so I would know how to convert it to use KOLCE
magi6162 (2010-01-04 16:54:00) [33]Thanks for the quick response.
Tonight I try it.
Bye
Jon (2010-01-04 15:09:00) [34]Define: USE_NAMES
Use: TObj. Name
> USE_NAMES - to use property Name with any TObj.
> This makes also available method TObj.FindObj( name ): PObj.