Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

In C++ plugin development, how do you set the position of a panel or dialog on the screen?

Explorer ,
Apr 21, 2025 Apr 21, 2025

I have obtained the IControlView of the panel or dialog, and then called the MoveTo function, but it doesn't change the window's position. For the panel, I obtained the IWidgetParent interface through IControlView, and then got the IWindow interface by calling:

InterfacePtr<IWidgetParent> myParent(panelControw, UseDefaultIID());
InterfacePtr<IWindow> iWindow((IWindow*)myParent->QueryParentFor(IWindow::kDefaultIID));

For dialogs, I created a new dialog using:

IDialog* dialog = dialogMgr->CreateNewDialog(dialogSpec, IDialog::kMovableModal);

 Then I got the IWindow interface through:

InterfacePtr<IWindow> iWindow(dialog, UseDefaultIID());

Afterwards, I called the SetPosition function of the IWindow interface, but still couldn’t change the window's position. Has anyone encountered this issue before? Any guidance or advice from more experienced developers would be greatly appreciated. Thank you.

TOPICS
SDK
321
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Apr 21, 2025 Apr 21, 2025

Get the panel via IDialog::GetDialogPanel, e.g. for Resize()

For moving, I used IDialog::SetDialogPositioningAlgorithm(IDialog::kAutoCenter);

If you need non-center, dive into the header comments.

 

I leave palette panel positions to the user, as they are determined by the holding palettes anyway.

You can arrange these palettes and groups e.g. docked to some screen margin.

 

For a large set of panels I added a menu to some Window submenu to collect them into a new palette with tab group, stacked etc. r

...
Translate
Mentor ,
Apr 21, 2025 Apr 21, 2025

Get the panel via IDialog::GetDialogPanel, e.g. for Resize()

For moving, I used IDialog::SetDialogPositioningAlgorithm(IDialog::kAutoCenter);

If you need non-center, dive into the header comments.

 

I leave palette panel positions to the user, as they are determined by the holding palettes anyway.

You can arrange these palettes and groups e.g. docked to some screen margin.

 

For a large set of panels I added a menu to some Window submenu to collect them into a new palette with tab group, stacked etc. rather than the random initial group. Also doing that from an Initializer for startup once after installation.

 

Not sure about actual position, but if you find nothing better have a look at the top of PaletteRef.h and GetOWLControl()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2025 Apr 21, 2025

Thank you, Dirk Becker,I have already found a method. By using the following function, I can set the position of the panel.

PaletteRef paletteref = panelMgr->GetPaletteRefContainingPanel(panel);
PaletteRefUtils::SetPalettePosition(paletteref, 300, 300);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 22, 2025 Apr 22, 2025
LATEST

I wrote on a tiny laptop where I missed SetPalettePosition, should also have more emphasized that it is all about PaletteRef. Thanks for sharing.

 

Make also sure before positioning that your palette is not docked by the user.

 

For your test cases, remember to test both UI scalings - via OS and via InDesign's preferences.

One reason for annoying flicker and costly multiple redraws is when UI scaling bumps you to fractional pixels for position or size, then somewhere deep inside a resize tries to get you back to full pixels by another turn of size or move.

This is also relevant when you overload IControlView::ConstrainDimensions().

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines