Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SpoilerRules committed Apr 14, 2024
0 parents commit a174c16
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
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/
16 changes: 16 additions & 0 deletions CMakeLists.txt
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
)
27 changes: 27 additions & 0 deletions README.md
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!
62 changes: 62 additions & 0 deletions src/app/WindowInitiator.cpp
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);
}
}

15 changes: 15 additions & 0 deletions src/app/WindowInitiator.hpp
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
8 changes: 8 additions & 0 deletions src/app/main.cpp
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;
}

0 comments on commit a174c16

Please sign in to comment.