Comments (2)
This is unrelated to TGUI and specific about the Windows API. I have no experience with functions like DwmExtendFrameIntoClientArea, so I can't help with this.
from tgui.
Thanks for reply.
I found out a way.
But only for windows.
#include <TGUI/TGUI.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>
#include <Windows.h>
#include <windowsx.h>
#include <dwmapi.h>
WNDPROC SFMLWndProc;
const POINT border{
GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER),
GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)
};
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
switch (msg) {
case WM_NCCALCSIZE:
{
if (wparam == TRUE)
{
WINDOWPLACEMENT placement;
GetWindowPlacement(hwnd, &placement);
if (placement.showCmd == SW_MAXIMIZE) {
auto monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
MONITORINFO monitor_info{};
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(monitor, &monitor_info);
auto& params = *reinterpret_cast<NCCALCSIZE_PARAMS*>(lparam);
params.rgrc[0] = monitor_info.rcWork;
}
return false;
}
break;
}
case WM_NCHITTEST: {
POINT cursor{ GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
RECT winRect;
if (!GetWindowRect(hwnd, &winRect)) {
return HTNOWHERE;
}
static const unsigned client{ 0b0000 }, left{ 0b0001 },
right{ 0b0010 }, top{ 0b0100 }, bottom{ 0b1000 };
const auto result =
left * (cursor.x < (winRect.left + border.x)) |
right * (cursor.x >= (winRect.right - border.x)) |
top * (cursor.y < (winRect.top + border.y)) |
bottom * (cursor.y >= (winRect.bottom - border.y));
switch (result) {
case left: return HTLEFT;
case right: return HTRIGHT;
case top: return HTTOP;
case bottom: return HTBOTTOM;
case top | left: return HTTOPLEFT;
case top | right: return HTTOPRIGHT;
case bottom | left: return HTBOTTOMLEFT;
case bottom | right: return HTBOTTOMRIGHT;
case client: return HTCAPTION;
default: return HTNOWHERE;
}
break;
}
}
return CallWindowProc(SFMLWndProc, hwnd, msg, wparam, lparam);
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine, _In_ int nCmdShow)
{
sf::RenderWindow window(sf::VideoMode(sf::Vector2u(800, 600)), "MyWin");
tgui::Gui gui{ window };
auto hwnd = window.getNativeHandle();
SFMLWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
const MARGINS shadowState{ 0,0,0,1 };
DwmExtendFrameIntoClientArea(hwnd, &shadowState);
gui.mainLoop();
}
from tgui.
Related Issues (20)
- Autocomplete support for EditBox HOT 2
- Can not input CJK words HOT 9
- Black background shown when changing window size HOT 4
- How to implement a polygon window HOT 2
- Hover style does not disappear when mouse moves out of the window HOT 6
- Add a 2d chart or rendering 3d data for TGUI? HOT 1
- Chinese support? HOT 5
- Focus Issues HOT 1
- [ANNOUNCE] The TGUI now distributed via MSYS2 on Windows HOT 1
- CMake fails to install pkg-config files HOT 2
- On macOS, Input Method Editors(IME) behavior seems incorrect. HOT 6
- How to use SDL2/3 backend with cmake `FetchContent` HOT 2
- [Question] How to compile my first example of TGUI ? HOT 13
- [Bug] Dead radio button text HOT 3
- [Bug] Tabs state after disabled tab click HOT 2
- FileDialog documentation needs clarification and maybe working examples HOT 4
- Is there a C binding? HOT 12
- Raylib backend? HOT 15
- Cannot delete widgets inside of the gui-builder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tgui.