To Create a floating palette in Acrobat/Photoshop plugin two simple steps are needed – use CreateDialog() and ShowWindow() along with SDK specific floating palette flag (if any needed).
First Step is to create palette by using CreateDialog().
// Get the parent window HWND here. either use your SDK API’s or WIN32 API’s
HWND hParent = WinAppGetModalParent(AVAppGetActiveDoc()); //Acrobat specific HWND hParent = GetActiveWindow(); // WIN32 API, use it in photoshop
// Create the floating palette window and register callbackMyPaletteProc
HWND dialog = CreateDialog(gHINSTANCE, // it is instance handle of the plug-in MAKEINTRESOURCE(IDD_DIALOG1), // use resource dialog, IDD_DIALOG1 is the id of your dialog in resource.
hParent, // parent application HWND
(DLGPROC) MyPaletteProc); // callback function
In Photoshop use:
GetDLLInstance(gPlugInRef) in place of gHINSTANCE
|
Second step is to Register palette with Application and Show palette at WM_INITDIALOG opcode.
// here comes the dependency with SDK, you need to findout the API to register dialog and flag for floating palette.
// for acrobat SDK use following:
sAVWin = AVWindowNewFromPlatformThing(AVWLfloating, 0, NULL, gExtensionID, hWndDlg); // for photoshop plug-in, no registration required, just call ShowDialog.
// call this function to display palette on top. If you missed this, palette will remain invisible
![]() ShowWindow(hWndDlg, SW_SHOW); Complete code for Acrobat Plug-in is:
|
HWND dialog = NULL; void CreateDialog() { INT_PTR nRetVal ; HWND CapturehWnd, hParent; CapturehWnd = GetCapture(); if ( CapturehWnd != NULL ) { ReleaseCapture(); } hParent = WinAppGetModalParent(AVAppGetActiveDoc()); dialog = CreateDialog(gHINSTANCE, MAKEINTRESOURCE(IDD_DIALOG1), hParent, (DLGPROC) MyDialogProc); if ( CapturehWnd != NULL ) { SetCapture( CapturehWnd ); } } LRESULT CALLBACK MyDialogProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_INITDIALOG: { sAVWin = AVWindowNewFromPlatformThing(AVWLfloating, 0, NULL, gExtensionID, hWndDlg); ShowWindow(hWndDlg, SW_SHOW); return TRUE; } break; case WM_COMMAND: { switch(wParam) { case IDOK: { // TODO:: Write code here for OK button click handling EndDialog(hWndDlg, 0); return TRUE; } break; case IDCANCEL: { // TODO:: Write code here for CANCEL button click handling EndDialog(hWndDlg, 0); return FALSE; } break; } } break; case WM_DESTROY: { AVWindowDestroy(sAVWin); } break; } return FALSE; }
Now call CreateDialog() function where you want to instantiate your palette, at Menu item click probably.