-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a174c16
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CMakeLists.txt.user | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Testing | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
compile_commands.json | ||
CTestTestfile.cmake | ||
_deps | ||
|
||
/.idea/ | ||
/cmake-build-debug/ | ||
/cmake-build-release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.28) | ||
project(black_screen_app) | ||
|
||
set(CMAKE_CXX_STANDARD 23) | ||
set(CMAKE_GENERATOR_PLATFORM "Win32") | ||
|
||
if (MSVC) | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Ob2 /Oi /Ot /Oy /GL /GS-") | ||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") | ||
endif() | ||
|
||
add_executable(black_screen_app WIN32 | ||
src/app/main.cpp | ||
src/app/WindowInitiator.cpp | ||
src/app/WindowInitiator.hpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Black Screen Application | ||
[![C++](https://img.shields.io/badge/C%2B%2B-23-blue.svg "C++ Standard")](https://en.cppreference.com/w/cpp/23) | ||
[![CMake](https://img.shields.io/badge/CMake-3.28-important.svg "CMake Version")](https://cmake.org/) | ||
|
||
[![Windows x86](https://img.shields.io/badge/Windows-x86-lightgrey?logo=windows)](https://www.microsoft.com/) | ||
[![Windows x64](https://img.shields.io/badge/Windows-x64-551a8b?logo=windows)](https://www.microsoft.com/) | ||
|
||
The Black Screen App is a simple yet effective tool designed to display a fully black screen on your Windows computer. Whether you're looking to save energy, eliminate distractions, or simply need a black backdrop, this app has you covered. | ||
|
||
## Features | ||
|
||
- **Full-Screen Blackout**: Fills your entire screen with pure black color. | ||
- **Compatibility**: Supports both 32-bit (x32) and 64-bit (x64) Windows versions. | ||
|
||
## Quick Start | ||
|
||
1. **Launch**: Double-click the app icon to run. | ||
2. **Exit**: Simply press any key to close the app and return to your desktop. | ||
|
||
## Acknowledgments | ||
|
||
- Thanks to all the contributors who have helped make this app better. | ||
- Special thanks to the community for the valuable feedback and support. | ||
|
||
--- | ||
|
||
Enjoy the simplicity and utility of the Black Screen App! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// Created by spoil on 04/14/2024. | ||
// | ||
|
||
#include "WindowInitiator.hpp" | ||
#include <windows.h> | ||
|
||
LRESULT CALLBACK HandleWindowMessages(HWND windowHandle, UINT messageType, WPARAM windowParameterValue, LPARAM messageData); | ||
|
||
void WindowInitiator::createWindow() { | ||
const WNDCLASS windowClass = { | ||
.lpfnWndProc = HandleWindowMessages, | ||
.hInstance = GetModuleHandle(nullptr), | ||
.lpszClassName = "BlackWindowClass" | ||
}; | ||
RegisterClass(&windowClass); | ||
|
||
const auto windowHandle = CreateWindowEx( | ||
0, | ||
"BlackWindowClass", | ||
"Black Screen Application", | ||
WS_POPUP | WS_VISIBLE, | ||
CW_USEDEFAULT, | ||
CW_USEDEFAULT, | ||
GetSystemMetrics(SM_CXSCREEN), | ||
GetSystemMetrics(SM_CYSCREEN), | ||
nullptr, | ||
nullptr, | ||
GetModuleHandle(nullptr), | ||
nullptr | ||
); | ||
|
||
ShowCursor(false); | ||
|
||
ShowWindow(windowHandle, SW_SHOW); | ||
UpdateWindow(windowHandle); | ||
|
||
MSG message; | ||
while (GetMessage(&message, nullptr, 0, 0)) { | ||
TranslateMessage(&message); | ||
DispatchMessage(&message); | ||
} | ||
} | ||
|
||
LRESULT CALLBACK HandleWindowMessages(const HWND windowHandle, const UINT messageType, const WPARAM windowParameterValue, const LPARAM messageData) { // NOLINT(*-misplaced-const) | ||
switch (messageType) { | ||
case WM_CLOSE: | ||
case WM_KEYDOWN: | ||
case WM_DESTROY: | ||
PostQuitMessage(0); | ||
return 0; | ||
case WM_ERASEBKGND: { | ||
RECT clientRect; | ||
GetClientRect(windowHandle, &clientRect); | ||
FillRect(reinterpret_cast<HDC>(windowParameterValue), &clientRect, static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); | ||
return 1; | ||
} | ||
default: | ||
return DefWindowProc(windowHandle, messageType, windowParameterValue, messageData); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by spoil on 04/14/2024. | ||
// | ||
|
||
#ifndef WINDOWINITIATOR_HPP | ||
#define WINDOWINITIATOR_HPP | ||
|
||
|
||
class WindowInitiator { | ||
public: | ||
static void createWindow(); | ||
}; | ||
|
||
|
||
#endif //WINDOWINITIATOR_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <windows.h> | ||
#include "WindowInitiator.hpp" | ||
|
||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { | ||
WindowInitiator::createWindow(); | ||
|
||
return 0; | ||
} |