Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2016.03.27;
Скачать: [xml.tar.bz2];

Вниз

KOL-CE Form.ControlByName   Найти похожие ветки 

 
magi6162 ©   (2010-01-04 13:31) [0]

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-04 15:09) [1]

Define: USE_NAMES
Use: TObj.Name


> USE_NAMES - to use property Name with any TObj.
> This makes also available method TObj.FindObj( name ): PObj.


 
magi6162 ©   (2010-01-04 16:54) [2]

Thanks for the quick response.
Tonight I try it.

Bye


 
magi6162 ©   (2010-01-05 11:24) [3]

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


 
Jon ©   (2010-01-05 15:44) [4]

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 16:37) [5]

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 18:03) [6]

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 19:32) [7]

{ 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"


 
magi6162 ©   (2010-01-05 19:47) [8]

v1,v2.... are TKOLLabel


 
magi6162 ©   (2010-01-05 19:57) [9]

Go to project options and define a new conditional of USE NAMES

In project options where insert USE NAMES?

sorry my bad english


 
Дмитрий К ©   (2010-01-05 21:03) [10]

In Lazarus Project - Compiler options... - Other - Custom options
Add -dUSE_NAMES


 
magi6162 ©   (2010-01-08 10:55) [11]

I did as you have written, but:

fmain_1.inc(19,17) Error: identifier idents no member "SetName"

thanks for all the help


 
Jon ©   (2010-01-08 14:41) [12]

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 options add: -dUSE_NAMES
- Click OK
- Click Compile
- When compile completed, close package window and try again


 
magi6162 ©   (2010-01-08 15:11) [13]

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 15:45) [14]

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 16:37) [15]

MirrorKOLPackage when compiling with-dUSE_MHTOOLTIP, error:

C:\lazarus\components\kol-ce-2.80.3\kol\KOLMHToolTip.pas(268,50) Error: Identifier not found "TTM_GETDELAYTIME"

thanks


 
Jon ©   (2010-01-08 17:00) [16]

TTM_GETDELAYTIME is defined in delphicommctrl.inc

 TTM_GETDELAYTIME         = WM_USER + 21;

but in KOL.PAS it is only enabled for Win32...

{$IFDEF WIN}
//{_#IF [DELPHI]}
{$IFDEF WIN32}
 {$INCLUDE delphicommctrl.inc}
 {$IFDEF UNICODE_CTRLS}
   {$DEFINE interface_part} {$I KOL_unicode.inc} {$UNDEF interface_part}
 {$ELSE} // ANSI_CTRLS
{$ifndef FPC}
   {$DEFINE interface_part} {$I KOL_ansi.inc} {$UNDEF interface_part}
{$endif FPC}
 {$ENDIF UNICODE_CTRLS}
{$ENDIF WIN32}
//{_#ENDIF}
{$ENDIF WIN}


Try to add the relevant bits from delphicommctrl.inc to your unit.

Hopefully Yury Sidorov (the maintainer of KOL-CE) will read this and fix it in the SVN.


 
magi6162 ©   (2010-01-08 17:24) [17]

sorry,
My last message was wrong, MirrorKOLPackage compiling with -dUSE_MHTOOLTIP OK.

v1..vxx: TKOLLabel

for i := 1 to nMesi do
begin
   c := Form.FindObj("v" + Int2Str(i));  
   if c <> nil then
      PControl(c).Hint.Text :="zzz"   <--- Error here
end;

still error:

fmain.pas(213,19) Error: identifier idents no member "Hint"

thanks


 
magi6162 ©   (2010-01-08 17:56) [18]

Sorry again.
this error is present:

MirrorKOLPackage when compiling with-dUSE_MHTOOLTIP, error:

C:\lazarus\components\kol-ce-2.80.3\kol\KOLMHToolTip.pas(268,50) Error: Identifier not found "TTM_GETDELAYTIME"
---------------------
You: Try to add the relevant bits from delphicommctrl.inc to your unit.

How can I do?

thanks


 
Jon ©   (2010-01-08 21:34) [19]

Open KOLMHToolTip.pas
Find line 154:

const
 Dummy = 0;


Insert copied text from delphicommctrl.inc on next line:


