Skip to main content
Participant
August 18, 2009
Question

Modal dialog in Premiere Pro (using AE SDK)

  • August 18, 2009
  • 1 reply
  • 2455 views

Hello all,

I have a plugin that does some long, intensive processing inside a single render call. I show my own progress bar in a modal dialog while this happens.

This is working fine in After Effects, but it's causing a crash in Premiere Pro. I get a few messages through the WndProc but then they just stop coming. I've attached some code below. Does anyone have any idea what might be going on there?

many thanks for any help,

Hugh

Here's the code that creates the dialog:

//assume host window is foregrounded

hostWindow = GetForegroundWindow();

// also tried HWND hwnd; PF_GET_PLATFORM_DATA(PF_PlatData_MAIN_WND, &hwnd);


hDlg = CreateDialog(theDLL, MAKEINTRESOURCE(IDD_PROGRESS), hostWindow, reinterpret_cast<DLGPROC>(DlgProc));

SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)this);


CenterDialog();


ShowWindow(hDlg, SW_SHOW); UpdateWindow(hDlg);

SetForegroundWindow(hDlg); BringWindowToTop(hDlg);

hProgress = GetDlgItem(hDlg, IDC_PROGRESS1);

SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, total));

and here's the window proc:
static LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
ProgressDialog *myOwner = (ProgressDialog*)GetWindowLongPtr(hWndDlg, GWLP_USERDATA);

switch(Msg)
{
case WM_INITDIALOG:
        case WM_WINDOWPOSCHANGING:
return TRUE;

case WM_NCLBUTTONDOWN: //prevent user moving the dialog box
if (HTCAPTION == wParam) return TRUE;
else return FALSE;

case WM_COMMAND:
switch(wParam)
{
case IDOK:
return TRUE;
case IDCANCEL:
myOwner->cancelled=true;
return TRUE;
}
break;
}
return FALSE;
}

This topic has been closed for replies.

1 reply

hdenmanAuthor
Participant
August 20, 2009

Here's the code that is called periodically inside my processing to run the message pump, in case that's helpful:

SendMessage(hProgress, PBM_SETPOS, pos, 0);

HWND hProgText = GetDlgItem(hDlg, IDC_TEXT_PROG);

std::stringstream myStr;

myStr << "Frame " << pos << "/" << total;

SetWindowText(hProgText, myStr.str().c_str());

MSG Msg;

SendMessage(hostWindow,WM_ENTERIDLE,0,0L);

while (PeekMessage(&Msg, hDlg, 0, 0, TRUE)) {

if (!IsDialogMessage(hDlg, &Msg)) {

TranslateMessage(&Msg); DispatchMessage(&Msg);

}

}

Inspiring
August 31, 2009

Hi Hugh,

In general, it's not safe to display UI in PPro on a render thread, otherwise you'll trigger hangs like these.  Even without the hangs, popping a modal dialog on render could be pretty intrusive.  The user could scrub across several different frames, triggering several asynchronous renders, and then several modal dialogs would pop.  Without the modal dialog, even if the processing is running for several seconds, the UI could still remain responsive, and could allow the user to do further editing.

Zac