Skip to content

Commit

Permalink
Better handling of N++ focus restore after compare
Browse files Browse the repository at this point in the history
Suggested by UFO and Yaron to avoid SetForegroundWindow
  • Loading branch information
pnedev committed Mar 15, 2016
1 parent 2e1583d commit 1804fae
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,10 @@ bool compareNew()
unsigned int *doc2Hashes = computeHashes(doc2, doc2Length, Settings.IncludeSpace);

/* show progress dialog */
SetFocus(nppData._scintillaMainHandle);
SendMessage(nppData._nppHandle, NPPM_GETFILENAME, 0, (LPARAM)filenameMain);
SetFocus(nppData._scintillaSecondHandle);
SendMessage(nppData._nppHandle, NPPM_GETFILENAME, 0, (LPARAM)filenameSecond);
SetFocus(nppData._scintillaMainHandle);
SendMessage(nppData._nppHandle, NPPM_GETFILENAME, 0, (LPARAM)filenameMain);

if (_tcslen(filenameMain) > 28)
_tcscpy_s(filenameMain + 25, 4, TEXT("..."));
Expand Down Expand Up @@ -1260,13 +1260,12 @@ bool compareNew()
//clean up resources
#if CLEANUP

EnableWindow(nppData._nppHandle, TRUE);

bool compareCanceled = progDlg->IsCancelled();
progDlg->Close();
delete progDlg;

EnableWindow(nppData._nppHandle, TRUE);
SetForegroundWindow(nppData._nppHandle);
SetFocus(nppData._scintillaMainHandle);
UpdateWindow(nppData._nppHandle);

if (result != -1)
Expand Down

0 comments on commit 1804fae

Please sign in to comment.