Flickering During Textbox Resizing

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 927 Views - Last Post: 20 May 2019 - 04:21 PM Rate Topic: -----

#1 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Flickering During Textbox Resizing

Posted 19 May 2019 - 10:18 AM

Hi guys, someone is aware of some valid method to eliminate or diminish the flickering of a textbox inside a panel during the resizing of both.

I searched the web, but found nothing really valid and working.
Flickering in Textboxes or Richtextboxs by now is a persecution :nottalkingtoyou:/>/>

This post has been edited by Dreamfall: 19 May 2019 - 05:10 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Flickering During Textbox Resizing

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15113
  • View blog
  • Posts: 60,463
  • Joined: 12-June 08

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 10:59 AM

It's a long shot, as I don't know what your code is doing, but throwing these lines in the bottom of your form's 'new' constructor may help.

	        Me.SetStyle(ControlStyles.UserPaint, True)
	        Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
	        Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)

Was This Post Helpful? 0
  • +
  • -

#3 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 11:16 AM

You could stop your paint events from firing, but the results are undesirable. And without seen your code, its hard to say why its flickering. You should be careful not to set the sizing properties of your control more than once, as this can also cause "flicker".

The approach by Modi is not a long shot, its actually a practical answer and it will actually help your situation alot but its unlikely to reduce flicker permanently. This is one of the reasons WPF was created, to illuminate problems like this.

Since you're doing this in VB.Net, I suggest you look into ws_ex_composited for a permanent fix.
Was This Post Helpful? 0
  • +
  • -

#4 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 01:19 PM

I've already try yours solutions, I get an imperceptible decrease of flickering, nothing more.
I have to try to create a new Textbox control and replace it with the classic Windows.Forms.TextBox().
Was This Post Helpful? 0
  • +
  • -

#5 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 03:37 PM

Show me how you done this ::

I suggest you look into ws_ex_composited for a permanent fix.

I know you haven't done it, because if you did, you wouldn't still be complaining. Show me the API call you wrote?
Was This Post Helpful? 0
  • +
  • -

#6 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 04:04 PM

Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Const WS_EX_COMPOSITED As Integer = &H2000000
            Dim cp As CreateParams = MyBase.CreateParams
            If Not Me.DesignMode Then
                cp.ExStyle = (cp.ExStyle Or WS_EX_COMPOSITED)
            End If
            Return cp
        End Get
    End Property


:dozingoff:
Was This Post Helpful? 0
  • +
  • -

#7 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 05:35 PM

Grand and dandy so (more so code). You're the only one this isn't working for. Sorry, I can't reproduce the same problem, even when i add a massive background image to the forms background. You also seem to be having this problem since 2016. As I said earlier, you'd be best undertaking this project in WPF, as it is better for drawing, rendering and quicker in general, and while I do understand that's probably not something you wish to do, you will need to deal with the flickering on certain controls. Because not all controls will support double buffering anyway, which Is why i nudged you towards WPF earlier on. And there is really nothing else you can do about it.

If the API is not doing for you what it does for me; you will need to start looking at your own code for possible discrepancies. I'm not trying to be condescending either Dreamfall, but you need to understand there are hundreds of posts online with people who've gotten this working perfectly. I should also point out, if your computer is lacking resources, it will show a lot more flickering compared to faster computers as the performance of the UI will be hindered on slower PC's.

From what I can see in your screenshot, you seem to have multiple controls including some keyboard component inside a panel of some sort. With as many controls as you have, It is my assumption that the GUI has to redraw to much at once. And given the fact that winforms is so old, it was never really cut-out to be used as you're intending to use it.

I thought this might be evident to you, but if not, it may be your only solution to a fix - If not, you need to review your code for conflicts of interest or discrepancies.
The only other piece of advice I can give you, is to ensure that when your application is running, that you set some kinda flag to turn off aero glass. Otherwise you will also notice no difference. I believe aero glass came into play sometime between in windows vista. Try this MSDN function disabling DWM, it just may work if you haven't disabled aero, but keep note that disabling DWM will disable it throughout the desktop. Something I'd imagine your users of your application may not like.

This post has been edited by Sheepings: 19 May 2019 - 05:42 PM

Was This Post Helpful? 0
  • +
  • -

#8 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 06:30 PM

Have you disabled aero/DWM? Without that being disabled, the API you are using won't wqrk. Generally, whenever i ever had experienced any kind of flicker, the settings outlined in the second post worked for me. I have only once needed to use this api, and to do so requires aero to be disabled. Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15113
  • View blog
  • Posts: 60,463
  • Joined: 12-June 08

Re: Flickering During Textbox Resizing

Posted 19 May 2019 - 06:51 PM

@dreamfall - please do not edit your posts after folks have replied.
Was This Post Helpful? 1
  • +
  • -

#10 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 12:23 AM

View PostSheepings, on 19 May 2019 - 05:35 PM, said:

Grand and dandy so (more so code). You're the only one this isn't working for. Sorry, I can't reproduce the same problem, even when i add a massive background image to the forms background. You also seem to be having this problem since 2016. As I said earlier, you'd be best undertaking this project in WPF, as it is better for drawing, rendering and quicker in general, and while I do understand that's probably not something you wish to do, you will need to deal with the flickering on certain controls. Because not all controls will support double buffering anyway, which Is why i nudged you towards WPF earlier on. And there is really nothing else you can do about it.

If the API is not doing for you what it does for me; you will need to start looking at your own code for possible discrepancies. I'm not trying to be condescending either Dreamfall, but you need to understand there are hundreds of posts online with people who've gotten this working perfectly. I should also point out, if your computer is lacking resources, it will show a lot more flickering compared to faster computers as the performance of the UI will be hindered on slower PC's.

From what I can see in your screenshot, you seem to have multiple controls including some keyboard component inside a panel of some sort. With as many controls as you have, It is my assumption that the GUI has to redraw to much at once. And given the fact that winforms is so old, it was never really cut-out to be used as you're intending to use it.

I thought this might be evident to you, but if not, it may be your only solution to a fix - If not, you need to review your code for conflicts of interest or discrepancies.
The only other piece of advice I can give you, is to ensure that when your application is running, that you set some kinda flag to turn off aero glass. Otherwise you will also notice no difference. I believe aero glass came into play sometime between in windows vista. Try this MSDN function disabling DWM, it just may work if you haven't disabled aero, but keep note that disabling DWM will disable it throughout the desktop. Something I'd imagine your users of your application may not like.



View PostSheepings, on 19 May 2019 - 06:30 PM, said:

Have you disabled aero/DWM? Without that being disabled, the API you are using won't wqrk. Generally, whenever i ever had experienced any kind of flicker, the settings outlined in the second post worked for me. I have only once needed to use this api, and to do so requires aero to be disabled. Hope this helps.


I'm not the only one to have this problem since 2016, or from 2010, 2011, 12,13,14,15,16 etc until today, but millions of coders all over the world, who to date have not found a solution valid.
Your suggestions are solutions based on the camouflage of the problem, so as to work around it but not fix it, with solutions I already knew.
Furthermore, planning in WPF takes up too much time for this simple application, the computer with which I work on the project has all the possible and imaginary resources and even more, the "Blurbehind Parameters" has absolutely no influence on the problem, logically I have no intention of disabling the aero in other PCs for my application.

Quote

It is my assumption that the GUI has to redraw to much at once. And given the fact that winforms is so old, it was never really cut-out to be used as you're intending to use it.


I didn't understand this last advice, sorry.

BTW at the end of it all I found the solution on this project, replacing the TexBox with a Richtexbox, the latter certainly more suitable for the textbox, since I will have to color some parts of the text in the control to highlight them, that with the classic textbox not it was possible to do so, too bad not to have thought of it before.

Thanks to you and @modi123_1 to spend time.
Was This Post Helpful? 0
  • +
  • -

#11 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 07:23 AM

No need to quote whole posts, just quote the relevant snipped or hit reply at the bottom of the page.

You completely missed my point altogether. The API I first recommended you to look up, (ws_ex_composited) the code you acquired was originally taken from IronRazer who acquired it form SO, and it does not provide necessary information to get the flickering to stop.) As I was trying to point out, that the API I told you to use, does not fully work unless Aero is disabled!! I failed to include that in my first post.

The second thing I was pointing out later on; is that it is required to disable Aero for the API to take full effect, and that the likelihood of disabling Aero in your app would likely piss off some of your users who like the visual effects and other features that Aero provides. So if I wasn't clear the first time and now, you simply can't have your cake and eat it. Either you disable Aero to allow the API call to work effectively without Aeros interference, or else you need to move your App to WPF or simply use controls in your current app that support double buffering, and for those that don't support double buffering, accept and deal with the flickering on the controls being redrawn. By the way, RichTextBox does not support double buffering either.

Quote

I'm not the only one to have this problem since 2016, or from 2010, 2011, 12,13,14,15,16 etc until today, but millions of coders all over the world, who to date have not found a solution valid.
That's not what I said, so please don't put words in my mouth. What I said was; there are hundreds of people who have gotten this API to work for themselves. You're one of the many exceptions who haven't, mostly due to poor research. Most people who know the framework would know to disable Aero because of the visual effects introduced in Microsoft Windows 2008 server edition and Vista cause problems for the recommended API to function affectively.

Quote

Your suggestions are solutions based on the camouflage of the problem, so as to work around it but not fix it, with solutions I already knew.
Oh really, you knew about the API? In 2016, you only found out about the API from a moderator here in this forum, and I've no doubt that moderator acquired that code from this post and shortened it for you. The problem with these posts is the lack of research gone into the topics answered back in 2016 and 2013 and beyond. So let me be clear. The public posts on the net covering the fact that Aero needs to be turned off are very very few. I've searched and looked for similar posts regarding my recommendation last night, and I only found one or two posts regarding it. It's my understanding; the people whom know Aero must be disabled, also know it because they know the framework relatively well. It's not common knowledge!

Only I was once in your position, I learned what worked for me and what I did to resolve the flickering on an app I did for a customer long ago. So if you knew about this hack/fix, why didn't you include it in this topic or your previous one? It is not exactly widely known that Aero explicitly does not implement or support WS_EX_COMPOSITED, so how can you expect the API to comprehensively work with Aero enabled? More-so, how could you know that and not have fixed it? LOL

Jes, if you knew that, you wouldn't be bitching about having to change from TextBox to RichTextBox. Neither of them support double buffering, so switching controls isn't going to help you, even though you said it did. The same way as it didn't help you back in 2016 when you first posted about the same flickering issue, yet here you are again.....

Quote

I didn't understand this last advice, sorry.
It's rather simple. Your application has to much stuff to draw, and so when you resize something, all of the child controls resize with it and need to be redrawn. When most of the controls redraw simultaneously, it created the scaling effect you call flicker.
Was This Post Helpful? 0
  • +
  • -

#12 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 11:34 AM

You're going out of the way, I've already told you that I wouldn't have disabled AERO even if it would have worked, so the advice of the WS_EX_COMPOSITED and its implementation for me wouldn't have given any valid solution in my situation. Uselessly you are turning around to topics that I already know to convince you of your skill and your experience as a maestro..Mahh. :online2long:/>/>

Why should I be ashamed for using a Richtexbox instead of a textbox, I solved the problem by myself, if you don't believe it I can post a new GIF with the slide opening and closing in the absence of flickering.
Indeed explain to me why you who are so good and so much more experience than me, if both do not support the "double buffering" I solved the problem.

View PostSheepings, on 20 May 2019 - 07:23 AM, said:

Quote

I didn't understand this last advice, sorry.
It's rather simple. Your application has to much stuff to draw, and so when you resize something, all of the child controls resize with it and need to be redrawn. When most of the controls redraw simultaneously, it created the scaling effect you call flicker.


I tested the timed slide test in a new empty form with 2 buttons and 1 panel and the Textbox, the same problem and the same flicker.

I leave you to imagine that the opening and closing of the "Virtual Keyboard" contains 105 Keys "CheckBoxes" and other 105 images in the CBs, without any flicker in any control. :wink:/>
Was This Post Helpful? 0
  • +
  • -

#13 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 01:07 PM

Dreamfall You are the one who said you knew all of the solutions and tried them.

I don't see anywhere you implemented the DWM function, and yet if you knew using the DWM function was a required preference of the API, you would have said this approach was not usable from the get-go.

You seem complacent towards me for the well written explanation that I provided you with. It's Ok to not know something, ya know. I don't claim to be anything; of all things a maestro. I am where I am because of the code that I thought myself to write through the various languages I learned over the years. I write my own code and don't ask for help on any forum, and just because I know what I am doing (most of the time), does not make me a any kind of genius, as I am human and sometimes can still make little mistakes, and when I make a mistake, I'll put my hand up. I read a lot so not to be a person who makes many mistakes. And I won't apologise because you feel insignificant because of my own education or how i verse my responses to you.

And where did I say that you should be ashamed for using RichTexBox over a TextBox? Let me show you what I said, shall I ::

Quote

Jes, if you knew that, you wouldn't be bitching about having to change from TextBox to RichTextBox. Neither of them support double buffering, so switching controls isn't going to help you, even though you said it did. The same way as it didn't help you back in 2016 when you first posted about the same flickering issue, yet here you are again.....


Two years later you're claiming that switching controls (again) worked for you when said controls are constructed in the framework almost exactly the same way as each other minus some minor bits and pieces and extensive events.

Quote

Indeed explain to me why you who are so good and so much more experience than me,
Hot dam kid, you're on a roll today with the accusations. Once more, you are putting words in my mouth, and saying that I said something which can clearly be read that I did not.

What I did do; is prove that you are talking out of your ass and you didn't know WS_EX_COMPOSITED is not supported with Aero enabled. If you did, you would have tried it or said that the API method was no good to you because you would have known this information already, and known that you didn't want Aero disabled which is a required preference for the API I gave you to work correctly.

Quote

I leave you to imagine that the opening and closing of the "Virtual Keyboard" contains 105 Keys

Once more I didn't say that, but what I was alluding to was the fact that it was probably a heavy weight component, and the more detail on your UI is still required to be redrawn when your form scales from resizing.

Since you are getting rather brisk with your arguments, I'm done helping you both here and in future. And if you don't like my responses, I suggest you report them to the moderators for review or better yes PM one of them. Unsubed.

Good luck.
Was This Post Helpful? 0
  • +
  • -

#14 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 01:34 PM

View PostSheepings, on 20 May 2019 - 01:07 PM, said:

Dreamfall You are the one who said you knew all of the solutions and tried them.


In fact, I tried them all and they don't work, disable the AERO and make the WS_EX_COMPOSITED work, it's not a valid solution.
In fact I am here for a similar question made in 2016, because since 2016 to date, there has been no really working solution that solved the problem.
I haven't posted any code help, in fact I don't need it, the post was opened to know and ask if someone knew a new solution to fix the problem. But as I have seen since 2016, there has been no step forward.

in any case let's end it here with useless speeches from wise guy, which I don't read anywhere.
And when would you have helped me ?? I mean the question I asked you about why with the terxtbox I flickering and with the richtexbox no, you haven't answered me yet.

good luck to you too. :wink:/>/>

This post has been edited by Dreamfall: 20 May 2019 - 01:50 PM

Was This Post Helpful? 0
  • +
  • -

#15 Dreamfall   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 26-January 15

Re: Flickering During Textbox Resizing

Posted 20 May 2019 - 03:56 PM

@Sheepings...For what reason you lower the reputations, because you feel inferior to someone, or because you have not been able to give an answer to the problem, it was enough to confirm that there was no solution, as indeed it is. You just filled the thread with useless polemics of child expert that you're not.
I could lower your reputations, too, but I don't, I don't lower myself to the same level as an immature child. I see people like you in this forum as superficial and useless.

This post has been edited by Dreamfall: 20 May 2019 - 04:00 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2