All Projects → rodrigocfd → Winlamb

rodrigocfd / Winlamb

Licence: mit
A lightweight modern C++11 library for Win32 API, using lambdas to handle Windows messages.

Programming Languages

cpp
1120 projects
cplusplus
227 projects
cpp11
221 projects

Projects that are alternatives of or similar to Winlamb

pelauncher
Portable Executable launcher for Windows NT bypassing loader
Stars: ✭ 49 (-68.79%)
Mutual labels:  winapi, win32
isotoxin
Isotoxin source
Stars: ✭ 69 (-56.05%)
Mutual labels:  winapi, win32
Xdpw
XD Pascal: A small embeddable self-hosting Pascal compiler for Windows. Supports Go-style methods and interfaces
Stars: ✭ 199 (+26.75%)
Mutual labels:  winapi, win32
Win32 Programming
Win32编程
Stars: ✭ 151 (-3.82%)
Mutual labels:  winapi, win32
Iter
Go implementation of C++ STL iterators and algorithms.
Stars: ✭ 132 (-15.92%)
Mutual labels:  stl
Duckyspark
Translator from USB-Rubber-Ducky payloads to a Digispark code.
Stars: ✭ 107 (-31.85%)
Mutual labels:  stl
Fifo map
a FIFO-ordered associative container for C++
Stars: ✭ 100 (-36.31%)
Mutual labels:  stl
Mystl
C++11 实现的简易版 STL
Stars: ✭ 97 (-38.22%)
Mutual labels:  stl
Dem.net
Digital Elevation model library in C#. 3D terrain models, line/point Elevations, intervisibility reports
Stars: ✭ 153 (-2.55%)
Mutual labels:  stl
Hexed
Windows console-based hex editor
Stars: ✭ 145 (-7.64%)
Mutual labels:  win32
Slib
SLib - A universal, efficient, light-weight framework for building cross-platform applications on Android/iOS/macOS/Tizen/Win32/Linux platforms, developed by SLIBIO. Based on C++, provides desktop/mobile widgets, OpenGL rendering and networking solutions.
Stars: ✭ 113 (-28.03%)
Mutual labels:  win32
Projectreunion
The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
Stars: ✭ 2,612 (+1563.69%)
Mutual labels:  win32
Openjscad.org
JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
Stars: ✭ 1,851 (+1078.98%)
Mutual labels:  stl
Vac Hooks
Hook WinAPI functions used by Valve Anti-Cheat. Log calls and intercept arguments & return values. DLL written in C.
Stars: ✭ 103 (-34.39%)
Mutual labels:  winapi
Ai tetris
AI 俄罗斯方块(C++)
Stars: ✭ 150 (-4.46%)
Mutual labels:  winapi
Cropper
Point and shoot screen captures
Stars: ✭ 100 (-36.31%)
Mutual labels:  win32
Clavier Plus
Clavier+ keyboard shortcuts manager for Windows
Stars: ✭ 109 (-30.57%)
Mutual labels:  win32
Algorithms
STL Algorithm Cheat Sheet + example code from STL Algorithm Video Series.
Stars: ✭ 136 (-13.38%)
Mutual labels:  stl
Pb stl
STL import/export for Unity, supporting both ASCII and Binary.
Stars: ✭ 108 (-31.21%)
Mutual labels:  stl
Winmerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Stars: ✭ 2,358 (+1401.91%)
Mutual labels:  win32

WinLamb

A lightweight modern C++11 library for Win32 API, using lambdas to handle Windows messages.

  1. Overview
  2. Setup
  3. Example
  4. Classes summary
  5. License

1. Overview

As far as I can remember, around 2002 I started wrapping all my Win32 routines in classes, to make them reusable to myself, to save my time. Through all these years it took the form of a real library, a thin abstraction layer over raw Win32. People who saw it often commented that it was good, so in 2017 I decided to publish it on GitHub.

Then I wrote CodeProject - WinLamb: using C++11 lambdas to handle Win32 messages, a comprehensive article explaining WinLamb's message handling model, with dialogs and also ordinary windows. Actually, features from C++14 and C++17 are used as well, as much as my compiler (Visual C++) allows it.

Beyond dialog/window message handling, WinLamb also has wrappers for most native Windows controls (textbox, listview, etc.), along with other utility classes (strings, file I/O, COM wrappers, etc.) which play nice together. These controls and utilities, however, are not mandatory: you can use your own classes upon the basic dialog/window infrastructure.

