Page 1 of 2

Window BorderStyle

Posted: Tue Aug 28, 2007 9:27 pm
by eriansa
Is there a way to set the color of the resizeborder of a window? Or, even better, to set a patternbrush for the resizeborder?

Posted: Wed Aug 29, 2007 7:31 am
by eesau
You need to draw the border yourself while handling the #WM_NCPAINT message in a window callback.

More about that here.

Posted: Wed Aug 29, 2007 8:20 am
by netmaestro
The border itself is not difficult to ownerdraw, but the systemmenu buttons can be fiddly. I have some code from my CustomButton library that plugs in fairly easily though, and so here's an example of an owner-drawn resizable window border with a custom CloseButton:

Code: Select all

;===================================================================
; Program:            Ownerdrawn Resizable Window Frame Demo
; Author:             Lloyd Gallant (netmaestro)
; Date:               August 28, 2007
; Target OS:          Microsoft Windows All (I think)
; Target Compiler:    PureBasic 4.xx and later
; License:            Free, unrestricted, credit appreciated
;                     but not required
;===================================================================

; read in button images for the 3 states
*unpacked = AllocateMemory(3008)
UnpackMemory(?PicPak, *unpacked)
img0 = CatchImage(#PB_Any, *unpacked, 3008)
FreeMemory(*unpacked)
Global CB_Normal = GrabImage(img0, #PB_Any,0,0,18,18)
Global CB_Selected = GrabImage(img0, #PB_Any,18,0,18,18)
Global CB_Pressed = GrabImage(img0, #PB_Any,36,0,18,18)

StartDrawing(ImageOutput(img0))
  Global gTranscolor = Point(0,0)
StopDrawing()
FreeImage(img0)

*unpacked = AllocateMemory(19328)
UnpackMemory(?woodgrain, *unpacked)
Global gWoodTexture = CatchImage(#PB_Any, *unpacked, 19328)
FreeMemory(*unpacked)

Global gCloseButton_State = CB_Normal
Global captionH = GetSystemMetrics_(#SM_CYCAPTION)+GetSystemMetrics_(#SM_CYSIZEFRAME)
Global frameW = GetSystemMetrics_(#SM_CXSIZEFRAME)
Global buttonT = (captionH-18)/2

; we'll be using TransparentBlt_(), so make it available
Global msimg32 = OpenLibrary(#PB_Any, "msimg32.dll")
  Prototype TransparentBlt(hdcDest,destX,destY,destW,destH,hdcSrc,srcX,srcY,srcW,srcH,transCOLOR)
  Global TransparentBlt_.TransparentBlt = GetFunction(msimg32, "TransparentBlt")

Procedure WindowProc(hwnd,msg,wParam,lParam) 
    
  result = #PB_ProcessPureBasicEvents 

  Select msg
    Case #WM_MOUSEMOVE
      If gCloseButton_State <> CB_Normal
        gCloseButton_State = CB_Normal
        SendMessage_(hwnd, #WM_NCPAINT, 0,0)
      EndIf
      
    Case #WM_NCLBUTTONDOWN
      GetWindowRect_(hwnd, wr.RECT)
      cp.POINT
      cp\x = lparam & $FFFF - wr\left
      cp\y = lparam >> 16 - wr\top

      br.RECT
      br\left = wr\right-wr\left - 23
      br\right = br\left+18
      br\top = buttonT
      br\bottom = br\top + 18
      
      If PtInRect_(br, cp\x, cp\y)
        gCloseButton_State = CB_Pressed
        SendMessage_(hwnd, #WM_NCPAINT, 0,0)
        result = 0
      EndIf
      
    Case #WM_NCLBUTTONUP 
      GetWindowRect_(hwnd, wr.RECT)
      cp.POINT
      cp\x = lparam & $FFFF - wr\left
      cp\y = lparam >> 16 - wr\top
            
      br.RECT
      br\left = wr\right-wr\left - 23
      br\right = br\left+18
      br\top = buttonT
      br\bottom = br\top + 18
      
      If PtInRect_(br, cp\x, cp\y)
        If gCloseButton_State = CB_Pressed
          SendMessage_(hwnd, #WM_SYSCOMMAND, #SC_CLOSE, 0)
        EndIf
      Else
        gCloseButton_State = CB_Normal
        SendMessage_(hwnd, #WM_NCPAINT, 0,0)
        result = 0
      EndIf
          
    Case #WM_NCMOUSEMOVE
      GetWindowRect_(hwnd, wr.RECT)
      cp.POINT
      cp\x = lparam & $FFFF - wr\left
      cp\y = lparam >> 16 - wr\top
      
      br.RECT
      br\left = wr\right-wr\left - 23
      br\right = br\left+18
      br\top = buttonT
      br\bottom = br\top + 18
      
      If PtInRect_(br, cp\x, cp\y)
        If GetAsyncKeyState_(#VK_LBUTTON) & 32768
          If gCloseButton_State = CB_Pressed
            SendMessage_(hwnd, #WM_NCPAINT, 0,0)
          Else
            If gCloseButton_State <> CB_Selected
              gCloseButton_State = CB_Selected
              SendMessage_(hwnd, #WM_NCPAINT, 0,0)
            EndIf
          EndIf
        Else
          If gCloseButton_State <> CB_Selected
            gCloseButton_State = CB_Selected
            SendMessage_(hwnd, #WM_NCPAINT, 0,0)
          EndIf
        EndIf
      Else
        If gCloseButton_State <> CB_Normal
          gCloseButton_State = CB_Normal
          SendMessage_(hwnd, #WM_NCPAINT, 0,0)
        EndIf
      EndIf    
      result = 0
          
    Case #WM_NCPAINT, #WM_NCACTIVATE 
      
      GetWindowRect_(hwnd, wr.RECT)
      new_w = wr\right - wr\left
      new_h = wr\bottom - wr\top
      hdc = GetWindowDC_(hwnd) 
      hrgn = CreateRectRgn_(-1,-1,new_w+1, new_h+1)
      hrgn2 = CreateRectRgn_(frameW,captionH,new_w-frameW,new_h-frameW)
      CombineRgn_(hrgn, hrgn, hrgn2, #RGN_XOR)
      SelectClipRgn_(hdc, hrgn)
      hBrush = CreatePatternBrush_(ImageID(gWoodTexture))
      SelectObject_(hdc, hBrush)
      Rectangle_(hdc,-1,-1,new_w+1, new_h+1) 
      If IsImage(gCloseButton_State) 
      buttondc = CreateCompatibleDC_(hdc)
        SelectObject_(buttondc, ImageID(gCloseButton_State))
        TransparentBlt_(hdc, new_w - 23, buttonT, 18,18, buttondc,0,0,18,18,gTranscolor)
        DeleteDC_(buttondc)
      EndIf
      ReleaseDC_(hwnd, hdc)
      DeleteDC_(hdc) 
      DeleteObject_(hBrush)
      DeleteObject_(hrgn)
      DeleteObject_(hrgn2)
      result = 0 

  EndSelect 
  ProcedureReturn result 
EndProcedure 

Procedure MonitorButtons(hwnd)
  Repeat
    GetWindowRect_(hwnd, @wr.RECT)
    GetCursorPos_(@cp.POINT)
    ; if the cursor is outside the window, the CloseButton
    ; must show normal. All other cases are covered in the callback.
    If Not PtInRect_(wr, cp\x, cp\y)
      If gCloseButton_State <> CB_Normal
        gCloseButton_State = CB_Normal
        SendMessage_(hwnd, #WM_NCPAINT, 0,0)
      EndIf
    EndIf
    Delay(15)
  ForEver
EndProcedure

OpenWindow(0,0,0,320,240,"Ownerdrawn Frame",#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SetWindowColor(0, RGB(255,220,150))
SetWindowCallback(@WindowProc()) 
SendMessage_(WindowID(0), #WM_NCPAINT, 0 ,0)

; a thread ensures no mistakes in resetting the CloseButton image to normal
CreateThread(@MonitorButtons(), WindowID(0))

Repeat 
Until WaitWindowEvent()=#PB_Event_CloseWindow 

End

DataSection
  PicPak:
  Data.b $4A,$43,$C0,$0B,$00,$00,$72,$EC,$2F,$DE,$BC,$A9,$D0,$20,$69,$14,$59,$08,$18,$CA
  Data.b $08,$B0,$01,$25,$89,$22,$3C,$06,$18,$23,$98,$C4,$40,$50,$FF,$14,$60,$12,$79,$E2
  Data.b $7C,$80,$D2,$15,$A3,$B1,$CC,$74,$4E,$A2,$C0,$48,$30,$0D,$FD,$EF,$04,$6E,$65,$03
  Data.b $D0,$8C,$F4,$5C,$2E,$D4,$60,$15,$F5,$96,$27,$65,$63,$9D,$36,$AD,$9E,$F5,$57,$29
  Data.b $C7,$AD,$00,$2B,$53,$E3,$81,$15,$5D,$18,$14,$42,$1B,$50,$01,$C0,$58,$27,$67,$FB
  Data.b $04,$7A,$6A,$EC,$A1,$59,$4F,$42,$1B,$E0,$D0,$09,$84,$60,$6C,$B2,$63,$B5,$A3,$4F
  Data.b $99,$77,$19,$A0,$69,$F2,$27,$50,$45,$4E,$8A,$8D,$D5,$42,$B6,$D3,$F3,$ED,$77,$DC
  Data.b $19,$E8,$45,$7D,$6E,$4A,$A0,$3F,$E7,$36,$97,$60,$FE,$1F,$42,$21,$B4,$81,$91,$5A
  Data.b $2D,$74,$5B,$A1,$23,$A7,$55,$CA,$ED,$A4,$C7,$CA,$15,$B9,$60,$59,$BB,$2E,$09,$85
  Data.b $40,$3D,$CF,$9B,$B5,$D0,$27,$FA,$92,$B6,$E8,$4E,$A5,$32,$E2,$1D,$6C,$55,$66,$1D
  Data.b $4F,$96,$59,$AD,$E6,$CD,$E9,$06,$AC,$FC,$82,$F8,$B2,$58,$B4,$65,$2D,$74,$A7,$E2
  Data.b $64,$2E,$3F,$ED,$CB,$D6,$4C,$41,$1D,$F9,$93,$A6,$EC,$F6,$C0,$46,$53,$92,$10,$DA
  Data.b $C0,$6B,$B3,$16,$3A,$A1,$42,$6A,$CC,$90,$D7,$D5,$3E,$91,$52,$B3,$D2,$87,$CE,$2B
  Data.b $97,$E4,$95,$F9,$D3,$AA,$24,$D0,$61,$1A,$4C,$EB,$D7,$E7,$0A,$7A,$80,$07,$A1,$10
  Data.b $DA,$A0,$79,$94,$16,$3C,$44,$7F,$AE,$EE,$DE,$AC,$56,$E1,$C5,$87,$B5,$5A,$EA,$79
  Data.b $B4,$5B,$3E,$45,$0F,$56,$A7,$9D,$50,$BA,$02,$6F,$C0,$D2,$97,$C0,$4E,$AD,$D6,$42
  Data.b $27,$9C,$13,$E1,$43,$7D,$59,$B0,$71,$A5,$40,$23,$FE,$BF,$99,$19,$8B,$3E,$71,$4C
  Data.b $91,$3D,$74,$67,$F6,$7F,$7C,$C0,$34,$5F,$0D,$AA,$A0,$07,$A1,$13,$0A,$A1,$F1,$A5
  Data.b $44,$6B,$56,$1C,$90,$DA,$8E,$B5,$AB,$89,$D2,$A5,$5E,$6D,$BD,$BD,$ED,$DB,$B9,$CE
  Data.b $A7,$5E,$AD,$5F,$35,$59,$80,$0D,$D8,$F4,$B4,$41,$15,$F4,$2D,$74,$42,$21,$C7,$48
  Data.b $CD,$68,$DD,$AA,$7E,$6D,$B2,$55,$D1,$9F,$EF,$DB,$F6,$FB,$FA,$B1,$53,$CF,$B5,$3D
  Data.b $5B,$AE,$80,$B9,$77,$EB,$54,$41,$0F,$D8,$27,$14,$42,$1B,$2A,$A9,$D5,$42,$79,$8D
  Data.b $23,$15,$99,$EF,$7F,$C8,$A1,$BC,$97,$12,$C7,$CD,$52,$4E,$01,$53,$D0,$87,$32,$93
  Data.b $68,$97,$A0,$07,$78,$C0,$0A,$A1,$0D,$AA,$43,$6B,$A1,$13,$D6,$22,$B5,$A4,$5F,$72
  Data.b $07,$4B,$B8,$F0,$C4,$30,$09,$00,$33,$8A,$69,$F6,$25,$D9,$AE,$60,$AB,$B3,$81,$12
  Data.b $70,$00,$68,$83,$2A,$E8,$52,$EB,$84,$42,$1A,$0A,$F1,$24,$86,$55,$AF,$16,$CD,$9D
  Data.b $F8,$E5,$9C,$A3,$3C,$F4,$FF,$EE,$DA,$D0,$85,$DF,$D6,$2B,$00,$F1,$DD,$7E,$D0,$03
  Data.b $25,$D0,$85,$D0,$06,$55,$6A,$B5,$D0,$09,$E3,$47,$83,$4A,$EF,$FF,$C4,$1C,$52,$94
  Data.b $22,$19,$FB,$3E,$8E,$5A,$EF,$BD,$10,$98,$1F,$7E,$4B,$19,$00,$C4,$70,$FD,$E8,$81
  Data.b $12,$70,$42,$68,$83,$02,$B6,$5A,$E8,$84,$C4,$4E,$7D,$B8,$DD,$6B,$58,$D6,$96,$F2
  Data.b $95,$72,$61,$7E,$27,$5B,$F8,$70,$BC,$32,$EC,$99,$80,$9C,$AB,$D7,$FA,$1F,$09,$34
  Data.b $80,$85,$41,$15,$F4,$40,$74,$42,$21,$B4,$D6,$5C,$5B,$2D,$31,$BC,$28,$50,$AE,$58
  Data.b $F9,$E8,$AF,$D7,$2C,$65,$39,$C6,$D9,$C9,$EC,$C6,$01,$A3,$B8,$60,$C1,$34,$D3,$34
  Data.b $00,$FD,$1B,$30,$F7,$50,$42,$27,$14,$42,$87,$B3,$47,$D5,$6D,$71,$A3,$40,$BF,$ED
  Data.b $2F,$D8,$E2,$B8,$FC,$09,$E6,$39,$34,$3F,$E5,$C1,$93,$43,$C2,$6F,$EF,$84,$FF,$7F
  Data.b $D5,$52,$80,$12,$68,$00,$68,$83,$2A,$28,$5A,$E8,$84,$42,$44,$A2,$BC,$B6,$CD,$2E
  Data.b $91,$D4,$CA,$6E,$97,$90,$B4,$6A,$BB,$4B,$36,$13,$A6,$F9,$2F,$49,$EE,$A7,$0F,$B5
  Data.b $06,$98,$84,$36,$A0,$02,$AD,$85,$4E,$28,$E5,$18,$A9,$19,$BC,$67,$EB,$DF,$CF,$17
  Data.b $AD,$FD,$FF,$03,$B3,$C5,$F4,$8B,$75,$6A,$D4,$1A,$80,$3F,$42,$68,$03,$2B,$7D,$5A
  Data.b $E8,$84,$A4,$56,$F4,$27,$B6,$3F,$8C,$46,$76,$4B,$09,$DC,$3A,$CC,$A9,$01,$1F,$EB
  Data.b $84,$84,$D7,$86,$E0,$CA,$00,$FD,$A5,$2F,$C0,$03,$DA,$D0,$85,$D0,$06,$55,$6A,$B5
  Data.b $D0,$09,$4E,$76,$2C,$45,$DE,$CD,$96,$E5,$D9,$F0,$68,$27,$36,$ED,$77,$CA,$7A,$AF
  Data.b $A7,$A6,$FE,$DB,$46,$7D,$07,$4A,$E0,$00,$A1,$0D,$AA,$A0,$6B,$A1,$13,$0A,$B8,$C1
  Data.b $0C,$46,$5F,$EF,$D9,$E1,$F5,$F7,$45,$7B,$06,$28,$C0,$69,$B6,$76,$BF,$5F,$9C,$F3
  Data.b $27,$8C,$BD,$4F,$C3,$96,$40,$09,$60,$63,$B3,$41,$15,$F4,$FF,$BF,$69,$F3,$16,$F6
  Data.b $73,$02,$28,$71,$48,$AD,$BF,$69,$19,$00,$9A,$01,$AD,$7E,$D0,$C0,$80,$01,$3D,$FF
  Data.b $0B,$66,$F4,$00,$67,$63,$21,$B8,$41,$15,$5A,$2D,$74,$02,$48,$A1,$E2,$90,$B6,$6C
  Data.b $EB,$9F,$3E,$2D,$80,$76,$05,$BF,$76,$12,$58,$8D,$03,$A0,$93,$1A,$30,$94,$50,$05
  Data.b $3D,$40,$9D,$50,$08,$6D,$31,$3B,$55,$0B,$0F,$66,$8B,$9B,$FC,$05,$53,$FE,$66,$A1
  Data.b $37,$B5,$B9,$59,$FE,$BD,$40,$05,$3D,$40,$C7,$7E,$C1,$78,$9F,$13,$FA,$43,$19,$6A
  Data.b $B5,$F0,$4B,$DA,$E6,$A9,$AE,$ED,$D2,$E1,$29,$8B,$01,$14,$EF,$86,$E5,$4F,$00,$65
  Data.b $63,$F7,$E1,$6C,$15,$F4,$68,$C1,$13,$0E,$89,$D4,$DC,$A3,$F1,$90,$50,$AE,$09,$65
  Data.b $AD,$5A,$E3,$38,$00,$DB,$F7,$DE,$1D,$43,$9A,$75,$32,$E8,$81,$06,$D0,$ED,$AB,$82
  Data.b $1E,$28,$16,$3A,$01,$0F,$35,$7B,$54,$87,$52,$C4,$D9,$A1,$FC,$D6,$BF,$D9,$D4,$FE
  Data.b $0C,$10,$41,$DE,$BB,$4B,$38,$6B,$DA,$A2,$6C,$E0,$1A,$20,$0D,$AA,$80,$07,$B2,$A5
  Data.b $1E,$A0,$62,$FD,$CC,$0D,$7A,$21,$BC,$2C,$AC,$E6,$C2,$00,$D5,$9D,$42,$B7,$19,$6A
  Data.b $13,$A1,$0F,$6C,$03,$85,$42,$1B,$54,$41,$D5,$42,$27,$14,$80,$92,$1A,$A9,$E0,$6D
  Data.b $DB,$FA,$19,$F2,$70,$19,$4B,$B8,$53,$2A,$FE,$3B,$16,$F0,$3C,$73,$12,$07,$12,$68
  Data.b $00,$C4,$83,$2A,$E8,$81,$E8,$84,$42,$68,$41,$25,$B5,$5A,$0A,$EB,$6F,$41,$FF,$86
  Data.b $E1,$52,$66,$94,$C1,$1A,$E4,$BD,$8D,$B3,$F0,$99,$E8,$D1,$71,$56,$02,$0D,$42,$21
  Data.b $B4,$01,$91,$5A,$2D,$74,$21,$35,$8E,$28,$EF,$96,$8D,$4F,$4A,$DD,$B1,$F4,$D4,$DF
  Data.b $BB,$76,$55,$EE,$FB,$B8,$00,$9B,$7D,$06,$D0,$03,$25,$D0,$85,$D0,$06,$55,$6A,$B5
  Data.b $D0,$09,$B7,$AE,$2F,$4C,$B9,$14,$F3,$9C,$BC,$D9,$B1,$94,$D7,$00,$FF,$7D,$E6,$71
  Data.b $49,$70,$C6,$DD,$8B,$93,$D0,$00,$ED,$ED,$55,$D0,$03,$25,$09,$85,$D0,$06,$4F,$A4
  Data.b $B5,$D0,$CF,$13,$CB,$B5,$5F,$F1,$87,$0C,$9D,$42,$25,$E5,$71,$6D,$30,$EF,$1C,$BA
  Data.b $FC,$F7,$C7,$74,$21,$FF,$09,$34,$00,$7F,$BB,$E5,$F5,$40,$7F,$CF,$52,$CE,$5A,$E8
  Data.b $04,$FF,$9E,$4F,$FC,$AD,$B3,$FD,$4A,$B2,$7B,$B1,$53,$DB,$FB,$FF,$5D,$FB,$9A,$3E
  Data.b $AD,$D3,$3F,$77,$2C,$E3,$2B,$81,$06,$D0,$A1,$0D,$EC,$D8,$6A,$A1,$13,$0A,$14,$52
  Data.b $F3,$DA,$E7,$BE,$0E,$AA,$29,$74,$39,$77,$7D,$DD,$B8,$E8,$CD,$5C,$92,$FA,$3C,$71
  Data.b $DB,$BE,$38,$B0,$5F,$A1,$07,$F3,$9D,$9F,$F4,$84,$29,$EA,$27,$7D,$C4,$9A,$2A,$F0
  Data.b $1B,$94,$21,$B4,$41,$6E,$3D,$2D,$74,$42,$22,$D4,$0F,$2B,$12,$46,$55,$BC,$CC,$97
  Data.b $01,$F4,$FE,$01,$C9,$92,$4E,$64,$FB,$AE,$86,$37,$48,$99,$66,$C1,$9D,$D1,$38,$6C
  Data.b $87,$95,$2A,$E8,$01,$12,$5B,$FD,$35,$EC,$82,$27,$54,$E6,$D3,$38,$33,$D4,$CD,$2A
  Data.b $BC,$D2,$B4,$5C,$CF,$97,$FE,$85,$6A,$FA,$4B,$47,$AD,$1A,$CF,$E0,$BC,$89,$15,$DB
  Data.b $F8,$A6,$B8,$60,$F5,$D7,$09,$34,$00,$7C,$41,$15,$F4,$40,$74,$42,$21,$B4,$6A,$5C
  Data.b $5B,$2D,$BD,$5F,$BB,$4C,$BB,$0F,$CC,$F7,$53,$FF,$93,$15,$DD,$D9,$39,$6B,$D5,$97
  Data.b $F7,$1E,$7F,$9A,$32,$7D,$EE,$49,$4B,$66,$4F,$56,$8F,$01,$A9,$2F,$5F,$4A,$17,$E9
  Data.b $CE,$FA,$50,$08,$6D,$80,$EA,$53,$0B,$9D,$4F,$3A,$94,$3D,$FF,$9C,$07,$17,$37,$33
  Data.b $80,$E1,$B3,$61,$29,$B4,$DC,$94,$69,$EB,$6B,$7E,$63,$76,$17,$FF,$BA,$2F,$97,$CA
  Data.b $97,$DC,$93,$40,$E6,$FE,$49,$35,$BE,$35,$B4,$01,$63,$A6,$2D,$74,$42,$21,$4B,$89
  Data.b $36,$43,$7C,$C2,$73,$29,$B5,$FB,$54,$8B,$67,$BA,$07,$4B,$23,$CA,$CF,$2C,$97,$BD
  Data.b $5A,$78,$EB,$3B,$55,$E9,$31,$62,$CF,$00,$50,$05,$3D,$A0,$9D,$50,$08,$6D,$37,$35
  Data.b $5A,$0B,$FA,$84,$D4,$90,$E4,$C1,$BE,$93,$0C,$05,$78,$3F,$E7,$73,$76,$0C,$F4,$7F
  Data.b $DD,$A2,$DD,$99,$02,$FC,$4F,$03,$C0,$AF,$31,$20,$3E,$ED,$A8,$3B,$46,$EF,$B4,$C1
  Data.b $FF,$E0,$2D,$74,$42,$21,$F4,$6D,$74,$67,$5E,$D3,$A3,$DE,$69,$E1,$B4,$1E,$E9,$AA
  Data.b $29,$B8,$CA,$F5,$D6,$14,$21,$21,$79,$68,$01,$14,$FF,$C8,$32,$1A,$02,$8D,$EB,$AA
  Data.b $7D,$E0,$84,$42,$70,$83,$EA,$CD,$5A,$E8,$1F,$85,$69,$5D,$79,$BE,$77,$9D,$9E,$9F
  Data.b $7A,$71,$CE,$F4,$89,$67,$F9,$67,$84,$2C,$2F,$5C,$33,$45,$86,$9F,$D2,$C9,$05,$3D
  Data.b $60,$03,$50,$08,$6D,$50,$9D,$59,$0B,$9D,$60,$E8,$9E,$27,$67,$3F,$6B,$95,$AF,$33
  Data.b $AE,$33,$79,$DC,$FD,$3D,$2F,$5F,$7B,$BF,$B8,$90,$A7,$F0,$6C,$60,$9A,$07,$D0,$06
  Data.b $94,$F2,$B5,$D0,$09,$85,$A2,$5B,$66,$74,$E8,$28,$EB,$8D,$CD,$E8,$A8,$C0,$8A,$6E
  Data.b $B4,$DE,$E8,$CD,$06,$70,$BF,$75,$EB,$9C,$F4,$BC,$71,$AB,$49,$BA,$5D,$CB,$3A,$A1
  Data.b $10,$BC,$6E,$F7,$BF,$16,$0D,$75,$A8,$45,$CA,$A6,$50,$FD,$33,$60,$53,$AB,$81,$69
  Data.b $8C,$62,$14,$82,$09,$B8,$BD,$AB,$5D,$27,$53,$25,$03,$E6,$6D,$DE,$4C,$CE,$B0,$27
  Data.b $9C,$BC,$18,$EB,$84,$42,$88,$44,$08,$00,$00,$00,$00,$00
  woodgrain:
  Data.b $4A,$43,$80,$4B,$00,$00,$90,$25,$8C,$99,$B8,$A9,$D0,$20,$69,$14,$59,$0A,$12,$CA
  Data.b $08,$B0,$4A,$42,$A5,$B0,$0C,$30,$46,$02,$89,$81,$A0,$74,$60,$10,$D8,$42,$F0,$CF
  Data.b $8D,$14,$89,$D6,$A9,$51,$26,$2B,$DA,$80,$A1,$19,$25,$C6,$35,$45,$24,$EA,$04,$4B
  Data.b $02,$E9,$48,$E0,$1F,$8C,$54,$8C,$3A,$B1,$C3,$BC,$19,$F3,$72,$AC,$04,$CC,$58,$E5
  Data.b $99,$14,$22,$78,$46,$91,$24,$EB,$2C,$F3,$1A,$A0,$07,$28,$88,$04,$EA,$C1,$7C,$69
  Data.b $C9,$42,$72,$66,$03,$56,$87,$B7,$61,$74,$62,$9E,$93,$25,$87,$A1,$62,$76,$5A,$DB
  Data.b $0C,$89,$C6,$36,$7A,$D2,$17,$A9,$48,$28,$D2,$22,$E5,$94,$2C,$65,$03,$1C,$38,$33
  Data.b $BA,$DF,$1F,$30,$AE,$DC,$30,$8C,$E6,$36,$07,$28,$2D,$A3,$AD,$96,$BA,$B2,$E0,$83
  Data.b $B9,$41,$66,$C1,$50,$27,$D9,$95,$59,$03,$62,$0D,$40,$A3,$B8,$16,$03,$76,$1F,$BE
  Data.b $04,$C5,$6E,$96,$2B,$95,$0F,$C6,$09,$B4,$4E,$58,$27,$66,$C9,$66,$95,$DA,$92,$99
  Data.b $87,$D1,$08,$14,$12,$C6,$24,$14,$63,$9B,$53,$56,$82,$45,$79,$40,$66,$41,$93,$50
  Data.b $94,$9A,$50,$74,$3C,$E5,$4D,$42,$71,$F1,$42,$59,$51,$16,$65,$78,$C6,$45,$B0,$90
  Data.b $F1,$92,$14,$C7,$1B,$24,$F1,$B1,$59,$8A,$CD,$98,$AF,$48,$42,$59,$8A,$46,$F1,$A5
  Data.b $E6,$45,$43,$52,$7E,$AC,$33,$C6,$93,$E6,$0D,$E6,$24,$14,$A9,$66,$CD,$16,$71,$F4
  Data.b $B7,$D1,$F4,$22,$C5,$53,$09,$65,$35,$53,$51,$E8,$16,$F5,$35,$69,$19,$83,$6D,$D1
  Data.b $9C,$14,$59,$24,$14,$F5,$66,$8E,$99,$84,$F4,$00,$65,$CA,$12,$96,$B7,$67,$96,$55
  Data.b $3E,$C7,$65,$69,$59,$2A,$50,$F6,$24,$94,$71,$24,$14,$2F,$64,$98,$F5,$47,$C5,$5B
  Data.b $92,$59,$14,$57,$88,$45,$23,$59,$76,$18,$88,$D9,$89,$51,$71,$BE,$68,$54,$52,$84
  Data.b $98,$B3,$65,$27,$96,$73,$91,$50,$DC,$09,$46,$BD,$50,$59,$6F,$C3,$79,$60,$46,$59
  Data.b $35,$9A,$76,$24,$94,$05,$B9,$79,$11,$54,$48,$D6,$7B,$38,$94,$37,$C0,$D9,$67,$21
  Data.b $9A,$24,$53,$59,$7C,$A0,$A0,$59,$D0,$E6,$16,$7F,$C8,$B1,$91,$50,$54,$00,$7A,$F4
  Data.b $A8,$F9,$71,$27,$94,$41,$34,$BA,$59,$AA,$A9,$71,$91,$50,$F6,$91,$50,$7E,$DB,$1B
  Data.b $65,$63,$42,$F9,$90,$14,$75,$4B,$45,$4F,$BD,$79,$15,$1C,$67,$05,$53,$F4,$A7,$69
  Data.b $5E,$B2,$50,$51,$9D,$C6,$C5,$24,$94,$C1,$91,$50,$56,$88,$E5,$B9,$5A,$74,$A4,$45
  Data.b $17,$09,$9C,$1F,$4B,$19,$45,$50,$79,$E1,$14,$C5,$68,$E5,$FE,$49,$F9,$24,$23,$59
  Data.b $06,$69,$1E,$2D,$45,$59,$85,$50,$79,$24,$71,$A1,$5A,$59,$92,$67,$95,$C6,$7B,$F4
  Data.b $AB,$39,$C5,$94,$E6,$D9,$1A,$17,$F5,$CF,$16,$B5,$67,$1E,$75,$EB,$F9,$0C,$24,$46
  Data.b $49,$18,$16,$97,$34,$65,$79,$7E,$C6,$63,$24,$14,$CF,$C6,$7A,$7C,$42,$D1,$79,$36
  Data.b $1E,$43,$A5,$95,$1D,$AB,$54,$B7,$56,$BE,$54,$74,$17,$5E,$EA,$5C,$56,$6C,$1E,$FF
  Data.b $EC,$79,$4F,$42,$F1,$90,$1D,$97,$21,$99,$66,$F5,$72,$FC,$D7,$AA,$F1,$EE,$63,$F6
  Data.b $6C,$1C,$5D,$24,$14,$6D,$69,$F9,$21,$14,$F9,$24,$94,$77,$3F,$17,$E7,$4B,$5A,$4B
  Data.b $16,$DF,$BA,$D0,$2F,$43,$B3,$A1,$7C,$07,$84,$32,$60,$CB,$A2,$2A,$3C,$9A,$FD,$38
  Data.b $8B,$CD,$B3,$92,$B1,$E2,$05,$E8,$7C,$77,$38,$AF,$C8,$B8,$B3,$AA,$8D,$B5,$62,$E3
  Data.b $BC,$52,$38,$3B,$24,$CB,$EF,$8F,$A2,$9D,$9F,$8E,$1F,$30,$3A,$18,$2A,$FE,$07,$F3
  Data.b $73,$2C,$38,$69,$E9,$BC,$C3,$E7,$B3,$49,$7C,$CF,$90,$CC,$29,$DF,$33,$AE,$DF,$B1
  Data.b $A2,$C9,$B2,$38,$42,$CE,$CA,$E4,$E8,$42,$E5,$18,$8D,$8F,$CF,$80,$CB,$33,$E6,$B8
  Data.b $24,$28,$AA,$86,$8F,$56,$96,$8A,$4F,$35,$3F,$A8,$8C,$EE,$EE,$A7,$BC,$0B,$A1,$28
  Data.b $36,$8E,$4E,$F4,$E2,$22,$2B,$3A,$12,$8A,$43,$E0,$BC,$2C,$F8,$C2,$B6,$A2,$F0,$CC
  Data.b $54,$AD,$06,$60,$5A,$CA,$C1,$8F,$D9,$B8,$B2,$11,$3A,$DE,$01,$8B,$4A,$C5,$F2,$61
  Data.b $28,$AB,$4F,$8B,$8B,$84,$B2,$0A,$F4,$F8,$3C,$E3,$E2,$F7,$28,$DA,$C6,$38,$AE,$8F
  Data.b $8F,$49,$B1,$F8,$1D,$2B,$A3,$10,$38,$86,$A2,$B2,$22,$E5,$0F,$DB,$8A,$0F,$34,$B3
  Data.b $44,$29,$40,$BC,$06,$B0,$A1,$68,$6C,$2B,$E8,$2E,$CB,$27,$82,$CE,$8E,$A4,$38,$7B
  Data.b $2F,$EF,$44,$3E,$7A,$D7,$AD,$B8,$C8,$A8,$B2,$57,$F3,$B6,$81,$CA,$2B,$A5,$E8,$2E
  Data.b $CB,$0F,$49,$28,$7A,$D7,$8A,$67,$F1,$A8,$44,$2E,$2E,$12,$B3,$23,$A1,$F8,$92,$CB
  Data.b $0E,$D2,$CF,$CF,$2C,$7E,$37,$2C,$BB,$C6,$D9,$A8,$24,$A3,$F2,$49,$28,$BF,$07,$28
  Data.b $EB,$84,$8C,$92,$A1,$A3,$6E,$28,$2E,$66,$18,$CE,$B2,$31,$8F,$F2,$A6,$73,$DF,$CA
  Data.b $4E,$9E,$B3,$7B,$A3,$9C,$83,$F4,$3C,$30,$A2,$38,$A8,$F2,$0A,$2D,$9B,$84,$A2,$FB
  Data.b $A1,$F2,$18,$CC,$AE,$96,$CF,$4A,$97,$CE,$CC,$3C,$BA,$73,$2C,$4F,$8B,$F3,$1F,$F6
  Data.b $B2,$42,$2E,$8F,$CB,$8E,$CB,$F1,$28,$48,$28,$0A,$8C,$CA,$66,$B9,$A2,$91,$CE,$0A
  Data.b $D2,$A3,$9B,$37,$BB,$02,$3D,$E3,$21,$3D,$4F,$42,$81,$B4,$47,$76,$24,$99,$9D,$BF
  Data.b $64,$79,$15,$1C,$9D,$AB,$C5,$87,$53,$F1,$09,$1A,$D7,$89,$6A,$B4,$96,$65,$98,$A5
  Data.b $6C,$6C,$4F,$42,$F9,$D9,$E9,$F9,$DB,$9E,$F1,$23,$1E,$07,$70,$59,$35,$71,$4D,$42
  Data.b $59,$39,$96,$15,$A4,$67,$0F,$E9,$51,$D0,$9B,$E7,$EB,$1B,$E7,$2B,$5B,$FC,$0B,$57
  Data.b $9C,$35,$E5,$93,$50,$94,$E0,$99,$97,$6F,$2B,$9A,$67,$63,$54,$34,$09,$45,$FC,$54
  Data.b $7E,$B4,$D1,$81,$D0,$79,$CD,$D1,$79,$DA,$45,$4B,$65,$55,$F8,$82,$03,$24,$5E,$DC
  Data.b $F2,$82,$29,$BE,$92,$2A,$96,$AD,$F2,$23,$8B,$F7,$F3,$A2,$0D,$28,$7E,$D2,$CE,$9A
  Data.b $84,$A2,$5B,$F5,$28,$12,$A1,$78,$3F,$8F,$F2,$69,$CD,$27,$5A,$2A,$9F,$84,$CE,$2B
  Data.b $35,$3B,$F5,$EC,$F8,$0E,$E3,$BC,$9A,$A3,$6F,$8C,$CA,$67,$2F,$AB,$23,$3B,$12,$CA
  Data.b $EF,$86,$AC,$E2,$EC,$7C,$3C,$8C,$7F,$E3,$D0,$B2,$19,$28,$F2,$49,$28,$EE,$92,$8A
  Data.b $1A,$C9,$F2,$8A,$38,$7E,$8D,$F3,$E6,$E7,$3A,$E3,$CA,$8B,$3D,$AB,$2F,$8F,$5A,$A4
  Data.b $A8,$21,$AC,$64,$B8,$E2,$E0,$EC,$A6,$EC,$E8,$1A,$3D,$F7,$42,$CC,$3A,$B1,$BB,$AC
  Data.b $F0,$3C,$0E,$A6,$A8,$5D,$A1,$28,$51,$8E,$CA,$01,$38,$3F,$86,$2D,$2F,$12,$B3,$8A
  Data.b $84,$E2,$BA,$A2,$28,$1B,$F9,$CC,$81,$CA,$A8,$07,$F0,$79,$C3,$E0,$F8,$48,$2F,$AE
  Data.b $10,$CA,$D6,$E7,$78,$33,$28,$AE,$C9,$2B,$B3,$E1,$BC,$48,$2D,$EB,$A0,$8A,$0E,$D2
  Data.b $F3,$F5,$B7,$F3,$30,$38,$AC,$D7,$8A,$82,$6F,$AD,$58,$D9,$2E,$9E,$93,$F2,$CA,$B8
  Data.b $78,$19,$EC,$B1,$AD,$AC,$48,$CF,$DB,$E3,$8D,$9A,$84,$62,$AB,$36,$F3,$11,$B2,$AC
  Data.b $96,$38,$8F,$84,$B2,$5E,$3C,$3A,$6C,$2B,$5E,$D4,$A3,$D2,$1F,$CC,$49,$28,$CA,$EA
  Data.b $88,$CE,$71,$EA,$38,$54,$2B,$44,$AF,$38,$A1,$F8,$35,$3E,$9F,$9F,$CB,$87,$B2,$72
  Data.b $F6,$8A,$AD,$F2,$54,$FD,$FA,$B1,$A8,$7F,$E1,$68,$24,$8B,$53,$E5,$8A,$FA,$62,$3D
  Data.b $06,$CC,$2F,$0A,$D5,$F2,$23,$A1,$BC,$1D,$CF,$8B,$9F,$8B,$AD,$FC,$78,$48,$E8,$5C
  Data.b $BC,$E2,$D7,$F2,$B5,$E9,$2B,$07,$2E,$4E,$A5,$A2,$49,$28,$0C,$DB,$CA,$A7,$AA,$7C
  Data.b $59,$EB,$D2,$3C,$BE,$59,$F8,$FE,$B9,$EC,$A6,$FC,$57,$EA,$E2,$D6,$CD,$3B,$F3,$A2
  Data.b $A2,$A5,$6C,$24,$8B,$A7,$90,$E2,$B0,$AD,$7E,$CE,$2B,$EB,$DF,$A2,$C3,$29,$78,$12
  Data.b $CA,$EE,$62,$E3,$6C,$C3,$E7,$E2,$46,$B3,$7A,$91,$E2,$E2,$B6,$F3,$B4,$3C,$6B,$36
  Data.b $CE,$C7,$A9,$AC,$AF,$28,$8F,$8D,$E3,$4A,$24,$8B,$72,$32,$8D,$43,$C5,$38,$AC,$D0
  Data.b $F8,$9C,$A0,$B3,$92,$E6,$BB,$70,$CA,$43,$A9,$F8,$5B,$2A,$45,$AD,$F3,$D4,$C1,$B3
  Data.b $07,$E3,$13,$88,$20,$6D,$2B,$69,$AE,$AA,$CA,$2A,$85,$2A,$25,$3E,$2E,$12,$EA,$7F
  Data.b $2B,$3A,$A0,$6C,$75,$2F,$AB,$9D,$CE,$62,$A1,$73,$5E,$3B,$AC,$78,$B3,$1A,$98,$CB
  Data.b $1B,$E0,$28,$5D,$CB,$CA,$A6,$A3,$47,$B2,$8F,$85,$CE,$2E,$CF,$EC,$90,$2C,$43,$D2
  Data.b $81,$64,$65,$F7,$4F,$C7,$92,$45,$F5,$CF,$76,$24,$14,$35,$54,$D0,$B4,$54,$56,$59
  Data.b $0C,$D4,$C5,$43,$51,$19,$F2,$F9,$24,$94,$B5,$DA,$59,$3D,$56,$5D,$FE,$59,$55,$DE
  Data.b $B4,$54,$93,$50,$B6,$36,$C5,$17,$7A,$E5,$4D,$42,$39,$92,$94,$77,$4B,$45,$B7,$5C
  Data.b $5E,$24,$79,$EC,$5E,$D9,$A1,$C5,$4F,$42,$E7,$21,$D0,$19,$93,$50,$5E,$20,$7E,$56
  Data.b $9A,$45,$11,$D9,$F1,$A1,$56,$3F,$FE,$F9,$64,$F1,$D9,$53,$15,$B6,$15,$8D,$C6,$59
  Data.b $24,$14,$DE,$24,$14,$CD,$DC,$79,$2D,$54,$AB,$54,$56,$8B,$F1,$80,$5C,$F1,$7E,$9E
  Data.b $FF,$66,$C5,$41,$F1,$D1,$93,$50,$FE,$21,$C6,$15,$E1,$E5,$9F,$EF,$45,$1B,$15,$1F
  Data.b $09,$65,$6C,$9C,$DD,$43,$71,$21,$59,$74,$52,$66,$11,$D9,$54,$4E,$42,$F1,$15,$F3
  Data.b $E5,$3C,$56,$B6,$54,$59,$57,$7C,$1C,$57,$24,$95,$55,$3D,$9F,$45,$6F,$14,$90,$1E
  Data.b $FF,$4A,$79,$93,$50,$7E,$71,$5C,$88,$7E,$A3,$5C,$71,$B3,$C5,$55,$5A,$F1,$6C,$59
  Data.b $C1,$52,$A5,$0E,$24,$05,$2B,$36,$CE,$63,$B7,$E3,$3A,$2B,$3C,$54,$3A,$3A,$8D,$F3
  Data.b $83,$F4,$EC,$90,$2C,$FE,$AD,$28,$20,$BB,$0E,$D2,$E3,$DB,$CA,$2A,$C2,$8B,$AB,$AC
  Data.b $76,$E8,$A4,$29,$AB,$50,$E8,$9A,$ED,$B2,$F2,$A2,$63,$E3,$83,$B6,$8E,$9A,$36,$7F
  Data.b $12,$CA,$3E,$48,$CF,$56,$3D,$8B,$22,$33,$B2,$12,$B7,$E8,$B8,$F3,$8B,$84,$9F,$84
  Data.b $F2,$D4,$AE,$AC,$20,$3D,$E0,$CB,$0A,$81,$7B,$24,$8B,$36,$12,$8A,$B2,$31,$A8,$4B
  Data.b $BF,$7C,$15,$48,$8B,$D9,$9D,$51,$96,$4C,$65,$45,$59,$D9,$3C,$55,$9E,$04,$51,$2F
  Data.b $59,$DE,$5A,$59,$B5,$50,$65,$7F,$C6,$7F,$B5,$55,$16,$9E,$71,$B3,$71,$FC,$55,$56
  Data.b $1B,$F6,$48,$16,$EF,$E6,$9D,$C5,$55,$76,$9E,$47,$C8,$1D,$05,$E9,$71,$81,$75,$39
  Data.b $09,$65,$2F,$59,$14,$29,$50,$16,$13,$45,$F6,$76,$45,$27,$74,$9B,$54,$F1,$76,$74
  Data.b $75,$56,$D9,$FA,$F1,$32,$E5,$6D,$D8,$47,$24,$94,$F7,$CF,$D9,$92,$7C,$7C,$7E,$59
  Data.b $CD,$D2,$05,$5D,$D1,$06,$D1,$48,$16,$FD,$5C,$51,$1C,$54,$87,$64,$F1,$2B,$9D,$D5
  Data.b $1B,$C7,$61,$17,$4F,$C9,$05,$62,$95,$9F,$59,$01,$F0,$47,$7D,$3E,$0E,$5F,$C4,$66
  Data.b $D4,$06,$D4,$F1,$8D,$5C,$CD,$C6,$59,$03,$56,$4D,$D4,$65,$BA,$46,$93,$50,$97,$0F
  Data.b $E9,$F9,$C3,$15,$15,$3F,$51,$5B,$65,$D5,$47,$31,$FA,$71,$56,$59,$09,$DA,$FF,$5C
  Data.b $56,$B9,$F1,$5A,$56,$56,$44,$67,$47,$42,$85,$5A,$17,$1F,$1E,$35,$09,$45,$4D,$42
  Data.b $F1,$93,$1F,$1D,$B6,$15,$C8,$9F,$95,$82,$3C,$1B,$67,$45,$73,$F1,$93,$50,$31,$09
  Data.b $E5,$F3,$D2,$45,$D5,$51,$15,$1B,$C7,$27,$15,$7D,$E6,$9D,$82,$1F,$15,$89,$0F,$E8
  Data.b $57,$3C,$E9,$65,$4B,$1C,$FE,$48,$96,$C7,$4B,$C5,$F9,$71,$1D,$FA,$C7,$4D,$67,$4D
  Data.b $42,$D1,$6B,$97,$A7,$44,$35,$A4,$47,$E5,$1F,$0F,$6D,$1D,$6B,$17,$F7,$A3,$B1,$57
  Data.b $51,$35,$59,$2D,$59,$BE,$96,$14,$DF,$CB,$D9,$21,$59,$5C,$93,$50,$94,$84,$E5,$A3
  Data.b $F1,$51,$55,$5E,$34,$D6,$C3,$97,$B7,$14,$FA,$24,$14,$37,$8A,$82,$AE,$14,$B2,$C2
  Data.b $B5,$CF,$E6,$A3,$BB,$A5,$8F,$E9,$A3,$C3,$E3,$E1,$EC,$E2,$E0,$8B,$17,$F6,$43,$A6
  Data.b $8B,$FF,$8C,$9F,$A5,$CA,$9B,$8D,$E3,$25,$A1,$E8,$6A,$8E,$36,$E9,$CA,$27,$8A,$26
  Data.b $A1,$F8,$B2,$AC,$1E,$FD,$6A,$D5,$8A,$43,$B2,$CA,$A3,$CE,$F8,$FC,$05,$EA,$6C,$FA
  Data.b $BC,$A6,$EF,$D9,$AA,$F8,$2B,$EF,$99,$CB,$9C,$E3,$4A,$B1,$F8,$79,$2A,$EE,$8A,$EB
  Data.b $8F,$BF,$BA,$A8,$78,$E9,$C5,$CA,$6E,$99,$BC,$49,$28,$8E,$E3,$AC,$16,$BC,$00,$AC
  Data.b $CA,$67,$AC,$4E,$FD,$B8,$AB,$A8,$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$E4,$8F,$9F,$CB,$A6,$AA,$BC,$2C,$3B,$48,$8F,$CE,$DE,$9B,$83
  Data.b $2E,$3F,$A8,$96,$F9,$8F,$2F,$1E,$96,$AB,$FF,$29,$CF,$C3,$CB,$27,$B2,$A3,$D8,$38
  Data.b $5E,$91,$AB,$6B,$AB,$FC,$2A,$3E,$82,$2A,$98,$CF,$83,$A8,$E2,$1A,$35,$AF,$2E,$2B
  Data.b $01,$AE,$60,$EA,$78,$7E,$F8,$22,$A1,$FC,$2A,$3B,$91,$FF,$AA,$B2,$7A,$B6,$A8,$8A
  Data.b $AA,$8F,$8B,$9C,$A2,$D6,$C5,$CF,$55,$96,$9A,$37,$C5,$67,$D7,$EB,$71,$39,$7F,$54
  Data.b $29,$95,$70,$65,$E5,$ED,$15,$AA,$C5,$71,$94,$7F,$C0,$95,$61,$5B,$F1,$69,$79,$E3
  Data.b $FC,$E7,$48,$96,$DD,$E2,$85,$D2,$15,$5D,$97,$EE,$55,$F9,$70,$DE,$08,$1D,$A1,$E6
  Data.b $D2,$21,$6F,$47,$B3,$23,$B3,$27,$E8,$2A,$32,$A6,$B2,$2A,$A8,$B8,$58,$CE,$8A,$FE
  Data.b $FC,$66,$9E,$C1,$3E,$DB,$B9,$7C,$5A,$2A,$1C,$BA,$A3,$2C,$2A,$7A,$EE,$EC,$E2,$7E
  Data.b $A0,$8E,$EE,$08,$C2,$AE,$55,$3A,$AF,$C8,$E3,$6B,$00,$3A,$93,$50,$31,$41,$AF,$55
  Data.b $0D,$40,$65,$CF,$C6,$D9,$71,$1E,$BB,$5D,$45,$42,$79,$B1,$C7,$DB,$59,$C7,$8A,$17
  Data.b $BF,$EF,$D4,$19,$5F,$5E,$45,$A7,$46,$5F,$F9,$15,$3F,$09,$17,$5F,$D1,$A1,$91,$F9
  Data.b $17,$DD,$2B,$9D,$8D,$D1,$AB,$3C,$48,$2F,$35,$8A,$6B,$A0,$B5,$AB,$1A,$40,$5E,$AB
  Data.b $8A,$FB,$1A,$9B,$FB,$38,$07,$2F,$F7,$3B,$B2,$AF,$B9,$F2,$3C,$8B,$F7,$E3,$2A,$B5
  Data.b $3E,$2E,$B3,$16,$FD,$B2,$C6,$F8,$B3,$25,$38,$9A,$84,$E2,$05,$AF,$AC,$8A,$1B,$9E
  Data.b $AB,$78,$2F,$0F,$90,$8A,$03,$3A,$FF,$9E,$24,$54,$4C,$AA,$79,$AE,$5E,$D4,$91,$9D
  Data.b $AF,$4F,$09,$71,$15,$F7,$17,$17,$09,$E5,$70,$67,$C5,$47,$C1,$D6,$D1,$D9,$D7,$2D
  Data.b $F5,$D1,$D9,$E1,$D1,$9D,$55,$D9,$19,$5C,$1B,$47,$85,$62,$F9,$B7,$94,$15,$25,$95
  Data.b $35,$66,$E3,$2F,$B3,$7C,$34,$E8,$CA,$8A,$CB,$27,$A1,$F8,$8F,$01,$63,$30,$AA,$F2
  Data.b $BB,$F5,$26,$3D,$DB,$D9,$F2,$68,$BD,$E8,$AE,$E2,$F7,$B9,$A9,$2A,$9B,$C6,$83,$E1
  Data.b $A8,$66,$BD,$BC,$64,$CE,$A4,$AB,$AC,$2A,$8D,$AF,$A2,$A3,$B8,$48,$28,$AB,$30,$AD
  Data.b $76,$A8,$17,$1D,$90,$5D,$D6,$15,$5F,$6F,$CC,$57,$71,$F2,$DE,$08,$9D,$BD,$BA,$67
  Data.b $DE,$7C,$59,$D4,$0F,$25,$65,$2F,$E7,$23,$50,$5E,$9A,$FE,$2F,$DB,$F1,$91,$1E,$1F
  Data.b $CA,$67,$1F,$6E,$79,$90,$5E,$70,$5E,$15,$94,$15,$B6,$77,$2E,$2C,$77,$24,$CC,$AB
  Data.b $78,$36,$43,$F4,$CB,$6A,$BC,$1E,$E8,$2B,$8A,$BB,$F1,$AE,$B0,$54,$60,$24,$2B,$36
  Data.b $8E,$1A,$12,$CA,$DB,$30,$BC,$00,$AA,$7C,$A9,$FC,$10,$EE,$AD,$FC,$A8,$68,$1B,$C9
  Data.b $BA,$E2,$DB,$B8,$44,$29,$B3,$AA,$29,$DF,$EF,$A3,$22,$48,$00,$2B,$61,$3F,$49,$42
  Data.b $E9,$6C,$45,$35,$47,$5F,$79,$57,$34,$03,$BC,$9D,$51,$CD,$79,$21,$D9,$57,$D3,$57
  Data.b $CC,$4A,$56,$4B,$66,$2B,$3D,$18,$93,$58,$83,$F9,$CA,$E6,$D9,$0D,$50,$D4,$46,$45
  Data.b $E8,$5D,$31,$60,$D4,$B4,$15,$4B,$71,$A6,$15,$9E,$7D,$C5,$80,$48,$84,$2E,$00,$00
  Data.b $00,$00
EndDataSection

Posted: Wed Aug 29, 2007 8:43 am
by gnozal
Very nice code, netmaestro.
But it may not work on some windows versions like NT4 because of msimg32.dll (if you add the DLL it works).

Posted: Wed Aug 29, 2007 10:12 am
by Fangbeast
Lovely example netmaestro. Minor bug. When I grab the right side border or the bottom right corner and resize, the top isn't redrawn properly, looks like a small chunk cut out of it under the close button.

Judging from what I read about on MSDN, it looks as if a resizegadget would have to be ownerdrawn as well if people wanted it coloured as it isn't actually a child of the statusbar from what I gather.

Hmm, would be nice to have extended gadget libraries and shapes in PB natively from talented people like yourself. I love your code:):)

Posted: Wed Aug 29, 2007 11:48 am
by eriansa
Firstly : Thanks a lot!
This is what I kept for just ownerdrawn borders.
The question is : is there a way NOT to use a Window Callback procedure?

Code: Select all

Global ghBorderBrush
hBorder=CreateImage(#PB_Any,1,1)
StartDrawing(ImageOutput(hBorder))
Box(0,0,1,1,RGB(59,68,73))
StopDrawing()
ghBorderBrush = CreatePatternBrush_(ImageID(hBorder)) 
Procedure WindowProc(hwnd,msg,wParam,lParam)  
  Result = #PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_NCPAINT, #WM_NCACTIVATE 
      GetWindowRect_(hwnd, wr.RECT) 
      new_w = wr\right - wr\left 
      new_h = wr\bottom - wr\top 
      hdc = GetWindowDC_(hwnd) 
      hrgn = CreateRectRgn_(-1,-1,new_w+1, new_h+1) 
      hrgn2 = CreateRectRgn_(4,4,new_w-4,new_h-4) 
      CombineRgn_(hrgn, hrgn, hrgn2, #RGN_XOR) 
      SelectClipRgn_(hdc, hrgn) 
      SelectObject_(hdc, ghBorderBrush) 
      Rectangle_(hdc,-1,-1,new_w+1, new_h+1)  
      deletedc_(hdc) 
      DeleteObject_(hrgn) 
      DeleteObject_(hrgn2) 
      Result = 0 

  EndSelect 
  ProcedureReturn Result 
EndProcedure 
WindowMask=#PB_Window_BorderLess|#WS_THICKFRAME|#WS_BORDER
OpenWindow(0,0,0,320,240,"Ownerdrawn Borders",WindowMask) 
SetWindowColor(0, RGB(180,180,180)) 
SetWindowCallback(@WindowProc()) 
SendMessage_(WindowID(0), #WM_NCPAINT, 0 ,0) 
Repeat 
  EventID=WaitWindowEvent()
Until EventID=#PB_Event_CloseWindow 
DeleteObject_(ghBorderBrush) 
End 
I could do it this way :

Code: Select all

  If EventID=#WM_PAINT
    beginpaint_(hwnd,@paintstruct.PAINTSTRUCT)
      GetWindowRect_(hwnd, wr.RECT)  
      new_w = wr\right - wr\left 
      new_h = wr\bottom - wr\top 
      hdc = GetWindowDC_(hwnd) 
      hrgn = CreateRectRgn_(-1,-1,new_w+1, new_h+1) 
      hrgn2 = CreateRectRgn_(4,4,new_w-4,new_h-4) 
      CombineRgn_(hrgn, hrgn, hrgn2, #RGN_XOR) 
      SelectClipRgn_(hdc, hrgn) 
      SelectObject_(hdc, ghBorderBrush) 
      Rectangle_(hdc,-1,-1,new_w+1, new_h+1)  
      deletedc_(hdc) 
      DeleteObject_(hrgn) 
      DeleteObject_(hrgn2)
    endpaint_(hwnd,@paintstruct.PAINTSTRUCT) 
  EndIf
But it flickers :oops:

Posted: Wed Aug 29, 2007 1:31 pm
by Henrik
Very cool netmaestro. :D
Thank you ...

@Fangbeast
i have to change the (y) in this line to 36 then it works for me.

Code: Select all

  Case #WM_NCPAINT, #WM_NCACTIVATE
      GetWindowRect_(hwnd, wr.RECT)
      new_w = wr\right - wr\left
      new_h = wr\bottom - wr\top
      hdc = GetWindowDC_(hwnd)
      hrgn = CreateRectRgn_(-1,-1,new_w+1, new_h+1)
      hrgn2 = CreateRectRgn_(4,30,new_w-4,new_h-4)  ;<---- This line
to

Code: Select all

      hrgn2 = CreateRectRgn_(4,36,new_w-4,new_h-4)  
Maybe it's not the right way to do it, but it works her.

Best Henrik.

Posted: Wed Aug 29, 2007 1:36 pm
by Fangbeast
Thanks Henrik, I will try it. Would never work fierce code like this by myself.

Posted: Wed Aug 29, 2007 4:35 pm
by Henrik
@Fangles
Would never work fierce code like this by myself.
lol me neither

what i mean by the right way is 'MAYBE' the caption and the border is system/user depend, skin and so, i really don't know ? netmaestro / Sparkie ... help !

But if it is then we are using a border style (SM_CYSIZEFRAME) because we created the window with '#PB_Window_SizeGadget'

so our caption would be = #SM_CYCAPTION + #SM_CYSIZEFRAME

Code: Select all

hrgn2 = CreateRectRgn_(4,GetSystemMetrics_(#SM_CYCAPTION)+GetSystemMetrics_(#SM_CYSIZEFRAME),new_w-4,new_h-4)
Anyway Thanks to netmaestro this code 8)

Best Henrik

Posted: Wed Aug 29, 2007 4:53 pm
by Ollivier
@netmaestro

Excellent work !

Posted: Wed Aug 29, 2007 5:25 pm
by netmaestro
@fangs: Thanks for pointing that out, I was coding on the fly and just hardcoded a caption height, I meant to come back to it and do it right but I forgot. The solution is to use GetSystemMetrics to find the height for the user's currently selected window style settings.

@eriansa: The reason a #WM_PAINT handler won't do is that it paints the client area and allows the system to keep painting the frame. This is fine if you make the window borderless because then the system has no frame to paint, but then you lose the ability to size. This is often done with skinned windows, as I'm sure you know. If you leave the borders on and try to draw your own borders it flickers because you are drawing on top of the frame that Windows is also drawing, so there's too many cooks spoiling the broth. A #WM_NCPAINT handler tells the system not to draw the border and so you've solved the flicker but then it won't draw the system menu either, which leaves you with some work to do if you want normal sysmenu buttons. Much of the code in my demo is devoted to just getting the Close button back.

Posted: Wed Aug 29, 2007 7:04 pm
by Henrik
Well netmaestro i have another one for you, a littel bug more. :twisted:

if you add at normal standart pb button like

Code: Select all

If CreateGadgetList(WindowID(0)) 
   ButtonGadget(0,5,5 ,50,25,"Test") 
EndIf
Then if you close the app it will chrash on the this line:

Code: Select all

 SelectObject_(buttondc, ImageID(gCloseButton_State))
with [Error] #Image object not initialized.

in the callback --> Case #WM_NCPAINT, #WM_NCACTIVATE



Best Henrik

Posted: Wed Aug 29, 2007 7:25 pm
by netmaestro
Fixed:

Caption height problem reported by fangbeast
Image initialized problem reported by Henrik

Code is updated in the post, thanks for the valuable input!

Posted: Wed Aug 29, 2007 8:52 pm
by Henrik
@netmaestro
Just one thing more
you need to do the same with

Code: Select all

   If IsImage(gWoodTexture)
Then it will worke with pb 4.00 and PB 4.10 Beta 2

Best Henrik

Posted: Thu Aug 30, 2007 11:29 am
by Shardik
gnozal wrote: But it may not work on some windows versions like NT4 because of msimg32.dll (if you add the DLL it works).
gnozal, I was not able to successfully run netmaestro's code under NT4. I downloaded msimg32.dll from www.dll-files.com and I copied a version (same length but different date) from my XP installation to NT4. In both cases I obtain the following error message after trying to register the dll with the command "regsvr32 msimg32.dll":
LoadLibrary("msimg32.dd") failed.
GetLastError returns 0x0000007f.
Running netmaestro's code I obtain the error message that the procedure entry point "GdiGradientFill" couldn't be located in "GDI32.dll". What further steps do I have to take?