473,778 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 PrototipesAndTe sting
{
public class AnimateNoFlick : System.Windows. Forms.Form
{
#region enums
public enum SetWindowPosFla gs
{
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002,
SWP_NOZORDER = 0x0004,
SWP_NOREDRAW = 0x0008,
SWP_NOACTIVATE = 0x0010
}
#endregion

#region WINAPIs
[DllImport("user 32.dll", CharSet=CharSet .Auto)]
private static extern bool SetWindowPos(In tPtr hWnd, IntPtr
hWndInsertAfter , int x, int y, int Width, int Height, SetWindowPosFla gs
flags);
[DllImport("User 32.dll", CharSet=CharSet .Auto)]
private static extern int SetWindowRgn(In tPtr hWnd, IntPtr hRgn, bool
redraw);
[DllImport("user 32.dll", CharSet=CharSet .Auto)]
private static extern int InvalidateRect( IntPtr hWnd, IntPtr rc, int
bErase);
[DllImport("user 32.dll", CharSet=CharSet .Auto)]
private static extern bool UpdateWindow(In tPtr hWnd);
#endregion

#region Variables Declaration
private System.Windows. Forms.Button button1;
private System.Componen tModel.Containe r components = null;
#endregion

#region Constructors
public AnimateNoFlick( )
{
InitializeCompo nent();
}
#endregion

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

#region Windows Form Designer generated code
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(96, 64);
this.button1.Na me = "button1";
this.button1.Ta bIndex = 2;
this.button1.Te xt = "button1";
this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click);
//
// AnimateNoFlick
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(280, 262);
this.Controls.A dd(this.button1 );
this.Location = new System.Drawing. Point(300, 100);
this.Name = "AnimateNoFlick ";
this.StartPosit ion = System.Windows. Forms.FormStart Position.Manual ;
this.Text = "AnimateNoFlick ";
this.ResumeLayo ut(false);

}
#endregion

private void button1_Click(o bject sender, System.EventArg s 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.CreateGrap hics();
IntPtr ptr = region.GetHrgn( graphics);
graphics.Dispos e();

//Try 1
//bResult = SetWindowPos(th is.Handle, IntPtr.Zero, stepRec.X,
stepRec.Y, stepRec.Width, stepRec.Height, SetWindowPosFla gs.SWP_NOZORDER |
SetWindowPosFla gs.SWP_NOACTIVA TE | SetWindowPosFla gs.SWP_NOREDRAW );
//iResult = SetWindowRgn(th is.Handle, ptr, true);

//Try 2
iResult = SetWindowRgn(th is.Handle, ptr, false);
bResult = SetWindowPos(th is.Handle, IntPtr.Zero, stepRec.X,
stepRec.Y, stepRec.Width, stepRec.Height, SetWindowPosFla gs.SWP_NOZORDER |
SetWindowPosFla gs.SWP_NOACTIVA TE);
InvalidateRect( this.Handle, IntPtr.Zero, 1);
UpdateWindow(th is.Handle);
Application.DoE vents();
}
#endregion
}
}
Nov 22 '05 #1
0 1227

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

Similar topics

9
4923
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 == "") { include ("InsertRecord.inc"); // Insert new record }
4
5494
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 list all current orders from customers. Customers can order at any time. I have a checkbox beside each listing so that as each order is complete it can be ticked off. I want the page to refresh every 2 mins so I have added .... <meta...
3
12924
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 recordset table on the 2nd graph page and because the user gets to it by clicking the graph, the page doesn't properly post to render the recordset table. I can click "Refresh" on 2nd page and table displays fine. Is there an ASP refresh command that...
5
4457
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 right with a table for viewing the contents of these messages. The left pane checks back with the server every few seconds to see if any new messages need to be processed and updates count accordingly.
12
10821
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 reason or another. My style is usually to reduce the use of Javascript, as much as possible, as in my experience it often causes compatibility issues. Anyhow, the page currently has: ....
4
3175
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 for the parent and finds the proper parent in the datagrid they then click on the accept button in the grid. Then I populate a session variable with the parent ID. I then go back to the main page and have it refresh using: ...
10
9251
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 click event and I update session information to track the visibilty of some panels in a wizard type navigation ("Next >>" and "<< Back" buttons).. but the refresh button makes another event firing and takes the whole thing to a Choes.. ...
1
3369
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 event fires first time it executes code associate with click event(As I expected). the problem is when you refresh page it fires a click event automatically. I looked around many posts and did not find any topics about this problem. Infact the same...
7
15443
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 the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
12
6045
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
9629
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9465
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10296
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10068
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7474
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2863
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.