예제 #1
0
 int MouseProc(int /* long */ code, int /* long */ wParam, int /* long */ lParam) {
   int result = Extension.CallNextHookEx(oldAddress, code, wParam, lParam);
   if (code < 0) return result;
   switch (wParam) {
     case Win32.WM_NCLBUTTONDOWN:
     case Win32.WM_NCRBUTTONDOWN:
       hideMenu();
       break;
   }
   return result;
 }
예제 #2
0
  private void installMouseHook() {
    if (mouseCallback == null) {
      mouseCallback = new Callback(this, "MouseProc", 3);
      newAddress = mouseCallback.getAddress();
      if (newAddress == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
      int threadId = Extension.GetCurrentThreadId();
      oldAddress = Extension.SetWindowsHookEx(Win32.WH_MOUSE, newAddress, 0, threadId);
      shell.addDisposeListener(
          new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
              if (mouseCallback != null) {
                Extension.UnhookWindowsHookEx(oldAddress);
                mouseCallback.dispose();
                mouseCallback = null;
                newAddress = 0;
              }
            }
          });
    }
  }