How to show progressbar in form-titlebar?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #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, 10 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, 10 months ago by m.rabatscher.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.