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.
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.
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.
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] + CompToolBar->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
}
}
}
}
//---------------------------------------------------------------------------