- This topic has 3 replies, 3 voices, and was last updated 2 years, 4 months ago by m.rabatscher.
-
AuthorPosts
-
April 6, 2022 at 1:28 pm #70851ralfiiiParticipant
Hello!
(how) Is it possible to show a progressbar in the title bar of a form?At the moment I use a progress bar in TsStatusbar + a TProgressbar, but customers complain that that’s too much vertical space given that the progress bar is visible very rarely.
I’d like to move the progress to the title bar, ideally right aligned just next to the min/max/close buttons.
Thanks for tips.
Btw: Sorry for the crosspost, I just realized, that the “tips” section of the forum is dead (at least no post for months there)
- This topic was modified 2 years, 7 months ago by ralfiii.
June 11, 2022 at 3:51 am #70915June 13, 2022 at 9:03 am #70918ralfiiiParticipantCool, thanks!
I found TsTitleBar is also an option to place a Plogressbar up there:procedure TfrmDarwin.sDarwinTitleBarItems1DrawItem(Item: TacTitleBarItem; ADrawData: TacTitleItemDrawData); const cTopOffset = 2; begin if geProgress.Progress > 0 then begin ADrawData.Bmp.Canvas.Lock; OffsetViewportOrgEx(ADrawData.Bmp.Canvas.Handle, aDrawData.ARect.Left, aDrawData.ARect.Top + cTopOffset, nil ); geProgress.Perform(WM_PAINT, WPARAM(ADrawData.Bmp.Canvas.Handle), 0); OffsetViewportOrgEx(ADrawData.Bmp.Canvas.Handle, -aDrawData.ARect.Left, -aDrawData.ARect.Top - cTopOffset, nil ); ADrawData.Bmp.Canvas.Unlock; end; end;
- This reply was modified 2 years, 5 months ago by ralfiii.
July 6, 2022 at 8:21 am #70930m.rabatscherParticipant@ alpha skin team:
this option above works fine BUT! :In some circumstances the code above leads to a stack overflow
-> if some caches are not ready yet the WM_PAINT call triggers a full repaint?!?! which again triggres
this event handler to be called again.So basically the code needs to be modified as:
procedure TfrmDarwin.sDarwinTitleBarItems1DrawItem(Item: TacTitleBarItem; ADrawData: TacTitleItemDrawData); const cTopOffset = 2; begin if not fInTitleDrawing and (geProgress.Progress > 0) then begin // ########################################### // #### Now paint the hidden progress bar to the titel bar // the Perform(WM_PAINT,...) method can atually cause a stack overflow in case the timing is bad and the components cache has not yet been // created before the title bar is drawn. This should not happen though in the component and is just a hack to avoid the stack problem. // basically start the darwin with bad sema connection params and see the overflow happen fInTitleDrawing := True; try ADrawData.Bmp.Canvas.Lock; OffsetViewportOrgEx(ADrawData.Bmp.Canvas.Handle, aDrawData.ARect.Left, aDrawData.ARect.Top + cTopOffset, nil ); geProgress.Perform(WM_PAINT, WPARAM(ADrawData.Bmp.Canvas.Handle), 0); OffsetViewportOrgEx(ADrawData.Bmp.Canvas.Handle, -aDrawData.ARect.Left, -aDrawData.ARect.Top - cTopOffset, nil ); ADrawData.Bmp.Canvas.Unlock; finally fInTitleDrawing := False; end; end; end;
Note:
fInTitleDrawing
is a member variable of the form- This reply was modified 2 years, 4 months ago by m.rabatscher.
-
AuthorPosts
- You must be logged in to reply to this topic.