相关文章推荐

Hi,

We are trying to create a modal dialog in Illustrator CS6 plug-in using Qt.

But when we call QDialog::exec() method, dialog appears but it is not modal, we can interact with panels (move them, select colors from palette and so on).

The code that we are using looks like:

static HWND mainHWND = ::FindWindow(NULL, L"Adobe Illustrator CS6");

MyDialog *dialog = new MyDialog(new QWinWidget(mainHWND));

dialog->exec();

or simply

QMessageBox::about(new QWinWidget(mainHWND), "title", "text");

In both cases dialog and message box are not modal.

The only way to create a custom modal dialog we have found is using Flash, but it is not acceptable for us.

Could you suggest how to do this with Qt?

Thanks!

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 03, 2013 Dec 03, 2013

You need to make sure you're parenting off the right handle. The main window you want to parent off is called 'illustrator'. We have code that goes looking for it the first time it's requested and then after that it caches the handle since it obviously isn't going anywhere until Illustrator closes.

This is how we figured out which handle to use:

  1. Fire up Spy++ and find the Illustrator family of handles.
  2. Put a breakpoint in your code where you create the MyDialog object and try different handles you read manually from Spy++.
  3. When you find the one that works, just figure out how to use Win32 calls to get the right handle. You can verify that again using Spy++.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 09, 2013 Dec 09, 2013

Thanks for your reply.

We have tried the suggested method and looked over all windows in the Illustrator process, but still can't create a dialog, that would block all Illustrator UI.

At best (when we are parenting from a window with the class name 'illustrator') we can create a dialog, that blocks the main window (all menus and tools), but panels are still not blocked i.e. we can move them and select tools from them (see video http://screencast.com/t/3e82I118 ).

Do you have any other idea how to block them?

Have you managed to block them using your method?

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 09, 2013 Dec 09, 2013

Hmm. The funny thing is, that sounds familliar. I feel I've seent that behaviour, but looking at our code, nothing jumps out at me that looks like it would address that problem.

We have a small library we've built that has a generic base modal dialog class off of which all our modal dialogs derive -- it handles things like making sure its parented off the current Qt dialog (by determining if one exists, and finding it) or failing that, main Illustrator window if nothing else is open. We also have a class for the 'main application window' but looking at its code, ti seems to largely be a container for the found window handle (and some helpful methods for finding the main window handle). So nothing there.

I'm honestly not sure. Maybe the flags you send to the dialog? I know we had to tinker with them to get them just so. It looks like we use:

// for resizable

const Qt::WindowFlags kDefaultWindowFlags = Qt::CustomizeWindowHint | Qt::Window | Qt::WindowTitleHint;

// for fixed

const Qt::WindowFlags kDefaultWindowFlagsFixed = kDefaultWindowFlags | Qt::MSWindowsFixedSizeDialogHint;

It also looks like we manually set 'setModal(true)' as the first line of our constructor. I don't know why that would matter, but perhaps it does?

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 10, 2013 Dec 10, 2013

Yes, we set 'setModal(true)' manually too, and we tried this combinations of flags, nothing helps.

There is a function in Acrobat API called AVAppBeginModal, that " Prepares the Acrobat viewer to display a modal window.

For example, it disables floating windows in Windows, where they are not automatically disabled."

May be there is some analog in Illustrator and your base class calles it?

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 10, 2013 Dec 10, 2013

On Mac, we have to call something that turns off the menus, but not in Windows.

I've just re-checked all our code and I can't find anything. We have a base class for modal dialogs, but there's nothing in there that does anything Illustrator-specific. It just sets the modality and handles a bunch of things like restoring & saving dialog geometry (to remember positioning) and other little hacks/tweaks for things I'm 100% sure aren't related to modality.


We have a singleton class derived from CWinWidget that represents the main application window. It doesn't have much at all frankly, it mostly looks like it exists to figure out which window to use as its base handle when creating itself and then is a singleton so it doesn't have to keep doing that.

I looked at our QApplication-derived class, and again, lots of Mac code but not a lot of Windows stuff. It doesn't have anything either. It looks like so long as we have picked up the right Illustrator window handle for our QWinWidget, it just works on Windows.

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Dec 15, 2013 Dec 15, 2013
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
 
推荐文章