Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visible and Minimized #70

Closed
Nick74k opened this issue Oct 20, 2017 · 8 comments
Closed

Visible and Minimized #70

Nick74k opened this issue Oct 20, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@Nick74k
Copy link

Nick74k commented Oct 20, 2017

Setting ribbon.visible := true also internally resets ribbon.minimized to false.
I can set it again to minimized after setting visible, but it causes flickering of ribbon - first it draws maximized and then switched to minimized.

procedure TForm5.FormCreate(Sender: TObject);
begin
  Ribbon.Visible := false;
  Ribbon.Minimized := true;
end;

procedure TForm5.Button1Click(Sender: TObject);
begin
  Ribbon.Visible := true;
  Ribbon.Minimized := true; // Without this ribbon will not be minimized, but now it causes flickering!!!
end;

Also setting of ribbon.visible := false at form.OnShow hides ribbon, but window header then showed with black color. Not a problem - I can move it to OnCreate, but it is not obvious.

procedure TForm5.FormShow(Sender: TObject);
begin
  Ribbon.Visible := false; // Now window header will be black
end;
@Nick74k
Copy link
Author

Nick74k commented Oct 20, 2017

Moved second part to issue #74 - it is not connected with OnShow, it always redraws window header.

@SaschaSchaefer
Copy link
Collaborator

Cannot be reproduced anymore. Possibly fixed by the changes that were made for issue 74. Could you please test again and check if this still occurs?

@Nick74k
Copy link
Author

Nick74k commented Oct 23, 2017

Nothing changed. See example project and screenshot.

RibTest.zip
2017-10-23_9-31-40 988

@Nick74k
Copy link
Author

Nick74k commented Oct 23, 2017

Second project - ribbon set as minimized at OnCreate, but showed maximized after button click.

RibTest.zip

@SaschaSchaefer
Copy link
Collaborator

Okay, with the sample projects I can reproduce it.

The reason that the ribbon is shown maximized, if Minimized is set to true in OnCreate, is that the ribbon is not yet initialized. You should move calls like that to the "OnLoaded" event of the ribbon.

A bit more problematic is the black bar, where the ribbon is supposed to be. This occurs when the ribbon is minimalized, without it ever having been visible before.
Even if both

Ribbon.Minimized := true;
Ribbon.Visible := false;

are moved to OnLoaded, we still get the black bar. I think the framework cannot handle setting the ribbon to minimized, without it having been drawn already, once before.

I don't think there is much we can do to fix this. This seems to be caused by the framework itself, not by the Delphi wrapper...
To work around this, you would have to ensure that the ribbon has processed a paint message, before calling Visible := False. This code, for example would work:

procedure TForm5.RibbonLoaded(Sender: TObject);
begin
  Ribbon.Minimized := true;
  Application.ProcessMessages;
  Ribbon.Visible := False;
end;

@Nick74k
Copy link
Author

Nick74k commented Oct 23, 2017

Ok, I see. Is it possible to add Application.ProcessMessages to SetMinimized function to suppress this error?

@joachimmarder
Copy link
Contributor

The reason that the ribbon is shown maximized, if Minimized is set to true in OnCreate, is that the ribbon is not yet initialized. You should move calls like that to the "OnLoaded" event of the ribbon.

Would it be possible to save this information in a member variable?

SaschaSchaefer added a commit that referenced this issue Oct 24, 2017
…hen the first paint message was processed by the ribbon. Until then, the "Minimize" operations are postponed (Fixes issue #70)
@SaschaSchaefer
Copy link
Collaborator

Would it be possible to save this information in a member variable?

I have added a new enum TUIRibbonState, which is now used to mark the time that the first paint message was processed by the ribbon. The call to "Minimize" will be postponed until the first paint message has been handled. This should fix this problem. Thx @joachimmarder for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants