I can use DialogBoxIndirectParam with no problem. But it's a modal dialog box, and I have to close it to use the VST plugin.
HOWEVER, in the code snippets below, with the lines for using DialogBoxIndirectParam commented out,
when I try using CreateDialogIndirectParam with any plugin, the VST plugin window appears, but then stays stuck in limbo, with the hour-glass symbol staying
(WM_INITDIALOG is called, but WM_KEYDOWN and WM_COMMAND can't be gotten to).
What am I doing wrong?
(the entire source code is at http://jdmcox.com/PianoRollComposer.cpp)
Code: Select all
//this is in the main thread:
struct MyDLGTEMPLATE: DLGTEMPLATE {
MyDLGTEMPLATE () { memset (this, 0, sizeof (*this)); };
WORD ext[3];
};
MyDLGTEMPLATE dt;
// this is in VSTthread:
dt.style = WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_BORDER|WS_SYSMENU;
//DialogBoxIndirectParam(hModule[plugin], (LPCDLGTEMPLATE)&dt, NULL, (DLGPROC)EditorProc, (LPARAM)effect[plugin]);
hwndDialog[plugin] = CreateDialogIndirectParam((HINSTANCE)hModule[plugin], (LPCDLGTEMPLATE)&dt, NULL, (DLGPROC)EditorProc, (LPARAM)effect[plugin]);
//this is in the main thread:
LRESULT CALLBACK EditorProc(HWND hwndedit, UINT msg, WPARAM wParam, LPARAM lParam)
{
static AEffect* theEffect;
static ERect* eRect;
static RECT editorRect;
switch(msg)
{
case WM_INITDIALOG:
theEffect = (AEffect*)lParam; // effect[plugin]
SetWindowText (hwndedit, TEXT(" *** CLOSE THIS TO USE PLUG-IN ***")); // necessary with DialogBoxIndirectParam
if (theEffect) {
editoropen = TRUE;
theEffect->dispatcher(theEffect, effEditOpen, 0, 0, hwndedit, 0);
eRect = 0;
theEffect->dispatcher(theEffect, effEditGetRect, 0, 0, &eRect, 0);
if (eRect)
MoveWindow(hwndedit, eRect->left, eRect->top, eRect->right - eRect->left, eRect->bottom - eRect->top+Title, TRUE);
}
break;
case WM_KEYDOWN: // to refresh EastWest's window
if (eRect) {
editorRect.top = eRect->top;
editorRect.bottom = eRect->bottom;
editorRect.left = eRect->left;
editorRect.right = eRect->right;
InvalidateRect(hwndedit, &editorRect, FALSE);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
case WM_CLOSE:
editoropen = FALSE;
if (theEffect)
theEffect->dispatcher (theEffect, effEditClose, 0, 0, 0, 0);
// EndDialog (hwndedit, TRUE);
// return TRUE;
DestroyWindow(hwndDialog[plugin]);
hwndDialog[plugin] = NULL;
break;
}
break;
}
// return 0;
return DefWindowProc(hwndedit, msg, wParam, lParam);
}