Strange 1px offset with RTL

Windows specific forum
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Strange 1px offset with RTL

Post by chi »

When I switch the window layout to RTL, the region isn't correctly aligned anymore. Is there a (good) reason why or is it a Windows bug?

Tested with XP, Win7, Win8.1

Code: Select all

Global oldProc
Global brushBG = CreateSolidBrush_(#Gray)
Global brushFRM = CreateSolidBrush_(#Red)

Procedure WndCallback(hwnd, msg, wparam, lparam)
  Select msg
      
    Case #WM_NCACTIVATE, #WM_ERASEBKGND
      ProcedureReturn
      
    Case #WM_NCPAINT
      GetWindowRect_(hwnd, wRect.RECT)
      wRgn = CreateRectRgn_(0, 0, wRect\right-wRect\left, wRect\bottom-wRect\top) 
      hdc = GetWindowDC_(hwnd)
      FillRgn_(hdc, wRgn, brushBG)      
      FrameRgn_(hdc, wRgn, brushFRM, 1, 1)
      DeleteObject_(wRgn)
      ReleaseDC_(hwnd, hdc)
      ProcedureReturn
      
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hwnd, msg, wparam, lparam)
EndProcedure

SetProcessDefaultLayout_(1) ; 0 = LTR, 1 = RTL

OpenWindow(0, 0, 0, 800, 500, "", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())
SetWindowTheme_(WindowID(0), "", "")

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Fix for RTL: (but... c'mon!)

Code: Select all

wRgn = CreateRectRgn_(-1, 0, wRect\right-wRect\left-1, wRect\bottom-wRect\top) 
Et cetera is my worst enemy