I have an odd one here... working on some old code here.
Using D11 and latest TMS UI Pack.
JvMail.pas from JEDI has this call it makes internally
procedure TJvMail.SaveTaskWindowsState;
var
I: Integer;
W: HWND;
begin
SetLength(FSaveTaskWindows, Screen.FormCount);
FSaveTaskActiveForm := Screen.ActiveForm;
for I := 0 to Screen.FormCount - 1 do
begin
W := Screen.Forms[I].Handle;
FSaveTaskWindows[I] := IsWindowEnabled(W);
EnableWindow(W, False);
end;
end;
This appears to be very old and hasn't changed in for ever (2013)
This was causing an exception error.
Control 'TAdvStringGrid($03D44850)' has no parent window. Path: TAdvStringGrid($03D44850).
This took me forever to figure out why in MY code.
Finally I found it.
I found some ooooooold code from almost 10 years ago.
grid := tadvstringgrid.create(nil);
< do some stuff >
grid.free;
Was some dumb code where it used the grid to handle some things quickly without visually showing anything to the user. Ala, hack job.. but it has worked for 10 years now with no issues.
Now that we switched to D11 and using UI Pack vs the old "Component Pack" in 10.2 that we have been on for A long time, this appears to not be good.
My fix for now, create it, set to visible = false, and parent it to the form.
Now, my issue is. Is this a TMS issue, Jedi, Or Delphi? (Beyond my ugly code)
The exception happens on the
EnableWindow(W, False);
Apparently making A TAdvStringgrid with no parent, now registers under Screen.Forms
Not sure this should work like that? TStringGrid does not reproduce this error.
Can reproduce with this code below.
procedure TForm540.Button1Click(Sender: TObject);
var
I: Integer;
W: HWND;
FSaveTaskWindows: array of boolean;
StringGrid1: Tadvstringgrid;
begin
StringGrid1 := Tadvstringgrid.Create(nil); // create a GRID with no parent, free floater
SetLength(FSaveTaskWindows, Screen.FormCount);
for I := 0 to Screen.FormCount - 1 do
begin
W := Screen.Forms[I].Handle;
FSaveTaskWindows[I] := IsWindowEnabled(W);
EnableWindow(W, False);
end;
end;
I don't JvMail is the exact issue, as its been the same since 2013. Could it be better? Maybe...
But I feel something else going on here.
I know my usage of the non parented grid probably isn't wise but I figure i'd point it out, as it had worked for basically a decade.