I’m experimenting with creating a custom borderless window using PureBasic Engine3D, simulating a normal Windows window with:
- a fake title bar drawn with sprites
- a close button
- manual window dragging using ResizeWindow()
- continuous 3D rendering via OpenWindowedScreen()
Visually, the code works, but the window does not behave like a normal Windows window, and I’m not sure whether this is a limitation of the Engine3D or if I’m missing a better architectural approach.
Issues observed
- The window does not respond exactly like a standard Windows window
(focus behavior, dragging feel, system interaction)
- WindowEvent() handling feels limited or inconsistent when combined with
OpenWindowedScreen()
- During some interactions (losing focus, clicking outside, fast dragging),
the behavior is not consistent
- I’m unsure if this kind of “fake window” is:
- inherently limited by Engine3D
- or if there is a recommended pattern to implement this more correctly in PureBasic
Code :
Code: Select all
#WIN_W = 800 #WIN_H = 600 #TITLE_H = 32 #BTN_SIZE = 24 InitEngine3D() InitSprite() InitKeyboard() InitMouse() OpenWindow(0, 200, 200, #WIN_W, #WIN_H, "", #PB_Window_BorderLess) OpenWindowedScreen(WindowID(0), 0, 0, #WIN_W, #WIN_H, 0, 0, 0) CreateSprite(1, #WIN_W, #TITLE_H) StartDrawing(SpriteOutput(1)) Box(0, 0, #WIN_W, #TITLE_H, RGB(40,40,40)) StopDrawing() CreateSprite(2, #BTN_SIZE, #BTN_SIZE) StartDrawing(SpriteOutput(2)) Box(0, 0, #BTN_SIZE, #BTN_SIZE, RGB(120,40,40)) StopDrawing() Global dragging = #False Global dragOffX, dragOffY Repeat ExamineMouse() While WindowEvent() : Wend mx = MouseX() my = MouseY() If MouseButton(#PB_MouseButton_Left) If my < #TITLE_H And dragging = #False dragging = #True dragOffX = DesktopMouseX() - WindowX(0) dragOffY = DesktopMouseY() - WindowY(0) EndIf Else dragging = #False EndIf If dragging ResizeWindow(0, DesktopMouseX() - dragOffX, DesktopMouseY() - dragOffY, #PB_Ignore, #PB_Ignore) EndIf RenderWorld() DisplaySprite(1, 0, 0) DisplaySprite(2, #WIN_W - #BTN_SIZE - 6, 4) FlipBuffers() Delay(1) Until KeyboardPushed(#PB_Key_Escape) End
The final goal is to avoid my game freezing when moving a native Windows window, and also to gain more control over the window behavior. Does anyone know how this code could be improved to work more reliably?

