HighTechTalks DotNet Forums  

Invalidate Desktop with C#

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Invalidate Desktop with C# in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Invalidate Desktop with C# - 09-22-2005 , 01:56 AM






Hi together,

I have a "sliding" form on my desktop which can be expanded or
collapsed in a sliding manner. So my problem is, that if the form is
collapsing, I want to refresh or invalidate that region on the desktop.

I already tried it with something like this:

-----> snip

[DllImport("user32.dll", SetLastError = true)]
public static extern bool InvalidateRect(
IntPtr hWnd,
ref Rectangle lpRect,
bool bErase);

[DllImport("user32.dll")]
public extern static IntPtr GetDesktopWindow();

// just a rectangle on the whole screen for testing
Rectangle invalidateRect = new Rectangle(0,0,1280,1024);

InvalidateRect(GetDesktopWindow(), ref invalidateRect, true);


----> snap

So InvalidateRect returns with true, but the desktop isn't refreshed.
It's really confusing and I spent a long time - but I can't it getting
work.

What can I do to refresh a rectangle on the desktop???


Kind regards
Franz


Reply With Quote
  #2  
Old   
Frank Hileman
 
Posts: n/a

Default Re: Invalidate Desktop with C# - 09-22-2005 , 09:13 AM






You should not need to invalidate the desktop. The window system should take
care of repainting the desktop automatically. Have you tested on another
system to see if you have a driver problem? Or a conflict with another piece
of software?

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor

<fdauo (AT) yahoo (DOT) de> wrote

Quote:
Hi together,

I have a "sliding" form on my desktop which can be expanded or
collapsed in a sliding manner. So my problem is, that if the form is
collapsing, I want to refresh or invalidate that region on the desktop.

I already tried it with something like this:

-----> snip

[DllImport("user32.dll", SetLastError = true)]
public static extern bool InvalidateRect(
IntPtr hWnd,
ref Rectangle lpRect,
bool bErase);

[DllImport("user32.dll")]
public extern static IntPtr GetDesktopWindow();

// just a rectangle on the whole screen for testing
Rectangle invalidateRect = new Rectangle(0,0,1280,1024);

InvalidateRect(GetDesktopWindow(), ref invalidateRect, true);


----> snap

So InvalidateRect returns with true, but the desktop isn't refreshed.
It's really confusing and I spent a long time - but I can't it getting
work.

What can I do to refresh a rectangle on the desktop???


Kind regards
Franz




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Invalidate Desktop with C# - 09-22-2005 , 09:54 AM



Ok,

before I make my sliding effect I apply the following functions:

// Stop redrawing:
SendMessage(this.Handle, (int)Win32Api.MessageDef.WM_SETREDRAW,
// 0, IntPtr.Zero);

and after the sliding effect is done I reactivate the painting again.

// Start redrawing:
SendMessage(this.Handle, (int)Win32Api.MessageDef.WM_SETREDRAW,
1, IntPtr.Zero);

this.Refresh();

As I understand the functions - only my sliding form should be affected
(this.Handle).
So I think because of these two SendMessage calls I have to repaint the
desktop by myself - and so I am searching for a way to invalidate the
desktop region?

Kind regards,
Franz


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Invalidate Desktop with C# - 09-22-2005 , 09:55 AM



Sorry,

this line:

// Stop redrawing:
SendMessage(this.Handle, (int)Win32Api.MessageDef.WM_SETREDRAW,
// 0, IntPtr.Zero);

should be as follows:

// Stop redrawing:
SendMessage(this.Handle, (int)Win32Api.MessageDef.WM_SETREDRAW,
0, IntPtr.Zero);


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.