{$ifdef wince}
 TTM_ADDTOOLW             = WM_USER + 50;
 TTM_DELTOOLW             = WM_USER + 51;
 TTM_NEWTOOLRECTW         = WM_USER + 52;
 TTM_GETTOOLINFOW         = WM_USER + 53;
 TTM_SETTOOLINFOW         = WM_USER + 54;
 TTM_HITTESTW             = WM_USER + 55;
 TTM_GETTEXTW             = WM_USER + 56;
 TTM_UPDATETIPTEXTW       = WM_USER + 57;
 TTM_ENUMTOOLSW           = WM_USER + 58;
 TTM_GETCURRENTTOOLW      = WM_USER + 59;
 TTM_WINDOWFROMPOINT      = WM_USER + 16;
 TTM_TRACKACTIVATE        = WM_USER + 17;  // wParam = TRUE/FALSE start end  lparam = LPTOOLINFO
 TTM_TRACKPOSITION        = WM_USER + 18;  // lParam = dwPos
 TTM_SETTIPBKCOLOR        = WM_USER + 19;
 TTM_SETTIPTEXTCOLOR      = WM_USER + 20;
 TTM_GETDELAYTIME         = WM_USER + 21;
 TTM_GETTIPBKCOLOR        = WM_USER + 22;
 TTM_GETTIPTEXTCOLOR      = WM_USER + 23;
 TTM_SETMAXTIPWIDTH       = WM_USER + 24;
 TTM_GETMAXTIPWIDTH       = WM_USER + 25;
 TTM_SETMARGIN            = WM_USER + 26;  // lParam = lprc
 TTM_GETMARGIN            = WM_USER + 27;  // lParam = lprc
 TTM_POP                  = WM_USER + 28;
 TTM_POPUP                = WM_USER + 34;
 TTM_UPDATE               = WM_USER + 29;
{$endif wince}


Hope it works!


 
magi6162 ©   (2010-01-11 12:29) [20]

Will try today.

Thanks for your help and quick response.

thanks


 
magi6162 ©   (2010-01-11 16:59) [21]

great!

The compilation is OK!

Then try the application on the device

thank you very much!


 
Jon ©   (2010-01-11 18:03) [22]

Prego!


 
magi6162 ©   (2010-01-12 10:32) [23]

I tried

compilation is ok

when I run on device(windows mobile 2003 SE) error Access Violation:

PControl(c).Caption := "AAA";

Help me

grazie


 
magi6162 ©   (2010-01-13 10:30) [24]

Some ideas to solve?

thanks


 
Jon ©   (2010-01-13 18:14) [25]

Sorry, but I have no mobile device to test with.
Can you provide more details of the error?
Are you sure that the device can actually show tooltips?


 
magi6162 ©   (2010-01-13 20:04) [26]

The device does not support tooltips.

But the error occurs:

PControl(c).Caption := "AAA";  <-- Error here

without using the tooltips

The device shows only AccessViolation

thanks


 
Jon ©   (2010-01-14 01:00) [27]

Sorry about the tooltips - I misread your post.

I have downloaded and installed a Win-CE emulator to test. I could not find ROM images for Windows Mobile 2003 SE so I tested with Windows Mobile 6 Professional (ARM920T).

The code works correctly and without errors for me.

Here is a link to my Lazarus project and compiled exe for you to test: http://www.sendspace.com/file/xxlrzj


 
magi6162 ©   (2010-01-14 13:24) [28]

You: I have downloaded and installed a Win-CE emulator to test.

Where can I find the emulator?
how I install it?
as I run it?
thanks


 
Jon ©   (2010-01-14 14:06) [29]


> Where can I find the emulator?
> how I install it?
> as I run it?
> thanks


From Microsoft - details here: http://technet.microsoft.com/en-us/library/cc461417.aspx

You need:
- Virtual PC 2007 http://www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&DisplayLang=en
- Device Emulator Standalone http://www.microsoft.com/downloads/details.aspx?familyid=A6F6ADAF-12E3-4B2F-A394-356E2C2FB114&displaylang=en
- Emulator images (Professional) http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&displaylang=en

Did the files from my project work correctly?


 
magi6162 ©   (2010-01-14 16:57) [30]

now works.
I indicated a different subject.

Excellent work.
thanks


 
magi6162 ©   (2010-01-14 17:04) [31]

PControl(cl).Hint.Text :="AAA"

Compilazione ok, Esecuzione Ok.

but whatever value do to the string is not stored, without giving error.

Use the "Hint" to store strings. I must not see the hints. I use them as tags.
any suggestions to workaround the problem?

thanks


 
magi6162 ©   (2010-01-14 18:15) [32]

I solved using arrays of strings.

thanks


 
Jon ©   (2010-01-15 18:23) [33]


> Use the "Hint" to store strings. I must not see the hints.
>  I use them as tags.


You can use the CustomData property:

Set: PControl(c).CustomData := PKOLChar("String to store as tag");
Get: MsgOK(PKOLChar(PControl(c).CustomData));

Nice and easy. No need for additional arrays ;-)


 
magi6162 ©   (2010-01-18 12:26) [34]

good!

thank you so much!

ciao.



Страницы: 1 вся ветка

Форум: "KOL";
Текущий архив: 2016.03.27;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.54 MB
Время: 0.002 c
4-1276769551
Иван
2010-06-17 14:12
2016.03.27
Выбор сертификата


2-1409151951
kaldirishe
2014-08-27 19:05
2016.03.27
Разница межу D7 и D2010+


15-1436995802
Юрий
2015-07-16 00:30
2016.03.27
С днем рождения ! 16 июля 2015 четверг


15-1436563802
Юрий
2015-07-11 00:30
2016.03.27
С днем рождения ! 11 июля 2015 суббота


15-1437082204
Юрий
2015-07-17 00:30
2016.03.27
С днем рождения ! 17 июля 2015 пятница





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский