Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdb2ebd295 | ||
|
|
bd5d845ec1 | ||
|
|
a6c866d1dd | ||
|
|
38a570310f | ||
|
|
4a96fef1c7 | ||
|
|
0f47ebae9e | ||
| f8b925d0f8 | |||
| 35f791d7a0 | |||
|
|
4586599d2c | ||
| dfdbd6a94b | |||
| 5ef184bee3 | |||
| ce31a7d6e0 | |||
|
|
00a949f502 | ||
|
|
703fccaa15 |
@@ -1,2 +1,6 @@
|
||||
# wCenterWindow
|
||||
This program centers the current active window by a 'LCTRL + LWIN + C' hotkey.
|
||||
|
||||
'LCTRL + LWIN + I' hotkey - hide tray icon.
|
||||
|
||||
You can also use commandline option '/hide' for hide trayicon at startup.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.1000
|
||||
VisualStudioVersion = 15.0.28307.1082
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wCenterWindow", "wCenterWindow\wCenterWindow.vcxproj", "{6A775901-6C34-4E96-B359-C11C76A520BB}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wCenterWindow", "wCenterWindow\wCenterWindow.vcxproj", "{2494B3F2-585E-4A2E-A013-20A15AE25B9E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -13,19 +13,19 @@ Global
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Debug|x64.Build.0 = Debug|x64
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Debug|x86.Build.0 = Debug|Win32
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Release|x64.ActiveCfg = Release|x64
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Release|x64.Build.0 = Release|x64
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Release|x86.ActiveCfg = Release|Win32
|
||||
{6A775901-6C34-4E96-B359-C11C76A520BB}.Release|x86.Build.0 = Release|Win32
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Debug|x64.Build.0 = Debug|x64
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Release|x64.ActiveCfg = Release|x64
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Release|x64.Build.0 = Release|x64
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2494B3F2-585E-4A2E-A013-20A15AE25B9E}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CAD0B026-63B6-4645-9B26-22CD0E1049B7}
|
||||
SolutionGuid = {34E34C1F-8A53-40DA-BA24-78C20152D64C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// resource.h
|
||||
#define IDS_APP_TITLE 100
|
||||
#define IDS_CLASSNAME 101
|
||||
#define IDS_HELPTEXT 102
|
||||
#define IDI_TRAYICON 103
|
||||
#define IDR_MENU 104
|
||||
#define ID_POPUPMENU_HELP 105
|
||||
#define ID_POPUPMENU_EXIT 106
|
||||
#define IDS_ERR_MAIN 107
|
||||
#define IDS_ERR_WND 108
|
||||
#define IDS_ERR_ICON 109
|
||||
#define IDS_ERR_MENU 110
|
||||
#define IDS_ERR_POPUP 111
|
||||
#define IDS_ERR_HOOK 112
|
||||
#define IDS_RUNNING 113
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
// header.h: включаемый файл для стандартных системных включаемых файлов
|
||||
// или включаемые файлы для конкретного проекта
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows
|
||||
// Файлы заголовков Windows
|
||||
#include <windows.h>
|
||||
#include <strsafe.h>
|
||||
#include <shellapi.h>
|
||||
// Файлы заголовков среды выполнения C
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
19
wCenterWindow/resource.h
Normal file
19
wCenterWindow/resource.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#define IDS_APP_TITLE 100
|
||||
#define IDS_CLASSNAME 101
|
||||
#define IDS_ABOUT 102
|
||||
#define IDI_TRAYICON 103
|
||||
#define IDR_MENU 104
|
||||
#define ID_POPUPMENU_ICON 105
|
||||
#define ID_POPUPMENU_AREA 106
|
||||
#define ID_POPUPMENU_ABOUT 107
|
||||
#define ID_POPUPMENU_EXIT 108
|
||||
#define IDS_ERR_MAIN 109
|
||||
#define IDS_ERR_WND 110
|
||||
#define IDS_ERR_ICON 111
|
||||
#define IDS_ERR_MENU 112
|
||||
#define IDS_ERR_POPUP 113
|
||||
#define IDS_ERR_HOOK 114
|
||||
#define IDS_RUNNING 115
|
||||
#define IDC_STATIC -1
|
||||
@@ -1,2 +0,0 @@
|
||||
#pragma once
|
||||
#include <SDKDDKVer.h>
|
||||
@@ -1,92 +1,70 @@
|
||||
// wCenterWindow.cpp : Определяет точку входа для приложения.
|
||||
// wCenterWindow, v2.1
|
||||
|
||||
#include "framework.h"
|
||||
#include "wCenterWindow.h"
|
||||
#include <windows.h>
|
||||
#include <strsafe.h>
|
||||
#include "resource.h"
|
||||
#include "S:\MyFunctions\MoveWindowToMonitorCenter.h"
|
||||
|
||||
#define MAX_LOADSTRING 80
|
||||
#define WM_WCW WM_USER + 0x7F00
|
||||
#define MAX_LOADSTRING 32
|
||||
#define WM_WCW 0x8F00
|
||||
|
||||
// Глобальные переменные:
|
||||
HINSTANCE hInst; // Текущий экземпляр
|
||||
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
||||
WCHAR szClass[MAX_LOADSTRING]; // Имя класса главного окна
|
||||
WCHAR szHelp[MAX_LOADSTRING]; // Текст описания
|
||||
// Global variables:
|
||||
HINSTANCE hInst; // Instance
|
||||
CHAR szTitle[MAX_LOADSTRING]; // Window's title
|
||||
CHAR szClass[MAX_LOADSTRING]; // Window's class
|
||||
CHAR szAbout[MAX_LOADSTRING * 14]; // Description text
|
||||
HHOOK KeyboardHook;
|
||||
HICON hIcon;
|
||||
HMENU hMenu, hPopup;
|
||||
HWND hWnd;
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
KBDLLHOOKSTRUCT *pkhs;
|
||||
BOOL pressed = FALSE, showIcon = TRUE;
|
||||
HWND hWnd, hTaskBar, hDesktop, hProgman;
|
||||
BOOL bPressed = FALSE, bShowIcon = TRUE, bWorkArea = TRUE;
|
||||
BOOL bLCTRL = FALSE, bLWIN = FALSE, bKEYI = FALSE, bKEYC = FALSE;
|
||||
int dtCenterX, dtCenterY;
|
||||
|
||||
// Прототипы функций
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
LPKBDLLHOOKSTRUCT pkhs;
|
||||
MENUITEMINFO mii;
|
||||
POINT ptMousePos;
|
||||
|
||||
// Function's prototypes
|
||||
ATOM MyRegisterClass(HINSTANCE);
|
||||
VOID ShowError(HINSTANCE, UINT);
|
||||
VOID HandlingTrayIcon();
|
||||
VOID ShowError(UINT);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK KeyboardHookProc(int, WPARAM, LPARAM);
|
||||
BOOL CreateTrayIcon();
|
||||
|
||||
// Точка входа
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadStringW(hInstance, IDS_CLASSNAME, szClass, MAX_LOADSTRING);
|
||||
hInst = hInstance;
|
||||
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, _countof(szTitle));
|
||||
LoadString(hInstance, IDS_CLASSNAME, szClass, _countof(szClass));
|
||||
|
||||
if (FindWindow(szClass, NULL))
|
||||
{
|
||||
ShowError(hInstance, IDS_RUNNING);
|
||||
ShowError(IDS_RUNNING);
|
||||
return FALSE;
|
||||
}
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
|
||||
MyRegisterClass(hInstance);
|
||||
hWnd = CreateWindowEx(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
|
||||
if (!hWnd)
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_WND);
|
||||
ShowError(IDS_ERR_WND);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (showIcon)
|
||||
{
|
||||
if (!CreateTrayIcon())
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_ICON);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
}
|
||||
int nArgs = 0;
|
||||
LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
||||
(nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], L"/hide")) ? bShowIcon = FALSE : bShowIcon = TRUE;
|
||||
LocalFree(szArglist);
|
||||
HandlingTrayIcon();
|
||||
|
||||
hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU));
|
||||
if (!hMenu)
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_MENU);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
hPopup = GetSubMenu(hMenu, 0);
|
||||
if (!hPopup)
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_POPUP);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, hInstance, NULL);
|
||||
if (!KeyboardHook)
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_HOOK);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
LoadStringW(hInstance, IDS_HELPTEXT, szHelp, MAX_LOADSTRING);
|
||||
RECT dtrc = { 0 };
|
||||
SystemParametersInfo(SPI_GETWORKAREA, NULL, &dtrc, FALSE);
|
||||
dtCenterX = dtrc.right / 2, dtCenterY = dtrc.bottom / 2;
|
||||
hTaskBar = FindWindow("Shell_TrayWnd", NULL);
|
||||
hProgman = FindWindow("Progman", NULL);
|
||||
hDesktop = GetDesktopWindow();
|
||||
|
||||
MSG msg;
|
||||
BOOL bRet;
|
||||
@@ -95,7 +73,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
{
|
||||
if (bRet == -1)
|
||||
{
|
||||
ShowError(hInstance, IDS_ERR_MAIN);
|
||||
ShowError(IDS_ERR_MAIN);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@@ -125,27 +103,84 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU));
|
||||
if (!hMenu)
|
||||
{
|
||||
ShowError(IDS_ERR_MENU);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
hPopup = GetSubMenu(hMenu, 0);
|
||||
if (!hPopup)
|
||||
{
|
||||
ShowError(IDS_ERR_POPUP);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
mii.cbSize = sizeof(MENUITEMINFO);
|
||||
mii.fMask = MIIM_STATE;
|
||||
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
||||
SetMenuItemInfo(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
||||
|
||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
nid.hWnd = hWnd;
|
||||
nid.uVersion = NOTIFYICON_VERSION;
|
||||
nid.uCallbackMessage = WM_WCW;
|
||||
nid.hIcon = hIcon;
|
||||
nid.uID = IDI_TRAYICON;
|
||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
nid.dwInfoFlags = NIIF_INFO;
|
||||
StringCchCopy(nid.szTip, _countof(nid.szTip), szTitle);
|
||||
|
||||
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
||||
if (!KeyboardHook)
|
||||
{
|
||||
ShowError(IDS_ERR_HOOK);
|
||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
LoadString(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_WCW:
|
||||
{
|
||||
if (lParam == WM_RBUTTONDOWN && wParam == IDI_TRAYICON)
|
||||
{
|
||||
SetForegroundWindow(hWnd);
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
int idMenu = TrackPopupMenu(hPopup, TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL);
|
||||
if (idMenu == ID_POPUPMENU_HELP && !pressed)
|
||||
if (idMenu == ID_POPUPMENU_ICON)
|
||||
{
|
||||
pressed = TRUE;
|
||||
if (MessageBox(hWnd, szHelp, szTitle, MB_OK | MB_TOPMOST) == IDOK) pressed = FALSE;
|
||||
bShowIcon = FALSE;
|
||||
HandlingTrayIcon();
|
||||
}
|
||||
if (idMenu == ID_POPUPMENU_AREA)
|
||||
{
|
||||
bWorkArea = !bWorkArea;
|
||||
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
||||
SetMenuItemInfo(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
||||
}
|
||||
if (idMenu == ID_POPUPMENU_ABOUT && !bPressed)
|
||||
{
|
||||
bPressed = TRUE;
|
||||
if (MessageBox(hWnd, szAbout, szTitle, MB_OK | MB_TOPMOST | MB_ICONINFORMATION) == IDOK) bPressed = FALSE;
|
||||
}
|
||||
if (idMenu == ID_POPUPMENU_EXIT) SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (KeyboardHook) UnhookWindowsHookEx(KeyboardHook);
|
||||
if (hMenu) DestroyMenu(hMenu);
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -154,6 +189,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
||||
@@ -162,7 +198,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = FALSE;
|
||||
if (pkhs->vkCode == VK_LWIN) bLWIN = FALSE;
|
||||
pressed = FALSE;
|
||||
bPressed = FALSE;
|
||||
}
|
||||
|
||||
if (wParam == WM_KEYDOWN)
|
||||
@@ -170,16 +206,47 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = TRUE;
|
||||
if (pkhs->vkCode == VK_LWIN) bLWIN = TRUE;
|
||||
|
||||
if (bLCTRL && bLWIN && pkhs->vkCode == 0x49 && !pressed) // 'I' key
|
||||
if (bLCTRL && bLWIN && pkhs->vkCode == 0x49 && !bPressed) // 'I' key
|
||||
{
|
||||
pressed = TRUE;
|
||||
showIcon = !showIcon;
|
||||
if (showIcon)
|
||||
bPressed = TRUE;
|
||||
bShowIcon = !bShowIcon;
|
||||
HandlingTrayIcon();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (bLCTRL && bLWIN && pkhs->vkCode == 0x43 && !bPressed) // 'C' key
|
||||
{
|
||||
if (!CreateTrayIcon())
|
||||
bPressed = TRUE;
|
||||
HWND hFgWnd = GetForegroundWindow();
|
||||
|
||||
if (hFgWnd)
|
||||
{
|
||||
ShowError(GetModuleHandle(NULL), IDS_ERR_ICON);
|
||||
showIcon = FALSE;
|
||||
if (hFgWnd != hDesktop && hFgWnd != hTaskBar && hFgWnd != hProgman)
|
||||
{
|
||||
if (!IsIconic(hFgWnd) && !IsZoomed(hFgWnd))
|
||||
{
|
||||
RECT fgwrc;
|
||||
GetWindowRect(hFgWnd, &fgwrc);
|
||||
LONG fgWidth = fgwrc.right - fgwrc.left;
|
||||
LONG fgHeight = fgwrc.bottom - fgwrc.top;
|
||||
MoveWindowToMonitorCenter(hFgWnd, fgWidth, fgHeight, bWorkArea, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
VOID HandlingTrayIcon()
|
||||
{
|
||||
if (bShowIcon)
|
||||
{
|
||||
if (!Shell_NotifyIcon(NIM_ADD, &nid))
|
||||
{
|
||||
ShowError(IDS_ERR_ICON);
|
||||
bShowIcon = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -188,60 +255,9 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
|
||||
if (bLCTRL && bLWIN && pkhs->vkCode == 0x43 && !pressed) // 'C' key
|
||||
VOID ShowError(UINT uID)
|
||||
{
|
||||
pressed = TRUE;
|
||||
HWND fgWindow = GetForegroundWindow();
|
||||
if (fgWindow)
|
||||
{
|
||||
HWND parentWindow = fgWindow;
|
||||
while (TRUE)
|
||||
{
|
||||
parentWindow = GetParent(fgWindow);
|
||||
if (parentWindow) fgWindow = parentWindow;
|
||||
else break;
|
||||
}
|
||||
WINDOWPLACEMENT wp = { 0 };
|
||||
wp.length = sizeof(WINDOWPLACEMENT);
|
||||
GetWindowPlacement(fgWindow, &wp);
|
||||
if (wp.showCmd == SW_SHOWNORMAL)
|
||||
{
|
||||
int fgW = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
|
||||
int fgH = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
|
||||
int fgX = dtCenterX - (fgW / 2);
|
||||
int fgY = dtCenterY - (fgH / 2);
|
||||
wp.rcNormalPosition.left = fgX;
|
||||
wp.rcNormalPosition.top = fgY;
|
||||
wp.rcNormalPosition.right = fgX + fgW;
|
||||
wp.rcNormalPosition.bottom = fgY + fgH;
|
||||
SendMessage(fgWindow, WM_ENTERSIZEMOVE, NULL, NULL);
|
||||
SetWindowPlacement(fgWindow, &wp);
|
||||
SendMessage(fgWindow, WM_EXITSIZEMOVE, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
BOOL CreateTrayIcon()
|
||||
{
|
||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
nid.hWnd = hWnd;
|
||||
nid.uVersion = NOTIFYICON_VERSION;
|
||||
nid.uCallbackMessage = WM_WCW;
|
||||
nid.hIcon = hIcon;
|
||||
nid.uID = IDI_TRAYICON;
|
||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
nid.dwInfoFlags = NIIF_INFO;
|
||||
StringCchCopy(nid.szTip, sizeof(nid.szTip), szTitle);
|
||||
return Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
}
|
||||
|
||||
VOID ShowError(HINSTANCE hInstance, UINT uID)
|
||||
{
|
||||
WCHAR szErrorText[MAX_LOADSTRING]; // Текст ошибки
|
||||
LoadStringW(hInstance, uID, szErrorText, MAX_LOADSTRING);
|
||||
CHAR szErrorText[MAX_LOADSTRING]; // Error's text
|
||||
LoadString(hInst, uID, szErrorText, _countof(szErrorText));
|
||||
MessageBox(hWnd, szErrorText, szTitle, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#pragma once
|
||||
#include "resource.h"
|
||||
Binary file not shown.
@@ -20,8 +20,7 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{6A775901-6C34-4E96-B359-C11C76A520BB}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{2494B3F2-585E-4A2E-A013-20A15AE25B9E}</ProjectGuid>
|
||||
<RootNamespace>wCenterWindow</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
@@ -30,27 +29,27 @@
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -70,102 +69,73 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<UACExecutionLevel>HighestAvailable</UACExecutionLevel>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="wCenterWindow.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\MyFunctions\MoveWindowToMonitorCenter.cpp" />
|
||||
<ClCompile Include="wCenterWindow.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="wCenterWindow.rc" />
|
||||
<ClInclude Include="..\..\..\MyFunctions\MoveWindowToMonitorCenter.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="wCenterWindow.ico" />
|
||||
<ResourceCompile Include="wCenterWindow.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -1,46 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="wCenterWindow.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="wCenterWindow.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\MyFunctions\MoveWindowToMonitorCenter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="wCenterWindow.rc">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</ResourceCompile>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\MyFunctions\MoveWindowToMonitorCenter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="wCenterWindow.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
<ResourceCompile Include="wCenterWindow.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
wCenterWindow/wCenterWindow.vcxproj.user
Normal file
4
wCenterWindow/wCenterWindow.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user