TMSFNCRibbon - Flickering

I create Form1 with style "Windows11 Dark". I put to Form1 TMSFNCRibbon1 with TMSFNCRibbonPageControlContainer1. When I resize Form1 every components like Edit1, TMSFNCEdit1, MaskEdit1, TrackBar1 flickering.


When I set Form1 style to "Windows" flickering will stop.

I've tried everything possible but I can't fix it. It only helps me if I use, for example, LockWindowUpdate(MaskEdit1->Handle); However, it has the disadvantage that it can only be used for one component. If I have more Edit boxes, I won't stop the other ones from flashing.

Hi,

I'll look into this issue as soon as possible.

Hi,

We have tested this here but can't reproduce the issue. From which IDe do you run this? Do you run this on a remote deskop, or virtual machine?

I use Rad Studio 12.2 on Windows 11. This version is 64bit. Can I send to you a simple project?

Hi,

Yes, you can attach it here

Flick.zip (119.7 KB)
It also flashes directly in the Rad Studio design environment when the size of Form1 changes.

Pieter did you manage to repeat the flickering, because this way I don't know where the problem is?

Hi,

We have tried compiling and running the demo but unfortunately could not due to the requirement vclxfiles290.lib, which presumably is another third-party library that we don't have here. Please make sure to limit the demo to TMS controls only so we can run and investigate it here.

Sorry in project file was old components. I create new clean project.
Flick2.zip (10.2 KB)

Hi Pieter,

Is it ok and can it be compiled?

It can be compiled and we can reproduce it, but unfortunately did not yet found the cause.

Thank you for test. That's enough for me while I'm not the only one with this problem. Any other style than Windows causes flickering. In this simple version it is not so visible, but when I put more components and pages it was already quite unpleasant and the whole window jumps when resizing. I started to move TEdit outside TMSFNCRibbon but it's a big shame because this component is excellently made.

Finally I found a solution, although it is not the most elegant but at least it works. I placed TTMSFNCRibbonToolBar on TPanel instead of TTMSFNCRibbonPageControlContainer. This disabled the ToolBar->Compact option, so I had to program it into Panel1Resize:

//---------------------------------------------------------------------------
#include // For state tracking
std::map<TTMSFNCToolBar*, int> originalWidths; // Stores original (non-compacted) widths of toolbars
std::map<TTMSFNCToolBar*, bool> toolbarState;

int CacheOriginalWidths(TObject *Sender) // Cache the non-compacted widths of all toolbars
{
int Comp = 0;
for (int i = 0; i < ((TPanel *)Sender)->ControlCount; i++)
{
TTMSFNCToolBar *ToolBar = dynamic_cast<TTMSFNCToolBar *>(((TPanel *)Sender)->Controls[i]);
if (ToolBar)
{
if (ToolBar->Compact) Comp++;
if (originalWidths.find(ToolBar) == originalWidths.end()) // Only cache once
{
ToolBar->Compact = false; // Temporarily expand to get full width
originalWidths[ToolBar] = ToolBar->Width;
ToolBar->Compact = ToolBar->Compact; // Restore original state
}
}
}
return Comp;
}

void __fastcall TForm1::Panel1Resize(TObject *Sender)
{
int Comp = CacheOriginalWidths(Sender); // Ensure we have the non-compacted widths cached
for (int i = 0; i < ((TPanel *)Sender)->ControlCount; i++)
{
TTMSFNCToolBar *ToolBar = dynamic_cast<TTMSFNCToolBar *>(((TPanel )Sender)->Controls[i]);
if (ToolBar)
{
int toolbarEnd = ToolBar->Left + originalWidths[ToolBar] + Comp
ToolBar->CompactWidth; // Right-most edge of the toolbar
bool shouldCompact = (toolbarEnd > ((TPanel *)Sender)->Width);
if (shouldCompact && !toolbarState[ToolBar])
{
ToolBar->Compact = true;
toolbarState[ToolBar] = true;
}
else if (!shouldCompact && toolbarState[ToolBar])
{// Expand only if not already expanded and room is available
ToolBar->Compact = false;
toolbarState[ToolBar] = false; // Mark as expanded
}
}
}
}
//---------------------------------------------------------------------------

and it looks like this
Flickering

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.