
Works here too

Thanks Rashad and obviously Hallodri

Code: Select all
Procedure OpenWindow2(id, x, y, w, h, title.s, classname.s, flags = #WS_OVERLAPPEDWINDOW | #WS_VISIBLE, parent = 0)
Define wnd.WNDCLASS, *winObj.Integer, hWnd, rc.rect
With wnd
\lpfnWndProc = @_PB_Window_ProcessEvent()
\hInstance = GetModuleHandle_(0)
\hIcon = PB_Window_Icon
\hCursor = PB_Window_Cursor
\lpszClassName = @classname
\hbrBackground = #COLOR_WINDOW
EndWith
If RegisterClass_(wnd)
w = DesktopScaledX(w)
h = DesktopScaledX(h)
SetRect_(rc, 0, 0, w, h)
AdjustWindowRectEx_(rc,flags,0,#WS_EX_WINDOWEDGE)
If x = #PB_Ignore Or y = #PB_Ignore
x = #CW_USEDEFAULT
y = #CW_USEDEFAULT
Else
x = DesktopScaledX(x)
y = DesktopScaledX(y)
EndIf
hWnd = CreateWindowEx_(#WS_EX_WINDOWEDGE, classname, title, flags, x, y, rc\right - rc\left, rc\bottom - rc\top, parent, 0, GetModuleHandle_(0), 0)
If hWnd
*WinObj = PB_Object_GetOrAllocateID(PB_Window_Objects, id)
*WinObj\i = hWnd
If id = #PB_Any
SetProp_(hWnd,"Pb_WindowID", *WinObj +1)
Else
SetProp_(hWnd,"Pb_WindowID", id +1)
EndIf
CreateGadgetList(hWnd)
UseGadgetList(hWnd)
If id = #PB_Any
id = *WinObj
Else
id = hWnd
EndIf
Else
UnregisterClass_(GetModuleHandle_(0),classname)
EndIf
EndIf
ProcedureReturn id
EndProcedure