0

I've made an InDesign plugin (in C++) that loads a DLL. I've been able to call its methods and handle its events in my plugin.

Now, I'm stuck with a thing—

I want to get the event when the InDesign application is minimized/maximized and perform some function on that event.

I tried using the InDesign messages but its not fulfilling the purpose since I'm getting some ambiguous results with that.

I guess this can also be accomplished using the WinAPI. If yes, I want to know how— any sample code / tutorial would be helpful.

Charles
  • 50,943
  • 13
  • 104
  • 142
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90

1 Answers1

2

Have a look at the WM_SIZE message

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
     {
         // The code for handling other Windows messages has been omitted for clarity.
         // ...
        case WM_SIZE:
            {
                INT nWidth = LOWORD(lParam);
                HWND hEditBox = GetDlgItem(hWnd, IDC_EDIT);
                HWND hEnterButton = GetDlgItem(hWnd, IDC_BUTTON);

                MoveWindow(hEditBox, 8, 4, nWidth - 70, 20, TRUE);
                MoveWindow(hEnterButton, nWidth - 57, 4, 50, 20, TRUE);
            }
            break;
    }
}
  • @Sahil http://ideone.com/ejXQJz is an example I found on keyboard hooking, but it hooks windows messages, and then listens to the keyboard messages, so you can modify it –  Jun 11 '13 at 09:26
  • Only that much I've to include in the code? any headers? sorry I'm new to this. – Sahil Mittal Jun 11 '13 at 10:20
  • I got too many errors compiling this. like: Identifiers not found : `KEY_DOWN`, `KEY_UP`, `g_Input`, `cheat_state`, `set`, `keyhook_uninstall` etc. and many others.. – Sahil Mittal Jun 11 '13 at 12:20
  • you are not supposed to copy paste but grab the idea of using SetWindowsLong and callbacks for hooking application messages. –  Jun 11 '13 at 12:29
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/31585/discussion-between-sahil-and-gam-erix) – Sahil Mittal Jun 11 '13 at 12:30
  • I used `SetWindowLong(hwnd, GWL_WNDPROC, (long)myProc);` for my application. `hwnd` is the System Window of the application; `GWL_WNDPROC` is the value of `nIndex` — I'm not really sure what value should be given! With this, it get inside the myProc to receive messages, but the problem is that the InDesign's menu and the panels become inactive, even I'm not able to min/max the InDesign. Why so? – Sahil Mittal Jun 13 '13 at 13:22