SetStyle Remotely

dannyres

Regular
Joined
Aug 29, 2003
Messages
67
Hi, does anyone know if it is possible using api or something to set double buffering and some other styles on a .net window in another program?




Dan
 
It's a protected method so works from anywhere within a derived class. You could probably use reflection to call it, too.
 
I doubt there's an easy way to setting the style on another program, even with reflection. What is it you need to do, anyway? Why do you need to set a style on another app?

In order to set the style, you will need to retrieve the Windows.Forms.Form object representation of the window, and as far as I know, there's no way to get a Form object out of an hWnd.
 
yeah basicly im trying to set the style of another application.
I know how to get the handle of the form but no idea about the object....:(



Dan
 
ok ive been thinking about this and how i would do it and i realized, i can get the forms object... let me explain a little more in depth what im trying todo.

I am making a component for a program called Dashboard.. kind of like the msn sidebar or the sidebar some of you may have seen in screenshots of longhorn. Anyway at the moment Dashboard keeps flashing, and so do the components. I fixed the flashing for my components by setting UserPaint, AllPaintinginWm and the DoubleBuffer styles. Now dashboard only flashes itself which is still anoying so i want to try and set those styles from a component.

I can get Dashboard's form object by using Me.Parent from my usercontrol.



Dan
 
So do something like this:
Visual Basic:
Dim parentForm As Form = DirectCast(Me.Parent, Form)

parentForm.SetStyle(blah)
 
That doesnt work :( i get this error:

'System.Windows.Forms.Control.Protected Sub SetStyle(flag As System.Windows.Forms.ControlStyles, value As Boolean)' is not accessible in this context because it is 'Protected'.

Looks like its not going to work this way?


Dan

EDIT: what does DirectCast do?
 
Back
Top