Patch from zeljko to qt. Fixes for ScrollBar and ShowModal

git-svn-id: trunk@11269 -
This commit is contained in:
sekelsenmat 2007-06-03 03:55:24 +00:00
parent 2f1dea96f0
commit a39c0e25b3
2 changed files with 22 additions and 11 deletions

View File

@ -2739,13 +2739,14 @@ end;
function TQtWidgetSet.SetScrollInfo(Handle : HWND; SBStyle : Integer;
ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer;
var
i: Integer;
ScrollBar: TScrollBar;
FScrollInfo: TScrollInfo;
R: TRect;
FRepaint: Boolean;
function PrepareScrollInfo: Integer;
var
iReCountMax: Integer;
begin
Result := 0;
@ -2766,7 +2767,13 @@ begin
FScrollInfo.nMin := ScrollInfo.nMin;
FScrollInfo.nMax := ScrollInfo.nMax;
ScrollBar.Min := ScrollInfo.nMin;
ScrollBar.Max := ScrollInfo.nMax - ScrollInfo.nPage;
{we must recount ScrollBar.Max since invalid value raises AV}
iRecountMax := FScrollInfo.nMax - ScrollInfo.nPage;
if iRecountMax < FScrollInfo.nMin then
iRecountMax := FScrollInfo.nMin;
ScrollBar.Max := iRecountMax;
{ - (ScrollInfo.nMax div 4 PageStep property)); }
end;

View File

@ -277,20 +277,24 @@ begin
{$endif}
TQtWidget(ACustomForm.Handle).Hide;
TQtWidget(ACustomForm.Handle).setWindowModality(QtApplicationModal);
TQtWidget(ACustomForm.Handle).Show;
{ This sleep is required, otherwise sometime the modal window will not show,
effectively freezing the application }
Application.ProcessMessages;
Sleep(10);
Application.ProcessMessages;
{give it a real modal loop, CPU consumption is OK now ... }
// while Assigned(ACustomForm) and (ACustomForm.Visible)
while (ACustomForm.ModalResult = mrNone) do
begin
sleep(10);
Application.ProcessMessages;
end;
{BUG: if we assign OnCloseQuery(), Lazarus TCustomForm.Close() Fires ModalResult = mrCancel,
without counting on OnCloseQuery() result (CanClose), so if we set it up we'll jump over our
loop, and then comes into LCL loop with WidgetSet.AppProcessMessages
which burns CPU ...}
{$ifdef VerboseQt}
WriteLn('Trace:< [TQtWSCustomForm.ShowModal]');
{$endif}