Flicker/Refresh Problem

I’m never sure which DataTypes to use… and looking at your great list: Windows APIs to Xojo data type conversion

Leads me to ask: is this (copied from above in this thread) correct?

Soft Declare Function SendMessageW Lib "User32" ( hwnd as Integer, msg as Integer, wParam as Integer, lParam as Integer ) as Integer

Does this work for both 32Bit and 64Bit builds?
Or should it be:

Declare Sub SendMessage Lib "User32.dll" Alias "SendMessageW" (hWnd as Integer, msg as UInt32, wParam as UInteger, lParam as Integer)

Ah, that shows I didnt write it. For example, msg as UInt32 doesn’t change in size depending on the target platform so we use UInt32 there instead of UInteger. The following is correct for 32bit & 64bit:

[code]Private Function SendMessage(hwnd as Integer, msg as Integer, wParam as Integer, lParam as Integer) as Integer
#if TargetWin32

if System.IsFunctionAvailable( "SendMessageW", "User32" ) then
  Soft Declare Function SendMessageW Lib "User32" ( hwnd as Integer, msg as UInt32, wParam as UInteger, lParam as Integer ) as Integer
  return SendMessageW( hwnd, msg, wParam, lParam )
else
  Soft Declare Function SendMessageA Lib "User32" ( hwnd as Integer, msg as UInt32, wParam as UInteger, lParam as Integer ) as Integer
  return SendMessageA( hwnd, msg, wParam, lParam )
end if

#else

#pragma unused hwnd
#pragma unused msg
#pragma unused wParam
#pragma unused lParam

#endif
End Function
[/code]

Remember that you will need to call a single Window.Refresh() after this is complete to actually have the window paint.

Jon,

I’ve learned a fair bit over the last week and I’ve had another look at your flicker problem. I’ve fixed it with just two declares.

Dim style As Integer = me.GetWindowLong(GWL_STYLE) Call SetWindowLong(me.handle, GWL_STYLE, BitSet(style, WS_CLIPCHILDREN))

You can leave the combo box as a child of the listbox, all the code I’ve put in is inside the ListBox.Open

It simply is not redrawing the child controls when a refresh happens in the listbox, which stops the flicker of the combo boxes as they were being redrawn along with the listbox originally.

https://www.dropbox.com/s/tmndxl2kkkuwa2e/ListboxTestEasyFix.zip?dl=1

You don’t need to worry about the ZOrderFix call either now (more on that coming soon).

If you would be so kind as to have a look and a test and let me know how it turns out for you?

Thanks

@JulianS - You get my “Dog with a bone” award for 2017. Your efforts in this area are greatly appreciated. Thank you :slight_smile:

What would the Linux equivalent of the ‘freeze’ and ‘unfreeze’ methods form above be? I’m looking for a way to keep certain window contents from redrawing automatically for short periods of time.