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

Вниз

StatusBar.AutoHint := ???   Найти похожие ветки 

 
КВАНТ   (2006-11-13 00:36) [0]

Скажите пожалуйста, как в KOL&MCK у формы в Статус Баре сделать AutoHint (показ подсказки в статус баре, а не около объекта)? В VCL это можно было очень легко сделать изменив StatusBar.AutoHint на True...
Спасибо!


 
Thaddy   (2006-11-13 10:59) [1]

Emulate ;) :

{
program Project1;
uses
 Kol,
 unit1 in "Unit1.pas";

begin
 NewForm1( Form1, nil);
 Run(Form1.form);
end.
}
unit unit1;

interface
uses
 Windows, Messages, Kol, KolAdd;

type

PForm1=^TForm1;
TForm1=object(Tobj)
 Form:pControl;
 Btn,
 Edit,
 Cb:PControl;
public
 procedure MouseEnter(sender:PObj);
 procedure MouseLeave(sender:PObj);
end;

procedure NewForm1( var Result: PForm1; AParent: PControl );

var
 Form1:pForm1;

implementation

procedure NewForm1( var Result: PForm1; AParent: PControl );
var
 i:integer;
begin
 New(Result,Create);
 with Result^ do
 begin
   Form:= NewForm(AParent,"KOLForm").SetSize(600,400).centeronparent.Tabulate;
   Applet:=Form;
   Form.Add2AutoFree(Result);
   Form.Simplestatustext :="";// make shure we have toolbar
   btn :=Newbutton(form,"Test");
   cb := NewCheckbox(form,"CB Test").placedown.autoSize(True);
   Edit := NewEditBox(Form,[]).Placedown;
   for i := 0 to form.ChildCount-1 do
   begin
     Form.Children[i].OnMouseEnter := MouseEnter;
     Form.Children[i].OnMouseLeave := MouseLeave;
   end;
 end;
end;

procedure TForm1.MouseEnter(sender: PObj);
begin
 Form.SimpleStatusText := PChar(PControl(sender).subClassName);
end;

procedure TForm1.MouseLeave(sender: PObj);
begin
 Form.SimpleStatusText := "";
end;

end.


 
КВАНТ   (2006-11-13 15:23) [2]

А есть более простой способ? Пытался разобраться с этим, нифига не понял... X-/


 
КВАНТ   (2006-11-14 21:02) [3]

Ладно, тогда как подсказку показывать в Label"е?


 
[e]Bu$ter ©   (2006-11-15 11:16) [4]


> А есть более простой способ? Пытался разобраться с этим,
>  нифига не понял... X-/


Да там всё просто, Тедди тебя напугал лишним кодом, он просто MCK не использует. :)

Главное там, это вот этот код:
1)
public
procedure MouseEnter(sender:PObj);
procedure MouseLeave(sender:PObj);


2)

 for i := 0 to form.ChildCount-1 do
  begin
    Form.Children[i].OnMouseEnter := MouseEnter;
    Form.Children[i].OnMouseLeave := MouseLeave;
  end;


3)
procedure TForm1.MouseEnter(sender: PObj);
begin
Form.SimpleStatusText := PChar(PControl(sender).subClassName);
end;

procedure TForm1.MouseLeave(sender: PObj);
begin
Form.SimpleStatusText := "";
end;


(2) Пишешь в событии onCreate главной формы. Вписываешь (1) у себя там где оно написано в примере, и жмёшь CtrlshiftC. В создавшихся обработчиках пишешь (3).


 
thaddy   (2006-11-15 20:42) [5]

Tnx! well done.


 
КВАНТ   (2006-11-16 05:18) [6]

[e]Bu$ter ©, спасибо! Я попробую ;)


 
КВАНТ   (2006-11-17 15:31) [7]

То-есть СубКлассНэйм нужно где-то "забить" подсказкой??
Button1.SubClassName := "Кнопка";

Так??


 
КВАНТ   (2006-11-17 15:46) [8]

И еще: у статус бара не изменишь СКН!! То есть при наведении НА статус бар, показывает obj_msctls_statusbar32, что оччень некрасиво звучит :) :(


 
[e]Bu$ter ©   (2006-11-17 20:19) [9]


> КВАНТ   (17.11.06 15:31) [7]
> То-есть СубКлассНэйм нужно где-то "забить" подсказкой??Button1.
> SubClassName := "Кнопка";Так??

Нет конечно! Стой, откуда там вообще SubClassName?! Тебе же Hint нужен вроде....
Это Тедди чего-то перемудрил, а я Copy"n"Paste сделал, сильно не приглядываясь чего там написано - доверял :)))

В (3), вместо строки
Form.SimpleStatusText := PChar(PControl(sender).subClassName);
естественно должно быть
Form.SimpleStatusText := PChar(PControl(sender).Hint);


 
thaddy   (2006-11-17 20:53) [10]

:)

Again, compliments....


 
КВАНТ   (2006-11-17 23:39) [11]

Я конечно извиняюсь, но ПОЧЕМУ на ЭТО:

Form.SimpleStatusText := PChar(PControl(sender).Hint);

ругается ЭТИМ:

Undeclared identifier: "Hint"

