[BUG_FIXED] Fix the annoying acrobat reader dialog problem.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@154 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-03-27 00:53:06 +00:00
parent 99faa2bc0f
commit 92c229a57a
1 changed files with 44 additions and 35 deletions

View File

@ -25,25 +25,33 @@
BOOL DockingManager::_isRegistered = FALSE; BOOL DockingManager::_isRegistered = FALSE;
//Window of event handling DockingManager (can only be one)
static HWND hWndServer = NULL; static HWND hWndServer = NULL;
static HWINEVENTHOOK gWinEvtHook = NULL; //Next hook in line
static HHOOK gWinCallHook = NULL;
LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam);
/* Callback function that handles events */ /* Callback function that handles messages (to test focus) */
void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND hwnd, LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
LONG idObject, LONG idChild, if (nCode == HC_ACTION && hWndServer) {
DWORD dwEventThread, DWORD dwmsEventTime) DockingManager *pDockingManager = (DockingManager *)::GetWindowLong(hWndServer, GWL_USERDATA);
{ if (pDockingManager) {
IAccessible* pAcc = NULL; vector<DockingCont*> & vcontainer = pDockingManager->getContainerInfo();
VARIANT varChild; CWPSTRUCT * pCwp = (CWPSTRUCT*)lParam;
HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild); if (pCwp->message == WM_KILLFOCUS) {
if ((hr == S_OK) && (pAcc != NULL)) for (int i = 0; i < DOCKCONT_MAX; i++)
{ {
if (event == EVENT_OBJECT_FOCUS) vcontainer[i]->SetActive(FALSE); //deactivate all containers
{ }
::SendMessage(hWndServer, DMM_LBUTTONUP, 0, (LPARAM)hwnd); } else if (pCwp->message == WM_SETFOCUS) {
} for (int i = 0; i < DOCKCONT_MAX; i++)
pAcc->Release(); {
} vcontainer[i]->SetActive(IsChild(vcontainer[i]->getHSelf(), pCwp->hwnd)); //activate the container that contains the window with focus, this can be none
}
}
}
}
return CallNextHookEx(gWinCallHook, nCode, wParam, lParam);
} }
DockingManager::DockingManager() DockingManager::DockingManager()
@ -114,19 +122,6 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)
throw int(777); throw int(777);
} }
/* register window event hooking */
hWndServer = _hSelf;
CoInitialize(NULL);
gWinEvtHook = SetWinEventHook(
EVENT_OBJECT_FOCUS, EVENT_OBJECT_FOCUS, NULL,
HandleWinEvent, 0, 0, WINEVENT_OUTOFCONTEXT);
if (!gWinEvtHook)
{
systemMessage("System Err");
throw int(1000);
}
setClientWnd(ppWin); setClientWnd(ppWin);
/* create docking container */ /* create docking container */
@ -141,6 +136,18 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)
else else
_vSplitter[iCont]->init(_hInst, _hParent, _hSelf, DMS_VERTICAL); _vSplitter[iCont]->init(_hInst, _hParent, _hSelf, DMS_VERTICAL);
} }
/* register window event hooking */
if (!hWndServer)
hWndServer = _hSelf;
CoInitialize(NULL);
if (!gWinCallHook) //only set if not already done
gWinCallHook = SetWindowsHookEx(WH_CALLWNDPROC, FocusWndProc, NULL, GetCurrentThreadId());
if (!gWinCallHook)
{
systemMessage("System Err");
throw int(1000);
}
_dockData.hWnd = _hSelf; _dockData.hWnd = _hSelf;
@ -206,11 +213,15 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
} }
/* unregister window event hooking */ /* unregister window event hooking */
UnhookWinEvent(gWinEvtHook); if (hWndServer == hwnd) {
UnhookWindowsHookEx(gWinCallHook);
gWinCallHook = NULL;
hWndServer = NULL;
}
CoUninitialize(); CoUninitialize();
break; break;
} }
case DMM_LBUTTONUP: case DMM_LBUTTONUP: //is this message still relevant?
{ {
if (::GetActiveWindow() != _hParent) if (::GetActiveWindow() != _hParent)
break; break;
@ -218,9 +229,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
/* set respective activate state */ /* set respective activate state */
for (int i = 0; i < DOCKCONT_MAX; i++) for (int i = 0; i < DOCKCONT_MAX; i++)
{ {
_vContainer[i]->SetActive( _vContainer[i]->SetActive(IsChild(_vContainer[i]->getHSelf(), ::GetFocus()));
IsChild(_vContainer[i]->getHSelf(), (HWND)lParam) &&
(::GetFocus() == (HWND)lParam));
} }
return TRUE; return TRUE;
} }