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

Вниз

MMTimer and Focus   Найти похожие ветки 

 
Jon ©   (2005-01-05 16:41) [0]

I am using pMMTimer in my project. I have BitBtn"s on my form. I want timer to set focus of buttons. Focus only correct when I switch to another application then back to mine. Works fine with pTimer. I assume it is because pMMTimer runs in its own thread. Can anyone help? Using KOL 2.05 /Delphi 7 / Win XP.


 
thaddy   (2005-01-05 17:04) [1]

Call setfocus on the applet handle first, then on the control or form you want focused. Also call bringtofront on the applet handle.


 
Jon ©   (2005-01-06 15:54) [2]

Thanks for your reply Thaddy, but it was unsuccessful. I tried your suggestions many times. I think this may be a genuine bug in KOL.

I have written a short app to demonstrate the problem. Compile the code and use SPACE-BAR to advance the button. The buttons advance correctly, but the focus will always appear on the first button.

Now try switching to another application the back to this - magic! - the focus is on the correct button.

program TestFocus;

{$DEFINE MM_TIMER}

uses
Windows, Messages, Kol;

var
MainForm, BitBtn: PControl;
{$IFDEF MM_TIMER}
Timer: PMMTimer;
{$ELSE}
Timer: PTimer;
{$ENDIF}
i: Integer;

procedure TimerEvent(Dummy: Pointer; Sender: PTimer);
begin
Timer.Enabled := False; //Check - why needed if periodic is false??
if MainForm.ActiveControl.Tag = 3 then MainForm.Children[0].Focused := True
else MainForm.Children[MainForm.ActiveControl.Tag +1].Focused := True;
MainForm.ActiveControl.Color := clRed;
end;

procedure ButtonClick(Dummy: Pointer; Sender: PControl);
begin
Timer.Enabled := False;
MainForm.ActiveControl.Color := clBtnFace;
Timer.Interval := 500;
Timer.Enabled := True;
end;

begin
MainForm := NewForm(nil,"Test Focus").SetSize(280,60);
for i := 0 to 3 do
begin
 BitBtn := NewBitBtn(MainForm,Int2Str(i +1),[],glyphLeft,0,0).PlaceRight;
 BitBtn.Tag := i;
 BitBtn.OnClick := TOnEvent(MakeMethod(nil,@ButtonClick));
end;
MainForm.Children[0].Focused := True;
MainForm.ActiveControl.Color := clRed;
{$IFDEF MM_TIMER}
Timer := NewMMTimer(0);
Timer.Periodic := False;
{$ELSE}
Timer := NewTimer(0);
{$ENDIF}
Timer.OnTimer := TOnEvent(MakeMethod(nil,@TimerEvent));
Run(MainForm);
end.

PS I finally managed to get to your website using the www4mail.org service. Keep up the good work!


 
Jon ©   (2005-01-07 18:04) [3]

I have tried the test with Free Pascal Compiler and it shows the same error too. I am convinced that this is a KOL fault. Is there a way to inform the developers?



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

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

Наверх




Память: 0.45 MB
Время: 0.012 c
1-1122109197
Андрей Молчанов
2005-07-23 12:59
2005.08.14
Редактирование поля ListView vsReport


1-1122471580
vigo
2005-07-27 17:39
2005.08.14
Вопрос по Юлианской дате


1-1122475280
REA
2005-07-27 18:41
2005.08.14
WebBrowser и мистика


1-1122470768
Juice
2005-07-27 17:26
2005.08.14
Директива-аналог "stop on delphi exceptions"


14-1122121196
Димитрий
2005-07-23 16:19
2005.08.14
Точки пересечения двух окружностей





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