Page 1 of 1

StringGadget graphical bug on 4 in width

Posted: Mon Jun 19, 2017 11:56 am
by oakvalley
Hi,

Using PB5.60 (x86)

Code: Select all

OpenWindow(0,0,0,500,200,"bug width")
StringGadget(0,10,10,1,100,"")
StringGadget(1,100,10,2,100,"")
StringGadget(2,200,10,3,100,"")
StringGadget(3,300,10,4,100,"") ; this one adds a vertical white area?! Looks like a flag.
StringGadget(4,400,10,5,100,"")
Repeat
  event=WaitWindowEvent()
Until GetAsyncKeyState_($1b)

When width=4, there is a strange graphical bug that shows a vertical sized white bar. All the other width looks fine.

__________________________________________________
Code tags added
03.07.2017
RSBasic

Re: StringGadget graphical bug on 4 in width

Posted: Thu Jun 22, 2017 7:34 pm
by Fred
Probably a windows issue, we don't do anything fancy for the stringgadget rendering

Re: StringGadget graphical bug on 4 in width

Posted: Thu Jun 22, 2017 10:14 pm
by luis
Uhm... something is not right.

The client areas of the edit controls (the API controls wrapped by StringGadget) in the program in the first post are:

1) 1x100
2) 2x100
3) 3x100
4) 0x96 (!!!)
5) 1x96 (???)

Note you can't even click in the 4th stringgadget, because there is no client area available.

Using an API only program using some edit controls directly, the client areas are

1) 1x100
2) 2x100
3) 3x100
4) 4x100
5) 5x100

as expected.

Code: Select all

Global hBrush = CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))

; window procedure

Procedure WinProc (hWnd, Msg, wParam, lParam)
 Select Msg
    Case #WM_CLOSE
        DestroyWindow_(hWnd)     
    Case #WM_NCDESTROY
        DeleteObject_(hBrush)
        PostQuitMessage_(0)
        ProcedureReturn 0     
 EndSelect
 ProcedureReturn DefWindowProc_(hWnd, Msg, wParam, lParam)
EndProcedure

; window class

Classname$ = "MyApiWindow"

