This problem has been driving me nuts for more than a day!
In my Triangle Program - or more specifically the Printer set up display - I had determined to show the position of the Tabs on the page with red lines at appropriate locations along the top of the Paper display. Because I can only use interger values and considering that the distance between tabs is small it was less than ideal but I was also confused by the fact that on first showing the MTF_Panel, the Tabs did not appear.
I tried various ways to stop this even thinking that because the TPanel was not 'visible' when I handled the 'drawing' - I made it visible, but still the tabs did not show until such time as I modified any of the parameters (Number of tabs, size of margins).
My next attempt to address both issues was to create a larger image (TShape) in the [Tabs] section of the display. This did make the position of the tab marks better but again on first show - nothing.
The attached .PNG file should make the problem clear.
By 'stepping through' the code I know that the procedure for drawing the Tabs image IS being executed prior to the MTF_Panel being shown so I cannot fathom why the first display is blank ????
Here is the code that draws the tab (and margin) lines :
procedure Show_Tabs(T,L,R,S : single);
var
TM,LM,RM,TS,CurTab : word;
I : byte;
M : single;
begin
TriangleSolution.Debug.Append('- Show Tabs');
if prPgOrient = 0 then // scaling factor between full sheet
M := 290/105 // display and page header display
else
M := 290/148;
TM := trunc(T * M + 0.5);
LM := trunc(L * M + 0.5);
RM := trunc(R * M + 0.5);
TS := trunc(S * M + 0.5);
if TM > 20 then TM := 20; // to account for top margin being large
CurTab := LM+TS;
with TriangleSolution.Margin_Display.Canvas do
begin
Clear;
Pen.Color:=clBlack;
Pen.Width:=2;
MoveTo(0,40); // Draw Page outline
LineTo(0,0);
LineTo(290,0);
LineTo(290,40);
Pen.Color:=clBlue;
MoveTo(LM,TM);LineTo(LM,35); // show margins
MoveTo(290-RM,TM);LineTo(290-RM,35);
MoveTo(LM,TM);LineTo(290-RM,TM);
Pen.Color:=clRed;
Pen.Width:=1;
TM := TM+3;
for I := 1 to MaxTab do // show Tabs
begin
CurTab := Trunc(LM+I*TS);
MoveTo(CurTab,TM);LineTo(CurTab,TM+12);
end;
end;
Application.ProcessMessages;
end;
I added the
Application.ProcessMessages; at the end in case it was a matter of Windows being lazy, but it made no difference.
The proc is called with the Margin & Tab sizes (in mm) precalculated.
Without making any changes to the variables on the MTF_Panel, if I click on the button to show the panel a second time then the tabs DO appear.
To try to solve this issue, I created a [Debug] TMemo and wrote the details of each proc called to that - just to make sure that I hadn't missed a call to draw the tabs - that's why the first line in the proc is
TriangleSolution.Debug.Append('- Show Tabs');