I'm unsure where I have to call `AVWindowNewFromPlatformThing' and `AVWindowDestroy'.
Everything works fine until I exit Acrobat and get an alert box with `Adobe Acrobat DC has stopped working'.
I've tried to put the function calls everywhere without any success.
Problem signature:
Problem Event Name: BEX
Application Name: Acrobat.exe
Application Version: 18.11.20055.27899
Application Timestamp: 5b363d8a
Fault Module Name: pluginname.api_unloaded
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 5b5f717b
Exception Offset: 708eda78
Exception Code: c0000005
Exception Data: 00000008
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1031
Additional Information 1: 8508
Additional Information 2: 85082419dd18a94700c1143a806349b7
Additional Information 3: a9e2
Additional Information 4: a9e2f2cd020b33c1d41a5eff016d3fab
Where do I have to call `AVWindowNewFromPlatformThing' and `AVWindowDestroy' from and do I need to call `DestroyWindow' myself or not?
Code (with error handling removed):
AVWindow my_window;
LRESULT CALLBACK WindowCallback(HWND window_handle, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_CLOSE:
DestroyWindow(window_handle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(window_handle, msg, wParam, lParam);
}
return0;
}
void SpawnWindow(std::string title) {
constchar window_class_name[] = "myWindowClass";
WNDCLASSEX window_class;
HWND window_handle;
MSG window_message;
if (GetClassInfoEx(gHINSTANCE, window_class_name, &window_class) == 0) {
window_class.cbSize = sizeof(WNDCLASSEX);
window_class.style = 0;
window_class.lpfnWndProc = WindowCallback;
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = gHINSTANCE;
window_class.hIcon = LoadIcon(NULL, IDI_APPLICATION);
window_class.hCursor = LoadCursor(NULL, IDC_ARROW);
window_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
window_class.lpszMenuName = NULL;
window_class.lpszClassName = window_class_name;
window_class.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
}
window_handle = CreateWindowEx(
WS_EX_CLIENTEDGE, window_class_name,
title.c_str(), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
400, 300, 0, 0,
gHINSTANCE, NULL
);
my_window = AVWindowNewFromPlatformThing(NULL, NULL, NULL, gExtensionID, reinterpret_cast<AVPlatformWindowRef>(window_handle));
ShowWindow(window_handle, SW_SHOWDEFAULT);
UpdateWindow(window_handle);
while(GetMessage(&window_message, NULL, 0, 0) > 0) {
TranslateMessage(&window_message);
DispatchMessage(&window_message);
}
AVWindowDestroy(my_window);
UnregisterClass(window_class_name, gHINSTANCE);
return;
}