Кстати, еще вопрос: как программно у Рича менять WordWrap, которого в инспекторе нет!! А мне нужно! ((


 
thaddy   (2006-11-18 10:07) [12]

here"s a simple engine, but you really should try to learn more by yourself instead of asking.

I won"t give help :) try to figure out how it workd ;)

unit kolhintengine;

interface
uses kol;
type

PSbHintEngine = ^TSbHintEngine;
TSbHintEngine = object(TStrlistEx)
 FForm:PControl;
public
 procedure MouseEnter(sender:Pobj);
 procedure MouseLeave(sender:PObj);
 procedure RegisterHint(aControl:PControl;const Hint:String);
 procedure UnRegisterHint(aControl:PControl);
end;

function NewSbHintEngine(aForm:PControl):PSbHintEngine;

implementation

function NewSbHintEngine(aForm:PControl):PSbHintEngine;
begin
 New(Result,Create);
 with result^ do
 begin
  FForm := aForm;
  FForm.SimplestatusText :="";
 end;
end;

procedure TSbHintEngine.MouseEnter(sender: Pobj);
var
 Index:integer;
begin
 Index := IndexOfObj(sender);
 if Index <> -1 then
  FForm.SimpleStatusText := PChar(Items[index]);
end;

procedure TSbHintEngine.MouseLeave(sender: PObj);
var
 Index:integer;
begin
 Index := IndexOfObj(sender);
 if Index <> -1 then
  FForm.SimpleStatusText := "";
end;

procedure TSbHintEngine.RegisterHint(aControl: PControl;
 const Hint: String);
var Index:Integer;
begin
Index := IndexOfObj(aControl);
if Index <> -1 then
   AddObject(Hint, Cardinal(aControl))
else
   Items[index] := Hint;
aControl.OnMouseEnter := MouseEnter;
aControl.OnMouseLeave := MouseLeave;
end;

procedure TSbHintEngine.UnRegisterHint(aControl:PControl);
var
index:integer;
begin
index := IndexOfObj(aControl);
if Index <> -1 then
  Delete(Index);
end;

end.


 
thaddy   (2006-11-18 10:26) [13]

too fast again, small bug:

procedure TSbHintEngine.RegisterHint(aControl: PControl;
const Hint: String);
var Index:Integer;
begin
Index := IndexOfObj(aControl);
if Index = -1 then // if we do not have this control"s hint already
  AddObject(Hint, Cardinal(aControl))
else
  Items[index] := Hint; //Replace it
aControl.OnMouseEnter := MouseEnter;
aControl.OnMouseLeave := MouseLeave;
end;


 
Galkov ©   (2006-11-18 10:47) [14]

thaddy, 10x :)

And what about:
1) Adding destructor (or Killer :)) to AutoFree list of Parent ?
2) Old events, that was assigned to OnMouseXXX ?


 
thaddy   (2006-11-18 11:08) [15]

1. Not a good idea...
Design constraints are thus:

- Objects are owned by creatING object but OFCOURSE not by the hint engine, so if the hint engine is destroyed, only the hints are destroyed, but not the objects... This is very important!
- In this simple example you can not re-use onmouseenter, onmouseleave( I agree).
- The events can ONLY be fired by a true, existing, pcontrol, otherwise there would be no event ;)

But I agree, this is a very basic example and it does not pretend to be otherwise ;)


 
thaddy   (2006-11-18 11:12) [16]

If you mean: FForm.AddToAutoFree(Result) that would be usefull


 
Galkov ©   (2006-11-18 12:34) [17]

> If you mean: FForm.AddToAutoFree(Result) that would be usefull
undoubtedly!

It seems, we haven"t KOL-technique for adding events to chains and removing its from this ... :(


 
thaddy   (2006-11-18 16:14) [18]


PEventChain = ^ REventChain;
TEventChain = packed record
ThisEvent:TOnEvent;
OldEvent: TOnEvent;
end;

Now, simply add:

- A Getter function to get the current values and assign it to an OldEvent record instance (Allocated with allocmem to have it initialized to zero"s)
- A Setter function that attaches the new handler
- In the new handler, make shure to call the old handler (either before or after the new handler, depending on functionality)

Some more little house work...
It is certainly possible and I have given event chaining examples here before.

In this case it is easier than writing a WndProc and use AttachWndProc, because these onenter and onleave handlerrs are a bit custom and not standard handlers.

I will do a more complete class later today, just to show it is not difficult.
(The example here was typed in and tested while answering the post and only for education)


 
КВАНТ   (2006-11-19 22:37) [19]

2thaddy
И ты снова даешь примеры на чистом KOL, ба-а-али-и-ин :) :\


 
Galkov ©   (2006-11-20 00:35) [20]

А мне так нравится :))
Вот только английский мой шибко скуден для изложения идей...

Попробую по-русски:
Видимо, можно сделать наследника для TControl, не добавляющего новых полей, и который перекрывает property типа OnMouseEnter (или просто добавляет два метода типа Add_XXX и Remove_XXX)
Дальше - дело техники: назначает на TControl.OnMouseEnter свой метод, сканирующий цепочку вызовами событий, добавляет деструктор цепочки методом Add2AutoFreeEx, ну и два метода типа Add и Remove

Чтобы можно было пользоваться типа так:
PChainControl(Form).OnMouseEnter2Chain := SbHintEngine.MouseEnter;

Цель - чтобы задача (например, решение которой демонстрировал коллега thaddy) была более ЛОКАЛИЗОВАНА.
Т.е., чтобы и в его кодах можно было бы не чесать репу: а было ли назначение обработчиков в aControl ДО, а будет ли - ПОСЛЕ ???



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

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

Наверх





Память: 0.5 MB
Время: 0.005 c
1-1177845915
Cj
2007-04-29 15:25
2007.07.01
BeginUpdate для всей StringGrid


2-1181057867
AAN
2007-06-05 19:37
2007.07.01
Проблема удаления объектов


2-1181218595
webpauk
2007-06-07 16:16
2007.07.01
Array Pointer


3-1175775683
elserpiente
2007-04-05 16:21
2007.07.01
Много транзакция для одного TIBDataBase


2-1181147621
GoRdon
2007-06-06 20:33
2007.07.01
Кнопка





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