Dafür verwende ich diese Methoden. Es funktioniert einwandfrei, wenn ich das übergeordnete Fenster verschiebe und das untergeordnete Fenster wieder an die richtige Position bringt.
Wenn ich das untergeordnete Fenster verschiebe, hat es diesen Versatz und passt nicht richtig in das übergeordnete Fenster.
Code: Select all
void ChangeWindowToPopup(HWND hwnd) {
LONG style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_CHILD;
style |= WS_OVERLAPPEDWINDOW;
style &= ~WS_MAXIMIZEBOX;
// Apply the new style
SetWindowLong(hwnd, GWL_STYLE, style);
SetParent(hwnd, NULL);
}
void RevertToChildWindow(HWND hwnd, HWND parent) {
LONG style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_OVERLAPPEDWINDOW;
style |= WS_CHILD;
SetWindowLong(hwnd, GWL_STYLE, style);
SetParent(hwnd, parent);
}