Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
add Splash
Browse files Browse the repository at this point in the history
  • Loading branch information
LengSC committed Jan 21, 2023
1 parent eef9a0f commit d4141db
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 10 deletions.
Binary file modified BossKey/BossKey.aps
Binary file not shown.
23 changes: 20 additions & 3 deletions BossKey/BossKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ HWND BossKey::Window() const {

INT BossKey::Create() {
/* 防止进程多开 */
m_hMutexExecuting = CreateMutex(NULL, FALSE, L"EXECUTING");
m_hMutexExecuting = CreateMutex(NULL, FALSE, L"BossKeyExecuting");

if (m_hMutexExecuting == NULL) {
return CS_FAILED;
Expand Down Expand Up @@ -133,6 +133,11 @@ LRESULT BossKey::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {


LRESULT BossKey::OnCreate() {
clock_t start = clock();

/* 显示开始画面 */
HWND hSplash = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_SPLASH), m_hWnd, SplashWindow::SplashProc);

/* 注册全局热键 */
m_idHotKeySwitch = GlobalAddAtom(L"BossKeyHotKeySwitchWindow");
m_idHotKeyDestroy = GlobalAddAtom(L"BossKeyHotKeyDestroyWindow");
Expand All @@ -146,7 +151,7 @@ LRESULT BossKey::OnCreate() {
&& RegisterHotKey(m_hWnd, m_idHotKeySelect, MOD_CONTROL | MOD_NOREPEAT, 'S')
&& RegisterHotKey(m_hWnd, m_idHotKeyCancel, MOD_NOREPEAT, VK_ESCAPE))
) {
MessageBox(m_hWnd, L"系统热键注册失败,可能发生冲突", L"错误", MB_OK | MB_ICONERROR);
MessageBox(m_hWnd, L"系统热键注册失败,可能发生冲突", L"错误", MB_OK | MB_ICONERROR);
DestroyWindow(m_hWnd);
}

Expand Down Expand Up @@ -179,6 +184,14 @@ LRESULT BossKey::OnCreate() {
NULL
);

clock_t td = clock() - start;

if (td < 2000) {
Sleep((DWORD)(2000 - td));
}

SendMessage(hSplash, WM_CLOSE, NULL, NULL);

return (LRESULT)FALSE;
}

Expand Down Expand Up @@ -260,7 +273,6 @@ LRESULT BossKey::OnHotkey(WPARAM wParam, LPARAM lParam) {

if (dwFocusThreadId != dwCurrentThreadId) {
PostMessage(hFocusWnd, WM_KEYDOWN, HIWORD(lParam), 0);
PostMessage(hFocusWnd, WM_CHAR, HIWORD(lParam), 0);
}

/* 处理热键 */
Expand Down Expand Up @@ -293,6 +305,11 @@ LRESULT BossKey::OnHotkey(WPARAM wParam, LPARAM lParam) {

}
m_bSelecting = FALSE;

if (m_wndSwt.Controlled() == m_hWnd) {
MessageBox(m_hWnd, L"不能绑定软件窗口本身!", L"错误", MB_OK | MB_ICONERROR);
m_wndSwt.Release();
}
}
break;

Expand Down
2 changes: 2 additions & 0 deletions BossKey/BossKey.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include <Windows.h>
#include <ctime>

#include "SplashWindow.h"
#include "SettingsWindow.h"
#include "AboutWindow.h"
#include "UsageWindow.h"
Expand Down
Binary file modified BossKey/BossKey.rc
Binary file not shown.
4 changes: 3 additions & 1 deletion BossKey/BossKey.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@
<ItemGroup>
<Image Include="Res\Images\16x16.bmp" />
<Image Include="Res\Images\App.ico" />
<Image Include="Res\Images\bitmap1.bmp" />
<Image Include="Res\Images\Splash.bmp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="App.cpp" />
<ClCompile Include="AboutWindow.cpp" />
<ClCompile Include="BossKey.cpp" />
<ClCompile Include="SettingsWindow.cpp" />
<ClCompile Include="SplashWindow.cpp" />
<ClCompile Include="UsageWindow.cpp" />
<ClCompile Include="WindowSwitching.cpp" />
</ItemGroup>
Expand All @@ -153,6 +154,7 @@
<ClInclude Include="BossKey.h" />
<ClInclude Include="SettingsWindow.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SplashWindow.h" />
<ClInclude Include="UsageWindow.h" />
<ClInclude Include="WindowSwitching.h" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion BossKey/BossKey.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Image Include="Res\Images\App.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="Res\Images\bitmap1.bmp">
<Image Include="Res\Images\Splash.bmp">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
Expand All @@ -44,6 +44,9 @@
<ClCompile Include="UsageWindow.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SplashWindow.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AboutWindow.h">
Expand All @@ -67,6 +70,9 @@
<ClInclude Include="UsageWindow.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SplashWindow.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="BossKey.rc">
Expand Down
Binary file added BossKey/Res/Images/Splash.bmp
Binary file not shown.
Binary file removed BossKey/Res/Images/bitmap1.bmp
Binary file not shown.
12 changes: 7 additions & 5 deletions BossKey/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// 供 BossKey.rc 使用
//
#define IDI_ICON_APP 101
#define IDR_MENU_MAIN 102
#define IDD_DIALOG_SETTINGS 103
#define IDD_DIALOG_ABOUT 104
#define IDD_DIALOG_USAGE 105
#define IDB_SPLASH 102
#define IDR_MENU_MAIN 103
#define IDD_DIALOG_SPLASH 104
#define IDD_DIALOG_SETTINGS 105
#define IDD_DIALOG_ABOUT 106
#define IDD_DIALOG_USAGE 107
#define IDC_MAIN_SELECT 1001
#define IDC_MAIN_LOGGING 1002
#define IDC_SETTINGS_OK 1003
Expand All @@ -27,7 +29,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_RESOURCE_VALUE 109
#define _APS_NEXT_COMMAND_VALUE 40007
#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 101
Expand Down
18 changes: 18 additions & 0 deletions BossKey/SplashWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "SplashWindow.h"


INT_PTR CALLBACK SplashWindow::SplashProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_CLOSE:
EndDialog(hDlg, NULL);
return (INT_PTR)TRUE;
break;

default:
return (INT_PTR)FALSE;
break;

}

return (INT_PTR)FALSE;
}
12 changes: 12 additions & 0 deletions BossKey/SplashWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <Windows.h>

#include "Resource.h"


class SplashWindow {
public:
static INT_PTR CALLBACK SplashProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

};
5 changes: 5 additions & 0 deletions BossKey/WindowSwitching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ WindowSwitching::WindowSwitching() {
}


HWND WindowSwitching::Controlled() const {
return m_hControlled;
}


INT WindowSwitching::Select() {
POINT pt = { 0 };
HWND hTmp = NULL;
Expand Down
2 changes: 2 additions & 0 deletions BossKey/WindowSwitching.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class WindowSwitching {
public:
WindowSwitching();

HWND Controlled() const;

INT Select();

BOOL Switch();
Expand Down
Binary file modified BossKey/x64/Release/BossKey.res
Binary file not shown.
Binary file modified x64/Release/BossKey.exe
Binary file not shown.

0 comments on commit d4141db

Please sign in to comment.