COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 08-17-2017, 02:58 PM   #1
Opcode 7
Human being with feelings
 
Join Date: Mar 2017
Posts: 25
Default CreateWindow returning NULL HWND in VST Hosts?

I am trying to create & open a Modal/Modeless Dialog Window in my VST. It works when running in Application mode, but Win32's "CreateWindow" is returning a NULL HWND when running in a VST Host.

What am I doing wrong / missing?

Here's how Im doing it :

Quote:
INT_PTR OpenDialog(char* szAppName, int resourceId, DLGPROC procWindow)
{
HWND hwndDlg = CreateWindow(
szAppName,
szAppName,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
(HWND)mPlug->GetGUI()->GetWindow(),
NULL,
mPlug->GetGUI()->GetInstance(),
NULL);

return DialogBoxA(GetModuleHandleA(NULL), MAKEINTRESOURCE(resourceId), hwndDlg, procWindow);
}


OpenDialog("Test", DIALOG_TEST, TestDlgProc);
Is it possible?

Last edited by Opcode 7; 08-17-2017 at 03:09 PM.
Opcode 7 is offline   Reply With Quote
Old 08-17-2017, 03:32 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,723
Default

It is probably possible to get it working in some way, but maybe you should reconsider why you actually want to do that at all. (Have you tried with just a simple MessageBox call, does it behave as expected?)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is offline   Reply With Quote
Old 08-17-2017, 03:48 PM   #3
Opcode 7
Human being with feelings
 
Join Date: Mar 2017
Posts: 25
Default

Edit:

Woop woop! I figured it out through lots of finding references, and reading through all the code --

In summary : In the .rc resource file, at the top I noticed resources are only included if #ifdef SA_API is defined, so by defining that (or removing that condition all together), and changing my code to as follows, I got dialogs to open from within VST Hosts :

Quote:
INT_PTR OpenDialog(char* szAppName, int resourceId, DLGPROC procWindow)
{
IGraphicsWin* pGraphics = (IGraphicsWin*)mPlug->GetGUI();

INT_PTR retVal = DialogBoxA(mPlug->GetGUI()->GetInstance(), MAKEINTRESOURCE(resourceId), (HWND)pGraphics->GetMainWnd(), procWindow);

DBGMSG("%X", GetLastError());

return retVal;
}

Last edited by Opcode 7; 08-18-2017 at 05:33 PM.
Opcode 7 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.