Page 1 of 1
MDI Child Window Flicker in PB 5.11
Posted: Tue Mar 19, 2013 10:22 pm
by CalamityJames
In the program below, if you change the size of the child window using either the right or bottom edge there is great deal of flickering on my Windows XP system with PB 5.11 (but not 5.10).
Code: Select all
#Main = 0
#MDIChild = 1
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
If CreateMenu(#Main, WindowID(#Main))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
AddGadgetItem(0, #MDIChild, "child window")
; add gadgets here...
UseGadgetList(WindowID(#Main)) ; go back to the main window gadgetlist
EndIf
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
In a rather more sophisticated program where I intercept the WM_Paint and WM_Erasebackground messages I now find that the window does not draw itself properly and even disappears unexpectedly in 5.11. This program worked perfectly in 5.10. I assume these two issues are connected. Even in the simple program I think the flckering is unacceptable.
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 12:05 am
by IdeasVacuum
Confirmed.
Just tested the above code with PB5.10 and then PB5.11(Final Release) on WinXP SP3.
Stark difference between the two, a lot of flicker in PB5.11

Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 1:15 am
by Thunder93
Same results here too.
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 1:25 am
by Shield
I also get flickers on Windows 7 and 8. SmartWindowRefresh doesn't help at all.
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 1:27 am
by Thunder93
That is what I tried too.
Shield wrote:I also get flickers on Windows 7 and 8. SmartWindowRefresh doesn't help at all.
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 5:35 pm
by Fred
It's because of this fix:
http://www.purebasic.fr/english/viewtop ... =4&t=53898 . We used WS_CLIPCHILDREN on subwindow creation, but it could lead to artifact so it has been removed, hence the flickering (which is a shame on Windows anyway, if you don't use a third party doublebuffer GUI toolkit). You can still try to re-enable it for your MDI window with SetWindowLong_() if you want.
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 6:45 pm
by codeprof
this has no flickering, but redraw bugs at the border if you move the inner window.
Code: Select all
#Main = 0
#MDIChild = 1
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
If CreateMenu(#Main, WindowID(#Main))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
SetWindowLong_(GadgetID(0), #GWL_EXSTYLE, #WS_EX_COMPOSITED)
AddGadgetItem(0, #MDIChild, "child window")
; add gadgets here...
UseGadgetList(WindowID(#Main)) ; go back to the main window gadgetlist
EndIf
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 7:09 pm
by ts-soft
Code: Select all
Procedure SetClip(hWnd, state = #False)
Protected Style = GetWindowLongPtr_(hWnd, #GWL_STYLE)
SetWindowLongPtr_(hWnd,#GWL_STYLE, style | #WS_CLIPCHILDREN )
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
If state
Style = GetWindowLongPtr_(hWnd,#GWL_EXSTYLE)
SetWindowLongPtr_(hWnd, #GWL_EXSTYLE, style | #WS_EX_COMPOSITED)
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)
EndIf
EndProcedure
#Main = 0
#MDIChild = 1
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
If CreateMenu(#Main, WindowID(#Main))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
SetClip(GadgetID(0))
AddGadgetItem(0, #MDIChild, "child window")
; add gadgets here...
UseGadgetList(WindowID(#Main)) ; go back to the main window gadgetlist
EndIf
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 7:14 pm
by Thunder93
Any reason why someone shouldn't do it like I have it? Besides the scenario Fred said?
Code: Select all
#Main = 0
#MDIChild = 1
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
If CreateMenu(#Main, WindowID(#Main))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
AddGadgetItem(0, #MDIChild, "child window")
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE)|#WS_CLIPCHILDREN) ; <---- Added
; add gadgets here...
UseGadgetList(WindowID(#Main)) ; go back to the main window gadgetlist
EndIf
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 8:04 pm
by codeprof
A soultion for the problem with the Tooltip could be to modify the Callback funtion of the StringGadget if it is inside a Mdi-Window (As the problem seems to be the Tooltip and not the Mdi-Window itself).
The window could be forced to be redrawn if a Tooltip windows was closed...
Code: Select all
Global oldCB
Procedure WinCallback(hWnd, uMsg, WParam, *LParam.NMHDR)
If uMsg = #WM_NOTIFY
If *lParam\code = #TTN_POP ; A Popup window was closed
If GetProp_(hWnd, "MDIWINDOW") <> 0 ; If StringGadget is in a MDI-Window...
RedrawWindow_(GetProp_(hWnd, "MDIWINDOW"), #Null, #Null, #RDW_INVALIDATE | #RDW_ERASE | #RDW_FRAME)
EndIf
EndIf
EndIf
ProcedureReturn CallFunctionFast(oldCB, hWnd,uMsg, WParam, *lParam)
EndProcedure
Define.i Wd, Sw, Md, Ev, Fi
Wd = OpenWindow(#PB_Any, 0, 0, 600, 400, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If Not Wd = 0
SetWindowColor(Wd, RGB(255, 255, 255))
If CreateMenu(#PB_Any, WindowID(Wd))
OpenSubMenu("Window")
Md = MDIGadget(#PB_Any, 0, 0, 400, 300, 0, 0, #PB_MDI_AutoSize)
SetWindowLong_(GadgetID(Md), #GWL_STYLE, GetWindowLong_(GadgetID(md), #GWL_STYLE)|#WS_CLIPCHILDREN) ; <---- Added
If Not Md = 0
Sw = AddGadgetItem(Md, #PB_Any, "MDI-Test")
;Avoid Flickering inside the window
SetWindowLong_(WindowID(Sw), #GWL_STYLE, GetWindowLong_(WindowID(Sw), #GWL_STYLE)|#WS_CLIPCHILDREN) ; <---- Added
If Not Sw = 0
ResizeWindow(Sw, #PB_Ignore, #PB_Ignore, 400, 300)
SetWindowColor(Sw, RGB(255, 100, 100))
sg = StringGadget(#PB_Any, 20, 20, 100, 25, "", #PB_String_Numeric)
oldCB = SetWindowLong_(GadgetID(sg), #GWL_WNDPROC, @WinCallback()) ; <---- Added
SetProp_(GadgetID(sg), "MDIWINDOW", WindowID(Sw)) ; <---- Added
TextGadget(#PB_Any, 20, 45, 300, 25, "Please enter non-numeric values above!")
Repeat
Test = WaitWindowEvent(5000)
Select Test
Case #PB_Event_CloseWindow: Fi = 1
EndSelect
Until Fi = 1
EndIf
EndIf
EndIf
EndIf
End
Re: MDI Child Window Flicker in PB 5.11
Posted: Wed Mar 20, 2013 8:27 pm
by Thunder93
Good solution codeprof!
