Sub Item_Window.Destroy() ID = "" : Title = "" DestroyWindow(whwnd) whwnd = 0 End Sub Function CreateNewWindow(byval w as Integer, byval h as Integer, byval t as String = "", byval x as integer = 0, byval y as integer = 0, byval s as UInteger = 0, byval se as UInteger = 0) as Item Dim ExStyle as UInteger = IIF(se, se, WS_EX_CLIENTEDGE OR WS_EX_CONTROLPARENT) Dim Style as UInteger = IIF(s , s , WS_GROUP OR WS_VISIBLE OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN OR WS_CAPTION OR WS_OVERLAPPED OR WS_SYSMENU OR WS_MINIMIZEBOX) Dim as Integer wWidth, wHeight Dim as RECT WindowRect WindowRect.left = x WindowRect.top = y WindowRect.right = x+w WindowRect.bottom = y+h AdjustWindowRectEx(@WindowRect, Style, NULL, ExStyle) wWidth = WindowRect.right -WindowRect.left wHeight = WindowRect.bottom-WindowRect.top Dim NewWindow as Item_Window ptr = NEW Item_Window Dim whwnd as HWND = CreateWindowEx(ExStyle, strptr(Globals.ClassName), t, Style, _ WindowRect.left, WindowRect.top, wWidth, wHeight, _ NULL, NULL, Globals.hInstance, NewWindow) If (whwnd = 0) Then Delete NewWindow LOGSTRING(Time & " | ERROR | Failed to create " & WindowID & " " & t) MessageBox(NULL,"Failed to create " & WindowID & " " & t, "Error", NULL) Return 0 End If SetWindowLongPtr(whwnd, GWLP_USERDATA, Cast(LONG_PTR, NewWindow)) LOGSTRING(Time & " | INFO | " & WindowID & " " & t & " created.") NewWindow -> ID = WindowID NewWindow -> Title = t NewWindow -> whwnd = whwnd SendMessage(whwnd, WM_SETFONT, Cast(WPARAM, Globals.hFont), Cast(LPARAM,TRUE)) Globals.ItemList.AddItem(NewWindow) '- center Dim DesktopWidth as Integer = GetSystemMetrics(SM_CXSCREEN) Dim DesktopHeight as Integer = GetSystemMetrics(SM_CYSCREEN) Dim as Integer ww Dim as Integer wh Dim as Integer px Dim as Integer py = DesktopHeight*0.5 - wh*0.5 If GetWindowRect(whwnd, @WindowRect) <> 0 Then ww = WindowRect.right - WindowRect.left wh = WindowRect.bottom - WindowRect.top If x=0 and y=0 then px = DesktopWidth*0.5 - ww*0.5 py = DesktopHeight*0.5 - wh*0.5 MoveWindow(whwnd, px, py, ww, wh, TRUE) End if End If '- ShowWindow(whwnd,SW_SHOW) PostMessage(whwnd, WM_ACTIVATE, 1, 0) 'Globals.TabStopHandle = whwnd Return NewWindow End Function