Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f8b925d0f8 | |||
| 35f791d7a0 | |||
|
|
4586599d2c | ||
| dfdbd6a94b | |||
| 5ef184bee3 | |||
| ce31a7d6e0 | |||
|
|
00a949f502 | ||
|
|
703fccaa15 | ||
| 3f8b848b1e | |||
| 73a7b40f9b | |||
| 81510d5105 |
52
.gitattributes
vendored
52
.gitattributes
vendored
@@ -10,7 +10,7 @@
|
|||||||
# default for csharp files.
|
# default for csharp files.
|
||||||
# Note: This is only used by command line
|
# Note: This is only used by command line
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#*.cs diff=csharp
|
*.cs diff=csharp
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Set the merge driver for project and solution files
|
# Set the merge driver for project and solution files
|
||||||
@@ -22,27 +22,27 @@
|
|||||||
# these files as binary and thus will always conflict and require user
|
# these files as binary and thus will always conflict and require user
|
||||||
# intervention with every merge. To do so, just uncomment the entries below
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#*.sln merge=binary
|
*.sln merge=binary
|
||||||
#*.csproj merge=binary
|
*.csproj merge=binary
|
||||||
#*.vbproj merge=binary
|
*.vbproj merge=binary
|
||||||
#*.vcxproj merge=binary
|
*.vcxproj merge=binary
|
||||||
#*.vcproj merge=binary
|
*.vcproj merge=binary
|
||||||
#*.dbproj merge=binary
|
*.dbproj merge=binary
|
||||||
#*.fsproj merge=binary
|
*.fsproj merge=binary
|
||||||
#*.lsproj merge=binary
|
*.lsproj merge=binary
|
||||||
#*.wixproj merge=binary
|
*.wixproj merge=binary
|
||||||
#*.modelproj merge=binary
|
*.modelproj merge=binary
|
||||||
#*.sqlproj merge=binary
|
*.sqlproj merge=binary
|
||||||
#*.wwaproj merge=binary
|
*.wwaproj merge=binary
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# behavior for image files
|
# behavior for image files
|
||||||
#
|
#
|
||||||
# image files are treated as binary by default.
|
# image files are treated as binary by default.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#*.jpg binary
|
*.jpg binary
|
||||||
#*.png binary
|
*.png binary
|
||||||
#*.gif binary
|
*.gif binary
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# diff behavior for common document formats
|
# diff behavior for common document formats
|
||||||
@@ -51,13 +51,13 @@
|
|||||||
# is only available from the command line. Turn it on by uncommenting the
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
# entries below.
|
# entries below.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#*.doc diff=astextplain
|
*.doc diff=astextplain
|
||||||
#*.DOC diff=astextplain
|
*.DOC diff=astextplain
|
||||||
#*.docx diff=astextplain
|
*.docx diff=astextplain
|
||||||
#*.DOCX diff=astextplain
|
*.DOCX diff=astextplain
|
||||||
#*.dot diff=astextplain
|
*.dot diff=astextplain
|
||||||
#*.DOT diff=astextplain
|
*.DOT diff=astextplain
|
||||||
#*.pdf diff=astextplain
|
*.pdf diff=astextplain
|
||||||
#*.PDF diff=astextplain
|
*.PDF diff=astextplain
|
||||||
#*.rtf diff=astextplain
|
*.rtf diff=astextplain
|
||||||
#*.RTF diff=astextplain
|
*.RTF diff=astextplain
|
||||||
|
|||||||
181
.gitignore
vendored
181
.gitignore
vendored
@@ -21,6 +21,7 @@ bld/
|
|||||||
[Bb]in/
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
[Ll]og/
|
[Ll]og/
|
||||||
|
[Bb]uild/
|
||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
# Visual Studio 2015 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
@@ -171,6 +172,9 @@ csx/
|
|||||||
ecf/
|
ecf/
|
||||||
rcf/
|
rcf/
|
||||||
|
|
||||||
|
# Microsoft Azure ApplicationInsights config file
|
||||||
|
ApplicationInsights.config
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
# Windows Store app package directories and files
|
||||||
AppPackages/
|
AppPackages/
|
||||||
BundleArtifacts/
|
BundleArtifacts/
|
||||||
@@ -187,6 +191,7 @@ _pkginfo.txt
|
|||||||
ClientBin/
|
ClientBin/
|
||||||
~$*
|
~$*
|
||||||
*~
|
*~
|
||||||
|
.*.swp
|
||||||
*.dbmdl
|
*.dbmdl
|
||||||
*.dbproj.schemaview
|
*.dbproj.schemaview
|
||||||
*.jfm
|
*.jfm
|
||||||
@@ -256,6 +261,178 @@ paket-files/
|
|||||||
# CodeRush
|
# CodeRush
|
||||||
.cr/
|
.cr/
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
/windows/LightGBM.VC.db
|
||||||
|
lightgbm
|
||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/python
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
!/python-package/lightgbm/
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*,cover
|
||||||
|
.hypothesis/
|
||||||
|
**/coverage.html
|
||||||
|
**/coverage.html.zip
|
||||||
|
R-package/tests/testthat/Rplots.pdf
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
docs/pythonapi/
|
||||||
|
|
||||||
|
# Doxygen documentation
|
||||||
|
docs/doxyoutput/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# dotenv
|
||||||
|
.env
|
||||||
|
|
||||||
|
# virtualenv
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# R testing artefact
|
||||||
|
lightgbm.model
|
||||||
|
|
||||||
|
# saved or dumped model/data
|
||||||
|
*.model
|
||||||
|
*.pkl
|
||||||
|
*.bin
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
|
# VSCode
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# IntelliJ IDEA
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Files from local Python install
|
||||||
|
python-package/LICENSE
|
||||||
|
python-package/build_cpp/
|
||||||
|
python-package/compile/
|
||||||
|
python-package/lightgbm/VERSION.txt
|
||||||
|
|
||||||
|
# R build artefacts
|
||||||
|
R-package/src/CMakeLists.txt
|
||||||
|
R-package/src/lib_lightgbm.so.dSYM/
|
||||||
|
R-package/src/src/
|
||||||
|
lightgbm_r/*
|
||||||
|
lightgbm*.tar.gz
|
||||||
|
lightgbm.Rcheck/
|
||||||
|
|
||||||
|
# Files from interactive R sessions
|
||||||
|
.Rproj.user
|
||||||
|
**/.Rhistory
|
||||||
|
|
||||||
|
# Files generated by aspell
|
||||||
|
**/*.bak
|
||||||
|
|
||||||
|
# GraphViz artifacts
|
||||||
|
*.gv
|
||||||
|
*.gv.*
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
# wCenterWindow
|
# wCenterWindow
|
||||||
This program centers the current active window by a 'LCTRL + LWIN + C' hotkey.
|
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,27 +1,25 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
// resource.h
|
||||||
// Включаемый файл, созданный в Microsoft Visual C++.
|
#define IDS_APP_TITLE 100
|
||||||
// Используется wCenterWindow.rc
|
#define IDS_CLASSNAME 101
|
||||||
|
#define IDS_ABOUT 102
|
||||||
|
#define IDI_TRAYICON 103
|
||||||
|
#define IDR_MENU 104
|
||||||
|
#define ID_POPUPMENU_ICON 105
|
||||||
|
#define ID_POPUPMENU_ABOUT 106
|
||||||
|
#define ID_POPUPMENU_EXIT 107
|
||||||
|
#define IDS_ERR_MAIN 108
|
||||||
|
#define IDS_ERR_WND 109
|
||||||
|
#define IDS_ERR_ICON 110
|
||||||
|
#define IDS_ERR_MENU 111
|
||||||
|
#define IDS_ERR_POPUP 112
|
||||||
|
#define IDS_ERR_HOOK 113
|
||||||
|
#define IDS_RUNNING 114
|
||||||
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
#define IDS_APP_TITLE 103
|
// Next default values for new objects
|
||||||
|
|
||||||
#define IDR_MAINFRAME 128
|
|
||||||
#define IDD_WCENTERWINDOW_DIALOG 102
|
|
||||||
#define IDD_ABOUTBOX 103
|
|
||||||
#define IDM_ABOUT 104
|
|
||||||
#define IDM_EXIT 105
|
|
||||||
#define IDI_WCENTERWINDOW 107
|
|
||||||
#define IDI_SMALL 108
|
|
||||||
#define IDC_WCENTERWINDOW 109
|
|
||||||
#define IDC_MYICON 2
|
|
||||||
#ifndef IDC_STATIC
|
|
||||||
#define IDC_STATIC -1
|
|
||||||
#endif
|
|
||||||
// Следующие стандартные значения для новых объектов
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NO_MFC 130
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
// header.h: включаемый файл для стандартных системных включаемых файлов
|
// header.h: включаемый файл для стандартных системных включаемых файлов
|
||||||
// или включаемые файлы для конкретного проекта
|
// или включаемые файлы для конкретного проекта
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "targetver.h"
|
#include "targetver.h"
|
||||||
#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows
|
#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows
|
||||||
// Файлы заголовков Windows
|
// Файлы заголовков Windows
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include <shellapi.h>
|
||||||
// Файлы заголовков среды выполнения C
|
// Файлы заголовков среды выполнения C
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
@@ -1,6 +1,2 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows.
|
|
||||||
// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и
|
|
||||||
// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h.
|
|
||||||
#include <SDKDDKVer.h>
|
#include <SDKDDKVer.h>
|
||||||
|
|||||||
@@ -1,180 +1,256 @@
|
|||||||
// wCenterWindow.cpp : Определяет точку входа для приложения.
|
// wCenterWindow.cpp : Определяет точку входа для приложения.
|
||||||
//
|
|
||||||
|
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
#include "wCenterWindow.h"
|
#include "wCenterWindow.h"
|
||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
#define MAX_LOADSTRING 32
|
||||||
|
#define WM_WCW WM_USER + 0x7F00
|
||||||
|
|
||||||
// Глобальные переменные:
|
// Глобальные переменные:
|
||||||
HINSTANCE hInst; // текущий экземпляр
|
HINSTANCE hInst; // Текущий экземпляр
|
||||||
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
||||||
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
WCHAR szClass[MAX_LOADSTRING]; // Имя класса главного окна
|
||||||
|
WCHAR szAbout[MAX_LOADSTRING * 9]; // Текст описания
|
||||||
|
HHOOK KeyboardHook;
|
||||||
|
HICON hIcon;
|
||||||
|
HMENU hMenu, hPopup;
|
||||||
|
HWND hWnd;
|
||||||
|
NOTIFYICONDATA nid = { 0 };
|
||||||
|
KBDLLHOOKSTRUCT *pkhs;
|
||||||
|
BOOL pressed = FALSE, showIcon = TRUE;
|
||||||
|
BOOL bLCTRL = FALSE, bLWIN = FALSE, bKEYI = FALSE, bKEYC = FALSE;
|
||||||
|
int dtCenterX, dtCenterY;
|
||||||
|
|
||||||
// Отправить объявления функций, включенных в этот модуль кода:
|
// Прототипы функций
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
ATOM MyRegisterClass(HINSTANCE);
|
||||||
BOOL InitInstance(HINSTANCE, int);
|
VOID HandlingTrayIcon();
|
||||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
VOID ShowError(UINT);
|
||||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
LRESULT CALLBACK KeyboardHookProc(int, WPARAM, LPARAM);
|
||||||
|
|
||||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
// Точка входа
|
||||||
_In_opt_ HINSTANCE hPrevInstance,
|
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||||
_In_ LPWSTR lpCmdLine,
|
_In_opt_ HINSTANCE hPrevInstance,
|
||||||
_In_ int nCmdShow)
|
_In_ LPWSTR lpCmdLine,
|
||||||
|
_In_ int nCmdShow)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
// TODO: Разместите код здесь.
|
hInst = hInstance;
|
||||||
|
|
||||||
// Инициализация глобальных строк
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, _countof(szTitle));
|
||||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
LoadStringW(hInstance, IDS_CLASSNAME, szClass, _countof(szClass));
|
||||||
LoadStringW(hInstance, IDC_WCENTERWINDOW, szWindowClass, MAX_LOADSTRING);
|
|
||||||
MyRegisterClass(hInstance);
|
|
||||||
|
|
||||||
// Выполнить инициализацию приложения:
|
if (FindWindow(szClass, NULL))
|
||||||
if (!InitInstance (hInstance, nCmdShow))
|
{
|
||||||
{
|
ShowError(IDS_RUNNING);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WCENTERWINDOW));
|
MyRegisterClass(hInstance);
|
||||||
|
hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
|
||||||
|
if (!hWnd)
|
||||||
|
{
|
||||||
|
ShowError(IDS_ERR_WND);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
MSG msg;
|
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);
|
||||||
|
|
||||||
// Цикл основного сообщения:
|
int nArgs = 0;
|
||||||
while (GetMessage(&msg, nullptr, 0, 0))
|
LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
||||||
{
|
(nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], L"/hide")) ? showIcon = FALSE : showIcon = TRUE;
|
||||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
LocalFree(szArglist);
|
||||||
{
|
HandlingTrayIcon();
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) msg.wParam;
|
MSG msg;
|
||||||
|
BOOL bRet;
|
||||||
|
|
||||||
|
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
|
||||||
|
{
|
||||||
|
if (bRet == -1)
|
||||||
|
{
|
||||||
|
ShowError(IDS_ERR_MAIN);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (int)msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// ФУНКЦИЯ: MyRegisterClass()
|
|
||||||
//
|
|
||||||
// ЦЕЛЬ: Регистрирует класс окна.
|
|
||||||
//
|
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
WNDCLASSEXW wcex;
|
WNDCLASSEX wcex = { 0 };
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
||||||
wcex.lpfnWndProc = WndProc;
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wcex.cbClsExtra = 0;
|
wcex.lpszClassName = szClass;
|
||||||
wcex.cbWndExtra = 0;
|
wcex.hIconSm = wcex.hIcon;
|
||||||
wcex.hInstance = hInstance;
|
hIcon = wcex.hIcon;
|
||||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WCENTERWINDOW));
|
return RegisterClassEx(&wcex);
|
||||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
|
||||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
||||||
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WCENTERWINDOW);
|
|
||||||
wcex.lpszClassName = szWindowClass;
|
|
||||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
|
||||||
|
|
||||||
return RegisterClassExW(&wcex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
|
||||||
//
|
|
||||||
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
|
||||||
//
|
|
||||||
// КОММЕНТАРИИ:
|
|
||||||
//
|
|
||||||
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
|
||||||
// создается и выводится главное окно программы.
|
|
||||||
//
|
|
||||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
||||||
{
|
|
||||||
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
|
||||||
|
|
||||||
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
|
||||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
|
||||||
|
|
||||||
if (!hWnd)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowWindow(hWnd, nCmdShow);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
|
||||||
//
|
|
||||||
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
|
||||||
//
|
|
||||||
// WM_COMMAND - обработать меню приложения
|
|
||||||
// WM_PAINT - Отрисовка главного окна
|
|
||||||
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
|
||||||
//
|
|
||||||
//
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_COMMAND:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
int wmId = LOWORD(wParam);
|
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU));
|
||||||
// Разобрать выбор в меню:
|
if (!hMenu)
|
||||||
switch (wmId)
|
{
|
||||||
{
|
ShowError(IDS_ERR_MENU);
|
||||||
case IDM_ABOUT:
|
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
}
|
||||||
break;
|
|
||||||
case IDM_EXIT:
|
hPopup = GetSubMenu(hMenu, 0);
|
||||||
DestroyWindow(hWnd);
|
if (!hPopup)
|
||||||
break;
|
{
|
||||||
default:
|
ShowError(IDS_ERR_POPUP);
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
||||||
case WM_PAINT:
|
if (!KeyboardHook)
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
ShowError(IDS_ERR_HOOK);
|
||||||
HDC hdc = BeginPaint(hWnd, &ps);
|
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
}
|
||||||
EndPaint(hWnd, &ps);
|
|
||||||
}
|
LoadStringW(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
|
||||||
break;
|
RECT dtrc = { 0 };
|
||||||
case WM_DESTROY:
|
SystemParametersInfo(SPI_GETWORKAREA, NULL, &dtrc, FALSE);
|
||||||
PostQuitMessage(0);
|
dtCenterX = dtrc.right / 2, dtCenterY = dtrc.bottom / 2;
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
case WM_WCW:
|
||||||
}
|
if (lParam == WM_RBUTTONDOWN && wParam == IDI_TRAYICON)
|
||||||
return 0;
|
{
|
||||||
|
SetForegroundWindow(hWnd);
|
||||||
|
POINT pt;
|
||||||
|
GetCursorPos(&pt);
|
||||||
|
int idMenu = TrackPopupMenu(hPopup, TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL);
|
||||||
|
if (idMenu == ID_POPUPMENU_ICON)
|
||||||
|
{
|
||||||
|
showIcon = FALSE;
|
||||||
|
HandlingTrayIcon();
|
||||||
|
}
|
||||||
|
if (idMenu == ID_POPUPMENU_ABOUT && !pressed)
|
||||||
|
{
|
||||||
|
pressed = TRUE;
|
||||||
|
if (MessageBox(hWnd, szAbout, szTitle, MB_OK | MB_TOPMOST) == IDOK) pressed = 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:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обработчик сообщений для окна "О программе".
|
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
if (wParam == WM_KEYUP)
|
||||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
{
|
||||||
{
|
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = FALSE;
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
if (pkhs->vkCode == VK_LWIN) bLWIN = FALSE;
|
||||||
return (INT_PTR)TRUE;
|
pressed = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
if (wParam == WM_KEYDOWN)
|
||||||
return (INT_PTR)FALSE;
|
{
|
||||||
|
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = TRUE;
|
||||||
|
if (pkhs->vkCode == VK_LWIN) bLWIN = TRUE;
|
||||||
|
|
||||||
|
if (bLCTRL && bLWIN && pkhs->vkCode == 0x49 && !pressed) // 'I' key
|
||||||
|
{
|
||||||
|
pressed = TRUE;
|
||||||
|
showIcon = !showIcon;
|
||||||
|
HandlingTrayIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bLCTRL && bLWIN && pkhs->vkCode == 0x43 && !pressed) // 'C' key
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID HandlingTrayIcon()
|
||||||
|
{
|
||||||
|
if (showIcon)
|
||||||
|
{
|
||||||
|
if (!Shell_NotifyIcon(NIM_ADD, &nid))
|
||||||
|
{
|
||||||
|
ShowError(IDS_ERR_ICON);
|
||||||
|
showIcon = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ShowError(UINT uID)
|
||||||
|
{
|
||||||
|
WCHAR szErrorText[MAX_LOADSTRING]; // Текст ошибки
|
||||||
|
LoadStringW(hInst, uID, szErrorText, _countof(szErrorText));
|
||||||
|
MessageBox(hWnd, szErrorText, szTitle, MB_OK | MB_ICONERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 36 KiB |
Binary file not shown.
@@ -123,12 +123,14 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<AssemblyDebug>false</AssemblyDebug>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@@ -152,7 +154,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="framework.h" />
|
<ClInclude Include="framework.h" />
|
||||||
<ClInclude Include="Resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
<ClInclude Include="wCenterWindow.h" />
|
<ClInclude Include="wCenterWindow.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -163,7 +165,6 @@
|
|||||||
<ResourceCompile Include="wCenterWindow.rc" />
|
<ResourceCompile Include="wCenterWindow.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="small.ico" />
|
|
||||||
<Image Include="wCenterWindow.ico" />
|
<Image Include="wCenterWindow.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
<ClInclude Include="targetver.h">
|
<ClInclude Include="targetver.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Resource.h">
|
<ClInclude Include="wCenterWindow.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="wCenterWindow.h">
|
<ClInclude Include="resource.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -39,9 +39,6 @@
|
|||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="small.ico">
|
|
||||||
<Filter>Файлы ресурсов</Filter>
|
|
||||||
</Image>
|
|
||||||
<Image Include="wCenterWindow.ico">
|
<Image Include="wCenterWindow.ico">
|
||||||
<Filter>Файлы ресурсов</Filter>
|
<Filter>Файлы ресурсов</Filter>
|
||||||
</Image>
|
</Image>
|
||||||
|
|||||||
Reference in New Issue
Block a user