How to show progressbar in form-titlebar?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #70851
    ralfiii
    Participant

    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.
    #70915
    JM-DG
    Participant

    Something like this?

    Attachments:
    You must be logged in to view attached files.
    #70918
    ralfiii
    Participant

    Cool, 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.
    #70930
    m.rabatscher
    Participant

    @ 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.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.