{"id":15047890,"url":"https://github.com/rodrigocfd/winlamb","last_synced_at":"2025-04-05T17:05:52.511Z","repository":{"id":64005009,"uuid":"89532325","full_name":"rodrigocfd/winlamb","owner":"rodrigocfd","description":"A lightweight modern C++11 library for Win32 API, using lambdas to handle Windows messages.","archived":false,"fork":false,"pushed_at":"2024-07-28T19:12:05.000Z","size":390,"stargazers_count":362,"open_issues_count":1,"forks_count":35,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-29T16:05:16.606Z","etag":null,"topics":["cplusplus","cplusplus-11","cpp","cpp11","stl","win32","winapi","winlamb"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodrigocfd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-26T22:31:05.000Z","updated_at":"2025-03-26T07:52:27.000Z","dependencies_parsed_at":"2024-10-29T20:28:28.025Z","dependency_job_id":null,"html_url":"https://github.com/rodrigocfd/winlamb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigocfd%2Fwinlamb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigocfd%2Fwinlamb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigocfd%2Fwinlamb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigocfd%2Fwinlamb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrigocfd","download_url":"https://codeload.github.com/rodrigocfd/winlamb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplusplus","cplusplus-11","cpp","cpp11","stl","win32","winapi","winlamb"],"created_at":"2024-09-24T21:05:48.976Z","updated_at":"2025-04-05T17:05:52.462Z","avatar_url":"https://github.com/rodrigocfd.png","language":"C++","funding_links":[],"categories":["GUI"],"sub_categories":[],"readme":"# WinLamb\r\n\r\nA lightweight modern C++11 library for [Win32 API](https://en.wikipedia.org/wiki/Windows_API), using [lambdas](https://www.cprogramming.com/c++11/c++11-lambda-closures.html) to handle Windows messages.\r\n\r\n1. [Overview](#1-overview)\r\n2. [Setup](#2-setup)\r\n3. [Example](#3-example)\r\n4. [Classes summary](#4-classes-summary)\r\n5. [License](#5-license)\r\n\r\n## 1. Overview\r\n\r\nAs 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.\r\n\r\nThen I wrote [CodeProject - WinLamb: using C++11 lambdas to handle Win32 messages](https://www.codeproject.com/Articles/1184175/WinLamb-using-Cplusplus-lambdas-to-handle-Win-mess), a comprehensive article explaining WinLamb's message handling model, with [dialogs](https://docs.microsoft.com/pt-br/windows/desktop/dlgbox/dialog-boxes) and also [ordinary windows](https://docs.microsoft.com/pt-br/windows/desktop/winmsg/windows). Actually, features from C++14 and C++17 are used as well, as much as my compiler (Visual C++) allows it.\r\n\r\nBeyond dialog/window message handling, WinLamb also has wrappers for most native Windows controls ([textbox](https://docs.microsoft.com/pt-br/windows/desktop/Controls/edit-controls), [listview](https://docs.microsoft.com/pt-br/windows/desktop/Controls/list-view-control-reference), 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.\r\n\r\nWinLamb 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.\r\n\r\nThere is a great WinLamb presentation from *Utah C++ Programmers* here: https://youtu.be/2K52YX-vHv4\r\n\r\n## 2. Setup\r\n\r\nWinLamb is a header-only library. You can clone the repository or simply [download](https://github.com/rodrigocfd/winlamb/archive/master.zip) the files; once referenced in your source code, it should work right away.\r\n\r\nIt has been tested with Visual C++ 2017.\r\n\r\n### 2.1. Windows 10 manifest file\r\n\r\nThere's an included `win10.exe.manifest` file, which you can [add to your Visual Studio project](https://stackoverflow.com/a/18115255/6923555). This manifest includes Common Controls and gives you [Windows 10 support](https://docs.microsoft.com/pt-br/windows/desktop/SysInfo/targeting-your-application-at-windows-8-1).\r\n\r\n## 3. Example\r\n\r\nThis is a simple Win32 program written with WinLamb. Each window has a class, and messages are handled with C++11 lambdas using [message crackers](internals/params_wm.h?ts=4#L20). There's no need to write a message loop or window registering.\r\n\r\n*Declaration:* My_Window.h\r\n\r\n````cpp\r\n#include \"winlamb/window_main.h\"\r\n\r\nclass My_Window : public wl::window_main {\r\npublic:\r\n    My_Window();\r\n};\r\n````\r\n\r\n*Implementation:* My_Window.cpp\r\n\r\n````cpp\r\n#include \"My_Window.h\"\r\n\r\nRUN(My_Window) // optional, generate WinMain call and instantiate My_Window\r\n\r\nMy_Window::My_Window()\r\n{\r\n    setup.wndClassEx.lpszClassName = L\"SOME_CLASS_NAME\"; // class name to be registered\r\n    setup.title = L\"This is my window\";\r\n    setup.style |= WS_MINIMIZEBOX;\r\n\r\n    on_message(WM_CREATE, [this](wl::wm::create p) -\u003e LRESULT\r\n    {\r\n        set_text(L\"A new title for the window\");\r\n        return 0;\r\n    });\r\n\r\n    on_message(WM_LBUTTONDOWN, [](wl::wm::lbuttondown p) -\u003e LRESULT\r\n    {\r\n        bool isCtrlDown = p.has_ctrl();\r\n        long xPos = p.pos().x;\r\n        return 0;\r\n    });\r\n}\r\n````\r\n\r\n### 3.1. Project examples\r\n\r\nI've written the following examples showcasing different things:\r\n\r\n* [Click lines](https://github.com/rodrigocfd/click-lines) (very simple example)\r\n* [FLAC/LAME frontend](https://github.com/rodrigocfd/flac-lame-frontend)\r\n* [Chromium Peeker](https://github.com/rodrigocfd/chromium-peeker)\r\n\r\nMore projects can be seen browsing [winlamb topic](https://github.com/topics/winlamb).\r\n\r\n## 4. Classes summary\r\n\r\nMost files are named after the class they contain; for example, file \"button.h\" contains `button` class.\r\n\r\nTo create your windows, you inherit from these classes below. See the [article](https://www.codeproject.com/Articles/1184175/WinLamb-using-Cplusplus-lambdas-to-handle-Win-mess) and the [examples](#3-example) to learn how to use them:\r\n\r\n| Class | Description |\r\n| :--- | :--- |\r\n| [`dialog_control`](dialog_control.h?ts=4) | Inherit from this class to have a dialog to be used as a control within a parent window. |\r\n| [`dialog_main`](dialog_main.h?ts=4) | Inherit from this class to have a dialog as the main window for your application. |\r\n| [`dialog_modal`](dialog_modal.h?ts=4) | Inherit from this class to have a modal dialog popup. |\r\n| [`dialog_modeless`](dialog_modeless.h?ts=4) | Inherit from this class to have a dialog modeless popup. |\r\n| [`window_control`](window_control.h?ts=4) | Inherit from this class to have an user-custom window control. |\r\n| [`window_main`](window_main.h?ts=4) | Inherit from this class to have an ordinary main window for your application. |\r\n\r\nWrappers and utilities:\r\n\r\n| Class | Description |\r\n| :--- |:--- |\r\n| [`button`](button.h?ts=4) | Wrapper to native button control. |\r\n| [`checkbox`](checkbox.h?ts=4) | Wrapper to native checkbox control. |\r\n| [`com::bstr`](internals/com_bstr.h?ts=4#L18) | Wrapper to BSTR string, used with COM. |\r\n| [`com::lib`](internals/com_lib.h?ts=4#L18) | Smart class to automate CoInitialize and CoUninitialize calls. |\r\n| [`com::ptr`](internals/com_ptr.h?ts=4#L16) | Wrapper to a COM pointer. |\r\n| [`com::variant`](internals/com_variant.h?ts=4#L18) | Wrapper to VARIANT object, used with COM. |\r\n| [`combobox`](combobox.h?ts=4) | Wrapper to native combobox control. |\r\n| [`datetime`](datetime.h?ts=4) | Wrapper to SYSTEMTIME structure. |\r\n| [`datetime_picker`](datetime_picker.h?ts=4) | Wrapper to datetime picker control from Common Controls library. |\r\n| [`gdi::dc`](gdi.h?ts=4#L19) | Wrapper to device context. |\r\n| [`gdi::dc_painter`](gdi.h?ts=4#L252) | Wrapper to device context which calls BeginPaint/EndPaint automatically. |\r\n| [`gdi::dc_painter_buffered`](gdi.h?ts=4#L306) | Wrapper to device context which calls BeginPaint/EndPaint automatically with double-buffer. |\r\n| [`download`](download.h?ts=4) | Automates internet download operations. |\r\n| [`executable`](executable.h?ts=4) | Executable-related utilities. |\r\n| [`file`](file.h?ts=4) | Wrapper to a low-level HANDLE of a file. |\r\n| [`file_ini`](file_ini.h?ts=4) | Wrapper to INI file. |\r\n| [`file_mapped`](file_mapped.h?ts=4) | Wrapper to a memory-mapped file. |\r\n| [`font`](font.h?ts=4) | Wrapper to HFONT handle. |\r\n| [`icon`](icon.h?ts=4) | Wrapper to HICON handle. |\r\n| [`image_list`](image_list.h?ts=4) | Wrapper to image list object from Common Controls library. |\r\n| [`insert_order_map`](insert_order_map.h?ts=4) | Vector-based associative container which keeps the insertion order. |\r\n| [`label`](label.h?ts=4) | Wrapper to native static text control. |\r\n| [`listview`](listview.h?ts=4) | Wrapper to listview control from Common Controls library. |\r\n| [`menu`](menu.h?ts=4) | Wrapper to HMENU handle. |\r\n| [`path`](path.h?ts=4) | Utilities to file path operations with std::wstring. |\r\n| [`progress_taskbar`](progress_taskbar.h?ts=4) | Allows to show a progress bar in the taskbar button of the window, in green, yellow or red. |\r\n| [`progressbar`](progressbar.h?ts=4) | Wrapper to progressbar control from Common Controls library. |\r\n| [`radio`](radio.h?ts=4) | Wrapper to native radio button control. |\r\n| [`radio_group`](radio_group.h?ts=4) | Automates a group of native radio buttons. |\r\n| [`resizer`](resizer.h?ts=4) | Allows the resizing of multiple controls when the parent window is resized. |\r\n| [`scrollinfo`](scrollinfo.h?ts=4) | Automates SCROLLINFO operations. |\r\n| [`statusbar`](statusbar.h?ts=4) | Wrapper to status control from Common Controls library. |\r\n| [`str`](str.h?ts=4) | Utilities to std::wstring. |\r\n| [`subclass`](subclass.h?ts=4) | Manages window subclassing for a window. |\r\n| [`sysdlg`](sysdlg.h?ts=4) | Wrappers to system dialogs. |\r\n| [`syspath`](syspath.h?ts=4) | Retrieves system paths. |\r\n| [`textbox`](textbox.h?ts=4) | Wrapper to native edit box control. |\r\n| [`treeview`](treeview.h?ts=4) | Wrapper to treeview control from Common Controls library. |\r\n| [`vec`](vec.h?ts=4) | Utilities to std::vector. |\r\n| [`version`](version.h?ts=4) | Parses version information from an EXE or DLL. |\r\n| [`wnd`](wnd.h?ts=4) | Simple HWND wrapper, base to all dialog and window classes. |\r\n| [`xml`](xml.h?ts=4) | XML wrapper class to MSXML2 Windows library. |\r\n| [`zip`](zip.h?ts=4) | Utilities to work with zipped files. |\r\n\r\n## 5. License\r\n\r\nLicensed under [MIT license](https://opensource.org/licenses/MIT), see [LICENSE.txt](LICENSE.txt) for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigocfd%2Fwinlamb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigocfd%2Fwinlamb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigocfd%2Fwinlamb/lists"}