ListBox Owner Draw Flicker on Resize

N

nak

Hi there,

I have an owner drawn listbox that works fine and without flicker except
when it is resized. The only examples I've come across for double buffering
require painting the entire control within the OnPaint event, of course this
isn't how I would like to draw the control as it negates the purpose of it
being owner drawn and I may as well just create the control from scratch.

I've also seen potential fixes involving the EnableVisualStyles property
but this does not work for me. Has anyone got any wizzy tips for curing
this resize flicker? Thanks a million in advance.

Nick.
 
E

Earlybite

nak said:
Hi there,

I have an owner drawn listbox that works fine and without flicker
except when it is resized. The only examples I've come across for double
buffering require painting the entire control within the OnPaint event, of
course this isn't how I would like to draw the control as it negates the
purpose of it being owner drawn and I may as well just create the control
from scratch.

I've also seen potential fixes involving the EnableVisualStyles
property but this does not work for me. Has anyone got any wizzy tips for
curing this resize flicker? Thanks a million in advance.

Nick.

Hi!
You can use SendMessage and a constant for Autoredraw.
First false. Then true. Then refresh.

Earlybite
 
N

nak

Hi Earlybite,
Hi!
You can use SendMessage and a constant for Autoredraw.

Would this be the same as the ResizeRedraw property? If so I have tried
using that and it still does not work.

Nick.
 
E

Earlybite

nak said:
Hi Earlybite,


Would this be the same as the ResizeRedraw property? If so I have
tried using that and it still does not work.

Nick.

Hi!
?ResizeRedraw? Don't know!
SendMessage is a API-Call and with autoredraw to false it stops every
redraw,
so you have to refresh form and so on.

Private Const WM_SETREDRAW = &HB
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

Call SendMessage(hWnd, WM_SETREDRAW, 0&, 0&) ' Set to false
Resize or replace with your code
Call SendMessage(hWnd, WM_SETREDRAW, 1&, 0&) ' Set to true
Refresh ' You have to try. [It can be you have to refresh all controls :-( ]

This will work (also with very big sized controls)
greetings
Earlybite
 
N

nak

Hi Earlybite,
Hi!
?ResizeRedraw? Don't know!
SendMessage is a API-Call and with autoredraw to false it stops every
redraw,
so you have to refresh form and so on.

Private Const WM_SETREDRAW = &HB
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

Call SendMessage(hWnd, WM_SETREDRAW, 0&, 0&) ' Set to false
Resize or replace with your code
Call SendMessage(hWnd, WM_SETREDRAW, 1&, 0&) ' Set to true
Refresh ' You have to try. [It can be you have to refresh all controls
:-( ]

This will work (also with very big sized controls)
greetings
Earlybite

I'm not convinced that this is going to help me to be honest, I don't
want to prevent redraws, I want to prevent a flicker during resize, stopping
it from redrawing completely will just mean that the control will look very
bad while resizing. I just tried it and it stops redraw completely until
enabled again, definitely not what I want to do.

I think the problem is caused by the underlying listbox itself clearing
the buffering during a resize, if it is actually double buffered, it's very
poorly double buffered, I have controls that I double buffer myself and get
no flicker at all so not quite sure what's going on underneath. It would be
cool if I could handle the double buffering myself along with Owner Drawn
but I can't see any examples of doing so.

Nick.
 
A

Armin Zingler

Earlybite said:
Private Const WM_SETREDRAW = &HB
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

If you want it platform independent:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As intptr, ByVal wMsg As uinteger, ByVal wParam As intptr,
byval lParam As intptr) As intptr


Armin
 
A

Armin Zingler

Armin said:
If you want it platform independent:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As intptr, ByVal wMsg As uinteger, ByVal wParam As intptr,
byval lParam As intptr) As intptr

or better

Private Declare AUTO Function SendMessage Lib "user32" (...)


Armin
 
T

Tom Shelton

If you want it platform independent:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As intptr, ByVal wMsg As uinteger, ByVal wParam As intptr,
byval lParam As intptr) As intptr


Armin

The use of Long as a type was wrong anyway :) Long is a 64-bit integer...
 
J

Jie Wang [MSFT]

Hello Nick,

You might already know it, but just a quick notice:

The managed support service of the newsgroup
microsoft.public.dotnet.languages.vb is now available instead on Visual
Basic General:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads. Would you
please repost the question in the forum with the Windows Live ID used to
access your Subscription benefits? Our engineers will assist you in the new
platform. The article
http://msdn.microsoft.com/en-us/subscriptions/aa974230.aspx introduces more
information about the migration. In the future, please post your
VB.NET-related questions directly to the forums. If you have any questions
or concerns, please feel free to contact us: (e-mail address removed).

Regards,
Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top