With wClass.WNDCLASSEX
    \cbsize  = SizeOf(WNDCLASSEX)
    \lpfnWndProc  = @WinProc()
    \hCursor  = LoadCursor_(0, #IDC_ARROW)
    \hbrBackground  = hBrush
    \lpszClassName  = @classname$
EndWith

RegisterClassEx_(@wClass)

; create window and process messages

WinStyle = #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN
WinStyle | #WS_CAPTION | #WS_SYSMENU | #WS_MINIMIZEBOX
WinStyle | #WS_MAXIMIZEBOX | #WS_SIZEBOX

hWnd = CreateWindowEx_(0, Classname$, "bug width", WinStyle, 100, 100, 500, 200, 0, 0, 0, 0)

CreateWindowEx_(0, "EDIT", "", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP, 10, 10, 1, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(0, "EDIT", "", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP, 100, 10, 2, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(0, "EDIT", "", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP, 200, 10, 3, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(0, "EDIT", "", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP, 300, 10, 4, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(0, "EDIT", "", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP, 400, 10, 5, 100, hwnd, 0, 0 ,0)

ShowWindow_(hWnd,  #SW_SHOW)

While GetMessage_(msg.MSG, 0, 0, 0 )
    TranslateMessage_(msg)
    DispatchMessage_(msg)
Wend

UnregisterClass_(Classname$, GetModuleHandle_(#Null))
This is what I get on Win 7

PB window

Image

API window

Image

Re: StringGadget graphical bug on 4 in width

Posted: Thu Jun 22, 2017 11:55 pm
by luis
I made some further experiments.
Looks like my first test was not good enough or if you prefer I was wrong. :lol:
Using a win spying utility I was able to replicate all the styles used by the PB program and looks like it's not a PB bug.

Code: Select all

Global hBrush = CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))

; window procedure

Procedure WinProc (hWnd, Msg, wParam, lParam)
 Select Msg
    Case #WM_CLOSE
        DestroyWindow_(hWnd)     
    Case #WM_NCDESTROY
        DeleteObject_(hBrush)
        PostQuitMessage_(0)
        ProcedureReturn 0     
 EndSelect 
 ProcedureReturn DefWindowProc_(hWnd, Msg, wParam, lParam)
EndProcedure

; window class

Classname$ = "MyApiWindow"

With wClass.WNDCLASSEX
    \cbsize  = SizeOf(WNDCLASSEX)
    \lpfnWndProc  = @WinProc()
    \hCursor  = LoadCursor_(0, #IDC_ARROW)
    \hbrBackground  = hBrush
    \lpszClassName  = @classname$
EndWith

RegisterClassEx_(@wClass)

; create window and process messages

WinStyle = #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN
WinStyle | #WS_CAPTION | #WS_SYSMENU | #WS_MINIMIZEBOX 
WinStyle | #WS_MAXIMIZEBOX | #WS_SIZEBOX

hWnd = CreateWindowEx_(0, Classname$, "bug width", WinStyle, 100, 100, 500, 200, 0, 0, 0, 0)

EditStyle = #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_GROUP | #WS_TABSTOP

EditStyleEx = #WS_EX_LEFT | #WS_EX_LTRREADING | #WS_EX_RIGHTSCROLLBAR

;EditStyleEx = #WS_EX_CLIENTEDGE | #WS_EX_LEFT | #WS_EX_LTRREADING | #WS_EX_RIGHTSCROLLBAR


CreateWindowEx_(EditStyleEx, "EDIT", "", EditStyle , 10, 10, 1, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(EditStyleEx, "EDIT", "", EditStyle , 100, 10, 2, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(EditStyleEx, "EDIT", "", EditStyle , 200, 10, 3, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(EditStyleEx, "EDIT", "", EditStyle , 300, 10, 4, 100, hwnd, 0, 0 ,0)
CreateWindowEx_(EditStyleEx, "EDIT", "", EditStyle , 400, 10, 5, 100, hwnd, 0, 0 ,0)


ShowWindow_(hWnd,  #SW_SHOW)

While GetMessage_(msg.MSG, 0, 0, 0 )
    TranslateMessage_(msg)
    DispatchMessage_(msg)
Wend

UnregisterClass_(Classname$, GetModuleHandle_(#Null))

Run it as it is, and there is no bug.

But comment out the second version of the extended style, the one using #WS_EX_CLIENTEDGE and the "bug" it's there in the API version too.

So is it a problem due to the fact that using #WS_EX_CLIENTEDGE the sunken effect mess with client area ?

Re: StringGadget graphical bug on 4 in width

Posted: Fri Jun 23, 2017 12:00 am
by luis
It's definitively the style.

Code: Select all


OpenWindow(0,0,0,500,200,"bug width")
StringGadget(0,10,10,1,100,"",  #PB_String_BorderLess)
StringGadget(1,100,10,2,100,"",  #PB_String_BorderLess)
StringGadget(2,200,10,3,100,"",  #PB_String_BorderLess)
StringGadget(3,300,10,4,100,"",  #PB_String_BorderLess)
StringGadget(4,400,10,5,100,"",  #PB_String_BorderLess)
Repeat
event=WaitWindowEvent()
Until event = #PB_Event_CloseWindow

Removing the border, and so the sunken border effect, the "bug" it's not there even in the PB version.

:shock:

Re: StringGadget graphical bug on 4 in width

Posted: Fri Jun 23, 2017 11:26 am
by oakvalley
Heh, thanks for investigating. Problem is that when border is removed, I loose that 3d Bevel effect splitter line i was looking for :-)

I had to use 5 in value instead of 4 to get my 3d bevel splitter-ish line. For those who want to create a white flag style automatically for free without any additional code, they could use value 4, haha.

So, who's to blame, Bill Gates?

I'm running Windows 7, 64bit here.

Re: StringGadget graphical bug on 4 in width

Posted: Tue Jul 11, 2017 1:45 pm
by Fred
yes, seems like a Windows issue