473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GDI Refresh Problem

Hi,

How can I execute 2 GDI steps without update the screen and update them
togheter?.

Basically I have a form and I want to change the Form Region and change the
Form Location, later show the changes on the screen.

On the Following code you can see that the code is executed but where the
window was there is the rest of the window that wasn't cleaned, if you move
a window over it it disapears.

I want to avoid see every change I do on the screen because I'm running many
changes a seconds (Animation)

I tried many ways but still I can get a way to work.

Here is the small code. "See Next Post" (Uncomment try1 or try2)
Thanks,

namespace PrototipesAndTesting
{
public class AnimateNoFlick : System.Windows.Forms.Form
{
#region enums
public enum SetWindowPosFlags
{
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002,
SWP_NOZORDER = 0x0004,
SWP_NOREDRAW = 0x0008,
SWP_NOACTIVATE = 0x0010
}
#endregion

#region WINAPIs
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr
hWndInsertAfter, int x, int y, int Width, int Height, SetWindowPosFlags
flags);
[DllImport("User32.dll", CharSet=CharSet.Auto)]
private static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool
redraw);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern int InvalidateRect(IntPtr hWnd, IntPtr rc, int
bErase);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern bool UpdateWindow(IntPtr hWnd);
#endregion

#region Variables Declaration
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
#endregion

#region Constructors
public AnimateNoFlick()
{
InitializeComponent();
}
#endregion

#region Initialization And Disposing
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 64);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// AnimateNoFlick
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(280, 262);
this.Controls.Add(this.button1);
this.Location = new System.Drawing.Point(300, 100);
this.Name = "AnimateNoFlick";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "AnimateNoFlick";
this.ResumeLayout(false);

}
#endregion

private void button1_Click(object sender, System.EventArgs e)
{
bool bResult;
int iResult;

Rectangle stepRec = new Rectangle(300, 500, this.Width,
this.Height);
Region region = new Region(new Rectangle(30,30, 200, 200));

Graphics graphics = this.CreateGraphics();
IntPtr ptr = region.GetHrgn(graphics);
graphics.Dispose();

//Try 1
//bResult = SetWindowPos(this.Handle, IntPtr.Zero, stepRec.X,
stepRec.Y, stepRec.Width, stepRec.Height, SetWindowPosFlags.SWP_NOZORDER |
SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_NOREDRAW);
//iResult = SetWindowRgn(this.Handle, ptr, true);

//Try 2
iResult = SetWindowRgn(this.Handle, ptr, false);
bResult = SetWindowPos(this.Handle, IntPtr.Zero, stepRec.X,
stepRec.Y, stepRec.Width, stepRec.Height, SetWindowPosFlags.SWP_NOZORDER |
SetWindowPosFlags.SWP_NOACTIVATE);
InvalidateRect(this.Handle, IntPtr.Zero, 1);
UpdateWindow(this.Handle);
Application.DoEvents();
}
#endregion
}
}
Nov 22 '05 #1
0 1187

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
4
by: Noel Wood | last post by:
Hello, I have a problem that I'm sure is simple but I have searched the newsgroup and have not found it posted before so I apologize if it has been asked heaps of times before. I have a page that...
3
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a...
5
by: Steve | last post by:
Hi, I have a private website for 20 people that is similar to a web email client like hotmail. There are two frames, one on the left with links for "New", "History", "Todays" and a frame on the...
12
by: Tarken | last post by:
Hi, I am trying to do some refactoring of a web site to ensure that it displays in the most web clients possible. One of the pages requires to be redirected to another automatically, for one...
4
by: Andrew Alger | last post by:
ok i have two forms. Customer.aspx and Parent_Searh.aspx. There is a button on Customer.aspx that when executed runs javascript code to open up parent_search as a popup. After the user searches...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
1
by: ppatel | last post by:
Problem I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine). When click...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
12
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.