WinLamb by no means covers the whole Win32 API, simply because it's too huge. It just wraps some things. New features are constantly being added, though.

2. Setup

WinLamb is a header-only library. You can clone the repository or simply download the files; once referenced in your source code, it should work right away.

It has been tested with Visual C++ 2017.

2.1. Windows 10 manifest file

There's an included win10.exe.manifest file, which you can add to your Visual Studio project. This manifest includes Common Controls and gives you Windows 10 support.

3. Example

This is a simple Win32 program written with WinLamb. Each window has a class, and messages are handled with C++11 lambdas using message crackers. There's no need to write a message loop or window registering.

Declaration: My_Window.h

#include "winlamb/window_main.h"

class My_Window : public wl::window_main {
public:
    My_Window();
};

Implementation: My_Window.cpp

#include "My_Window.h"

RUN(My_Window) // optional, generate WinMain call and instantiate My_Window

My_Window::My_Window()
{
    setup.wndClassEx.lpszClassName = L"SOME_CLASS_NAME"; // class name to be registered
    setup.title = L"This is my window";
    setup.style |= WS_MINIMIZEBOX;

    on_message(WM_CREATE, [this](wl::wm::create p) -> LRESULT
    {
        set_text(L"A new title for the window");
        return 0;
    });

    on_message(WM_LBUTTONDOWN, [](wl::wm::lbuttondown p) -> LRESULT
    {
        bool isCtrlDown = p.has_ctrl();
        long xPos = p.pos().x;
        return 0;
    });
}

3.1. Project examples

I've written the following examples showcasing different things:

More projects can be seen browsing winlamb topic.

4. Classes summary

Most files are named after the class they contain; for example, file "button.h" contains button class.

To create your windows, you inherit from these classes below. See the article and the examples to learn how to use them:

Class Description
dialog_control Inherit from this class to have a dialog to be used as a control within a parent window.
dialog_main Inherit from this class to have a dialog as the main window for your application.
dialog_modal Inherit from this class to have a modal dialog popup.
dialog_modeless Inherit from this class to have a dialog modeless popup.
window_control Inherit from this class to have an user-custom window control.
window_main Inherit from this class to have an ordinary main window for your application.

Wrappers and utilities:

Class Description
button Wrapper to native button control.
checkbox Wrapper to native checkbox control.
com::bstr Wrapper to BSTR string, used with COM.
com::lib Smart class to automate CoInitialize and CoUninitialize calls.
com::ptr Wrapper to a COM pointer.
com::variant Wrapper to VARIANT object, used with COM.
combobox Wrapper to native combobox control.
datetime Wrapper to SYSTEMTIME structure.
datetime_picker Wrapper to datetime picker control from Common Controls library.
gdi::dc Wrapper to device context.
gdi::dc_painter Wrapper to device context which calls BeginPaint/EndPaint automatically.
gdi::dc_painter_buffered Wrapper to device context which calls BeginPaint/EndPaint automatically with double-buffer.
download Automates internet download operations.
executable Executable-related utilities.
file Wrapper to a low-level HANDLE of a file.
file_ini Wrapper to INI file.
file_mapped Wrapper to a memory-mapped file.
font Wrapper to HFONT handle.
icon Wrapper to HICON handle.
image_list Wrapper to image list object from Common Controls library.
insert_order_map Vector-based associative container which keeps the insertion order.
label Wrapper to native static text control.
listview Wrapper to listview control from Common Controls library.
menu Wrapper to HMENU handle.
path Utilities to file path operations with std::wstring.
progress_taskbar Allows to show a progress bar in the taskbar button of the window, in green, yellow or red.
progressbar Wrapper to progressbar control from Common Controls library.
radio Wrapper to native radio button control.
radio_group Automates a group of native radio buttons.
resizer Allows the resizing of multiple controls when the parent window is resized.
scrollinfo Automates SCROLLINFO operations.
statusbar Wrapper to status control from Common Controls library.
str Utilities to std::wstring.
subclass Manages window subclassing for a window.
sysdlg Wrappers to system dialogs.
syspath Retrieves system paths.
textbox Wrapper to native edit box control.
treeview Wrapper to treeview control from Common Controls library.
vec Utilities to std::vector.
version Parses version information from an EXE or DLL.
wnd Simple HWND wrapper, base to all dialog and window classes.
xml XML wrapper class to MSXML2 Windows library.
zip Utilities to work with zipped files.

5. License

Licensed under MIT license, see LICENSE.txt for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].