diff --git a/examples/testall.lpi b/examples/testall.lpi index 476be30aa9..19066424c8 100644 --- a/examples/testall.lpi +++ b/examples/testall.lpi @@ -1,4 +1,4 @@ - + @@ -44,10 +44,7 @@ - - - - + @@ -60,11 +57,5 @@ - - - - - - diff --git a/examples/testallform.pp b/examples/testallform.pp index cc77764531..8778b9fa7b 100644 --- a/examples/testallform.pp +++ b/examples/testallform.pp @@ -960,7 +960,7 @@ BitBtn1 := TBitBtn.Create(Self); Font.Pitch := fpDefault; Font.Size := 10; Font.Style := BitBtn1.Font.Style+[fsBold]; - LoadGlyphFromLazarusResource('topendialog'); + LoadGlyphFromResourceName(hInstance,'topendialog'); //height := 28; Has to be set before Glyph //HelpContext := 0; Identifier not found Hint := 'Settings for BitBtn1 >>'; @@ -2251,7 +2251,7 @@ SpeedButton1 := TSpeedButton.Create(Self); Hint := 'SpeedButton1'; Color := clBtnFace; ShowHint := True; - LoadGlyphFromLazarusResource('laz_open'); + LoadGlyphFromResourceName(hInstance,'laz_open'); Visible := True; end; @@ -2267,10 +2267,10 @@ SpeedButton2 := TSpeedButton.Create(Self); Left := 35; Top := 28; Flat := False; - Hint := 'SpeedButton1'; + Hint := 'SpeedButton2'; Color := clBtnFace; ShowHint := True; - LoadGlyphFromLazarusResource('laz_save'); + LoadGlyphFromResourceName(hInstance,'laz_save'); Enabled := True; Visible := True; end; @@ -2286,10 +2286,10 @@ SpeedButton3 := TSpeedButton.Create(Self); Left := 60; Top := 28; Flat := False; - Hint := 'SpeedButton1'; + Hint := 'SpeedButton3'; Color := clBtnFace; ShowHint := True; - LoadGlyphFromLazarusResource('item_font'); + LoadGlyphFromResourceName(hInstance,'item_font'); Enabled := True; Visible := True; end; @@ -2308,7 +2308,7 @@ SpeedButton4 := TSpeedButton.Create(Self); Hint := 'SpeedButton4'; Color := clBtnFace; ShowHint := True; - LoadGlyphFromLazarusResource('tcolordialog'); + LoadGlyphFromResourceName(hInstance,'tcolordialog'); Enabled := True; Visible := True; end; diff --git a/examples/testtools.inc b/examples/testtools.inc index 96c28b5795..d035f7cca1 100644 --- a/examples/testtools.inc +++ b/examples/testtools.inc @@ -1560,6 +1560,7 @@ lblState := TLabel.Create(Self); // ADD TrackBar CompTools HERE !!!!!!!!! //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++ TUpDown Tools ++++++++++++++++++++++++++++++++++++++ + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ADD UpDown CompTools HERE !!!!!!!!! //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -2495,17 +2496,31 @@ procedure TForm1.ApplicationIdle(Sender: TObject; var Done: Boolean); var CurControl: TControl; P: TPoint; -begin - GetCursorPos(P); + F: TForm; + i: Integer; +begin + //Only perform OnIdle if either the mainform or one of the BenchForms is active + //e.g. if a ShowMessage is showing, FFocusControl may point to an aready + //destroyed component, thus crashing the application. + F := Screen.ActiveForm; + if not Assigned(F) then Exit; + if (F <> Self) then + begin + for i := Low(BenchForm) to High(BenchForm) do + if (BenchForm[i] = F) then Break; + //writeln('Not the MainForm or a BenchForm'); + Exit; + end; + GetCursorPos(P); CurControl := FindControlAtPosition(P, True); if FFocusControl <> CurControl then begin - if FFocusControl <> nil then + if FFocusControl <> nil then VirOnLeave(FFocusControl); FFocusControl := CurControl; if FFocusControl <> nil then VirOnEnter(FFocusControl); - end; + end; end; procedure TForm1.VirOnEnter(Sender: TObject); begin