CreateWindow with AVWindowNewFromPlatformThing

New Here ,
Jul 30, 2018

Copy link to clipboard

Copied

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);

  }


  return 0;

}


void SpawnWindow(std::string title) {

  const char 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;

}

My personal recommendation is don’t go down this path.

If you wish put your own windows up in Acrobat from a plugin – either just do it all using native stuff (and don’t bother with Acrobat) or use wxWidgets, as shown in the sample.

TOPICS
Acrobat SDK and JavaScript

Views

251

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CreateWindow with AVWindowNewFromPlatformThing

New Here ,
Jul 30, 2018

Copy link to clipboard

Copied

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);

  }


  return 0;

}


void SpawnWindow(std::string title) {

  const char 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;

}

My personal recommendation is don’t go down this path.

If you wish put your own windows up in Acrobat from a plugin – either just do it all using native stuff (and don’t bother with Acrobat) or use wxWidgets, as shown in the sample.

TOPICS
Acrobat SDK and JavaScript

Views

252

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 30, 2018 0
Adobe Employee ,
Jul 30, 2018

Copy link to clipboard

Copied

My personal recommendation is don’t go down this path.

If you wish put your own windows up in Acrobat from a plugin – either just do it all using native stuff (and don’t bother with Acrobat) or use wxWidgets, as shown in the sample.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2018 2
New Here ,
Jul 30, 2018

Copy link to clipboard

Copied

Thank you for your quick response.

Okay, I'll probably just do it without the functions then.

The only thing I'll be missing is the minimizing of my window if acrobat is minimized, which is no problem for me.

Could you kindly point me to a callback that gets fired when acrobat shuts down, if there is any?

So I can send a wm_close message to my windows and destroy them before acrobat exits.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2018 0
lrosenth LATEST
Adobe Employee ,
Jul 30, 2018

Copy link to clipboard

Copied

I believe there is an AVAppWillExit or AVAppWillQuit event that can register for…

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2018 1