Mam taki dziwny problem, nie wiem co jest jego powodem...
Otóż, mam aplikację, która wywołuje funkcje z biblioteki. Funkcje ładowane są dynamicznie (ponieważ z biblioteki korzystają 2 programy, w różnych
lokalizacjach). Funkcje w programie odpalane są co określony czas w TTimer.
Problem: TTimer ustawiony jest w przedziale 500-1000ms. Gdy chcę przesunąć formę lub zmienić jej rozmiar, bądź rozwinąć jakąś listę na tej formie,
aplikacja nie zezwala na to - jakby traciła fokus. Rozumiem, że to przez cykliczne wywoływanie funkcji z biblioteki, ale nie wiem dlaczego tak jest i co robię źle.
Poniżej szkielet tego co mam:
Biblioteka:
library System;
uses
Windows,
SysUtils,
Classes;
{$R *.res}
// Current Data ------------------------------------------------------------------------------------
function GetCurrent_Data: PChar; stdcall;
begin
result:=PChar(DateToStr(Now));
end;
// Current Data ------------------------------------------------------------------------------------
// Current Time ------------------------------------------------------------------------------------
function GetCurrent_Time: PChar; stdcall;
begin
result:=PChar(TimeToStr(Now));
end;
// Current Time ------------------------------------------------------------------------------------
exports
GetCurrent_Data,
GetCurrent_Time;
begin
end.
Jak widać, biblioteka eksportuje 2 proste funkcje, które zwracają bieżącą datę i godzinę.
Program (w uproszczeniu)
type
TGetCurrent_Data_Func = function : PChar; stdcall;
TGetCurrent_Time_Func = function : PChar; stdcall;
var
DLL_Handle : Cardinal;
GetCurrent_Data_Func : TGetCurrent_Data_Func;
GetCurrent_Time_Func : TGetCurrent_Time_Func;
V_CurrentData : string;
V_CurrentTime : string;
...
// procedura, która ładuje biblioteke i odpala 2 funkcje
procedure TMainFrm.Load_System_Info;
begin
DLL_Handle := LoadLibrary(PWideChar('C:\MyLibraryPath\System.dll')) ;
if DLL_Handle <> 0 then
begin
try
// Current Date
@GetCurrent_Data_Func := GetProcAddress(DLL_Handle, 'GetCurrent_Data');
if Assigned (GetCurrent_Data_Func) then
begin
V_CurrentData:= GetCurrent_Data_Func; // wynik funkcji wędruje do zmiennej globalnej
end;
// Current Time
@GetCurrent_Time_Func := GetProcAddress(DLL_Handle, 'GetCurrent_Time');
if Assigned (GetCurrent_Time_Func) then
begin
V_CurrentTime:= GetCurrent_Time_Func; // wynik funkcji wędruje do zmiennej globalnej
end;
finally
FreeLibrary(DLL_Handle);
end;
end;
end;
...
// Odpalam co 500 ms
procedure TMainFrm.TimerTimer(Sender: TObject);
begin
Load_System_Info;
end;
Co robię źle?
-Pawel