PowerRename: bring the rename dialog to foreground

This commit is contained in:
yuyoyuppe
2020-02-12 19:18:38 +03:00
committed by Andrey Nekrasov
parent 1e6936a8c3
commit 9607888fc5
2 changed files with 9 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
#include <helpers.h>
#include <settings.h>
#include <windowsx.h>
#include <thread>
#include <trace.h>
extern HINSTANCE g_hInst;
@@ -512,6 +513,12 @@ HRESULT CPowerRenameUI::_DoModal(__in_opt HWND hwnd)
}
return hr;
}
void CPowerRenameUI::BecomeForegroundWindow()
{
static INPUT i = {INPUT_MOUSE, {}};
SendInput(1, &i, sizeof(i));
SetForegroundWindow(m_hwnd);
}
HRESULT CPowerRenameUI::_DoModeless(__in_opt HWND hwnd)
{
@@ -520,6 +527,7 @@ HRESULT CPowerRenameUI::_DoModeless(__in_opt HWND hwnd)
if (NULL != CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), hwnd, s_DlgProc, (LPARAM)this))
{
ShowWindow(m_hwnd, SW_SHOWNORMAL);
BecomeForegroundWindow();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{

View File

@@ -86,6 +86,7 @@ private:
HRESULT _DoModal(__in_opt HWND hwnd);
HRESULT _DoModeless(__in_opt HWND hwnd);
void BecomeForegroundWindow();
static INT_PTR CALLBACK s_DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{