My app has a hidden native win32 window, that listens fro global hotkeys (the way that was shown somewhere here on the forums), it’s a class that’s a Thread class, listens for message events, using a static callback and a pointer to my class it passed events to my MainWindow class. On win32 it workes (i use actionListener/Broadcaster combination to notify my Juce classes), but on WIN64 i get exceptions when i get those events. I was getting them due to MessageManagerLocks (when i tried locking the message manager before touching the GUI part of the main window, i got a application halt so i stopped doing that). So i figured i’ll use AsyncUpdater, but now that causes other errors in _tmain
#ifdef _WINMAIN_
lpszCommandLine = _twincmdln();
mainret = _tWinMain( (HINSTANCE)&__ImageBase,
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow
: SW_SHOWDEFAULT
); <- exception
#else /* _WINMAIN_ */
_tinitenv = _tenviron;
mainret = _tmain(__argc, _targv, _tenviron);
#endif /* _WINMAIN_ */
everthing is fine if i don’t call triggerAsyncUpdate() in my class that gets the info, once i do that, it crashes.
Is there anything specific to WIN64 and different from WIN32 that i should consider ?
the code in the Thread class that i use to create the win32 native window
void Win32NotificationWindow::run()
{
MSG Msg;
int rval;
//
// register the window class
//
WNDCLASSEXA wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = Win32NotificationWindow::WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = GetModuleHandle(NULL);
wcex.hIcon = 0;
wcex.hCursor = 0;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = classname;
wcex.hIconSm = 0;
RegisterClassExA(&wcex);
//
// make the window
//
hWindow = CreateWindowEx (
0,
(LPCSTR)classname,
(LPCSTR)"Winamp Controller Utility",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
GetModuleHandle(NULL),
NULL
);
if (NULL == hWindow)
{
DWORD e = GetLastError();
return;
}
else
{
const KeyPress kp = KeyPress::createFromDescription (keyCodeDescription);
if ( RegisterHotKey(hWindow, 0x0aff, kp.getModifiers().getRawFlags(), kp.getKeyCode()) )
{
/* */
}
else
{
DWORD e = GetLastError();
AlertWindow::showMessageBox (AlertWindow::InfoIcon, T("Global hotkey register error"), T("I was unable to register the global hotkey, maybe try a different combination ") + String ((uint32)e));
}
}
//
// Save the "this" pointer in the window
//
if ( (SetWindowLongPtrA(hWindow,(int) GWLP_USERDATA,(__int3264) (LONG_PTR) this) ) == 0)
{
DWORD e = GetLastError();
}
//
// listen to the message loop
//
while ( (rval = GetMessage(&Msg, hWindow, 0, 0)) != 0)
{
if (-1 == rval)
{
DWORD e = GetLastError();
return;
}
else
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
}
then the WndProc looks like this
LRESULT CALLBACK Win32NotificationWindow::WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LONG_PTR context;
Win32NotificationWindow *that;
context = GetWindowLongPtrA (hwnd, GWLP_USERDATA);
that = (Win32NotificationWindow *) context;
if (that && uMsg == WM_HOTKEY)
{
that->windowsCallback(lParam);
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
and somewhere in windowsCallback i have the triggerAsyncUpdate() called.