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

Вниз

Manage multiple runtime created forms   Найти похожие ветки 

 
Dodfr   (2005-07-27 02:17) [0]

Hi,

I want to manage mulitple windows created at runtime but with same common event methods.

I create the windows like this :
 global var -> FormView: array[1..10] of PControl;

 for i:=1 to 10 do
 begin
   FormView[i]:=NewForm( Applet, "FormView"+int2str(i) );
   with FormView[i]^ do
   begin
     Tag:=i; // permit store form number and place in FormView array
     HasBorder := False;
     ...
     OnMove:=GenericOnMove;
   end;
 end;

Goal is to have a generic OnMove(Sender:PObj) that will react depending which form number is calling the event. I can know which form number it is thru the .tag property of the form.

I would like the GenericOnMove contain something like :

if TKolForm(Sender).tag=1 then ...

of course this is VCL syntax and don"t work with KOL as sender is PObj, so what is correct syntax (I am a bit confused with PObj and TObj)things ?

Regards.


 
Thaddy   (2005-07-27 12:22) [1]

Tobj is the base object and already has a tag property, so you do not need to cast.
Remember that the default value is 0, so you should start counting from 1 in this case or (recommended) even use a higher value like 10.000 to start from.

You can simply write:

if sender.tag = X then ...


 
Dodfr   (2005-07-27 12:48) [2]

yes , as you see, I already start with 1 and because it"s a dword value, I could eventually mask it to put form number on first 8 bits + some other things on 24 last bits.

Sender.tag is enought as I can do for example some FormView[sender.tag].visible:=true, but for my knowledge, how to access PControl properties when you just receive PObj ?

By the way, why some events receive PObj, and other PControl ? why not all PControl ?

I use array of forms because new version of my TinyResMeter will permit to get multiple windows to spread them around the screen in smaller view instead of one big window, so you could group fields by resource type, one form for disk spaces, other for net speed, other for CPU, Mem, Page file, Top CPU process, Top Mem process ..., each one in a screen corner for example.Also i"ll add multiple resources switching in same fields every second to keep even more screen space.

I think i"ll have tons of questions to ask here :-)


 
Thaddy   (2005-07-27 19:15) [3]

In that case do a hard cast like PControl(sender).Color :=clNavy


 
Thaddy   (2005-07-27 19:17) [4]

Oh, the reason for that is not clear to me too ;)


 
Dodfr   (2005-07-28 23:11) [5]

I now have a little problem, if I set my own OnShow and put some showmessage(xx"); then when I close the last message I get crashed.

I tried to move the showmessage in OnMove that make appear same followed showmessage but finally same crash.

Other strange thing, if I set .visible:=true; then I never get the showmessage appear if inside OnShow.

Also, the OnMove seems triggered after each OnShow, but if I set Visible:=false then OnMove is triggered only when I really move the form.

Form is created with :
FormView[i]:=NewForm(Applet,"FormView"+int2str(i));

Could it be the Applet that is bad (I have KolApplet1 dropped on my form) ?



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

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

Наверх





Память: 0.45 MB
Время: 0.02 c
15-1140700169
Grom PE
2006-02-23 16:09
2006.03.19
Люди, посмотрите мои программы - для Вас делал.


15-1140374277
splr
2006-02-19 21:37
2006.03.19
Интернет...


2-1141038241
DesertAlex
2006-02-27 14:04
2006.03.19
try не работает...


1-1139864107
The X
2006-02-13 23:55
2006.03.19
Мультистроковый TButton


2-1141404032
vadim1
2006-03-03 19:40
2006.03.19
TabOrders and TabStops





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский