ReadOnly Property

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 am

ReadOnly Property

Post by nirmalks »

I get below error messages when using DoubleBuffered, UserPaint and other properties to reduce flickering:

ERROR: 'UserPaint' is a ReadOnly property.
Final10.psf (258, 2): ERROR: At Line: 258 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::UserPaint = $true
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:
ERROR: 'AllPaintingInWmPaint' is a ReadOnly property.
Final10.psf (259, 2): ERROR: At Line: 259 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::AllPaintingInWmPaint = ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:
ERROR: 'OptimizedDoubleBuffer' is a ReadOnly property.
Final10.psf (260, 2): ERROR: At Line: 260 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::OptimizedDoubleBuffer = ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:

How do I enable these properties?

Appreciate your help!

Thanks,
Nirmal
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ReadOnly Property

Post by jvierra »

You cannot set the value of an enum.
thins like this - [System.Windows.Forms.ControlStyles]::UserPaint are static properties

Why are you trying to change these?
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 am

Re: ReadOnly Property

Post by nirmalks »

Thanks for your reply!

All I'm trying to do is avoid flickering for Winform and it's controls.

Thanks,
Nirmal
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ReadOnly Property

Post by jvierra »

Set the form properties not the Enum.
What is it you are trying to set and where did you get this information from?
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 am

Re: ReadOnly Property

Post by nirmalks »

How do I set the same set of properties for a Form and its controls.

Well, my idea is to reduce the flickering. I've been reading through some posts at Stackoverflow and MSDN to reduce flickering and this is what I've got, but I'm not sure as to how I make use of them in PowerShell studio.

https://social.msdn.microsoft.com/Forum ... m=winforms

Thanks,
Nirmal
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ReadOnly Property

Post by jvierra »

That article has nothing to do with what you are assigning. You need to tell us what you are trying to do or fix.

The article is about the property "DoubleBuffered". This is a stable property. The rest of what you are doing has little to do with this setting or the article you have referenced.

My best guess is this: https://msdn.microsoft.com/en-us/librar ... .110).aspx

Of course this is only useful if you are managing your own paint events. It is useless for normal operations.

If you are using complex graphics image rendering or doing high speed drawing this can reduce display issues. You can set those properties (DoubleBuffered,OptimizedDoubleBuffer) and see if it helps.
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 am

Re: ReadOnly Property

Post by nirmalks »

I can't find those properties (OptimizedDoubleBuffer and other props) on Form variable.

IntelliSense doesn't give me those properties on Form. So how do I set?

OR can you please suggest a few lines of code that I could use to reduce overall flickering for all controls on a form?

Thank you very much
Nirmal
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ReadOnly Property

Post by jvierra »

In PowerShell Studio look on the form properties It is there.
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 am

Re: ReadOnly Property

Post by nirmalks »

You know what - It is there!! but I don't see when navigating properties through IntelliSense.

Thank you for all your help!
Nirmal
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ReadOnly Property

Post by jvierra »

The issue with PowerShell is that it only allows for dialogs and dialogs cannot be DoubleBuffered.
This topic is 8 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked