Invalidate(); for only part of the form in VC++.NET

Omnibus

Member
Joined
Aug 30, 2004
Messages
8
Does anyone know how Invalidate(); can be applied on only part of the form in managed VC++.NET? Thanks in advance.
 
Omnibus said:
Does anyone know how Invalidate(); can be applied on only part of the form in managed VC++.NET? Thanks in advance.
put the area you want to invalidate on a pahodnel and call the panels invalidate method, or pass a rectangle to the Forms invalidate method.

UI find using a panel easier. no need to calculate the rectangle.
 
Joe Mamma said:
put the area you want to invalidate on a pahodnel and call the panels invalidate method, or pass a rectangle to the Forms invalidate method.

UI find using a panel easier. no need to calculate the rectangle.
Can you possibly give an example code in managed VC++.NET as to how to do that?
 
Omnibus said:
Can you possibly give an example code in managed VC++.NET as to how to do that?
boy my typing was attrocious. I swear I wasnt drinking!
pahodnel = panel (boy that was a weird one)

there is a basic example in the help.
llok up rectangle and region for examples for creating thos. . . they can be passed as arguments to Invalidate.
 
I cant figure out how to do that. As far as I understand from the help the rectangle should be created by something like this:

HDC hdc;
BOOL Rectangle(
hdc, // handle to DC
75, // x-coord of upper-left corner of rectangle
20, // y-coord of upper-left corner of rectangle
462, // x-coord of lower-right corner of rectangle
270 // y-coord of lower-right corner of rectangle
);

This, however, gives me

error C2078: too many initializers
error C2078: too many initializers
 
Omnibus said:
I cant figure out how to do that. As far as I understand from the help the rectangle should be created by something like this:

HDC hdc;
BOOL Rectangle(
hdc, // handle to DC
75, // x-coord of upper-left corner of rectangle
20, // y-coord of upper-left corner of rectangle
462, // x-coord of lower-right corner of rectangle
270 // y-coord of lower-right corner of rectangle
);

This, however, gives me

error C2078: too many initializers
error C2078: too many initializers
try
PHP:
Rectangle rect = Rectangle(
75, // x-coord of upper-left corner of rectangle
20, // y-coord of upper-left corner of rectangle
462, // x-coord of lower-right corner of rectangle
270 // y-coord of lower-right corner of rectangle
);
controlPtr -> Invalidate(rect);

or simply
PHP:
controlPtr -> Invalidate(Rectangle(75,20,462,270));

I dont know, my C++ is shaky. I dont use it for GUI - only for low level I/O.
 
Obviously managed VC++.NET has some peculiarities which dont allow code written for unmanaged C++ to compile. The only way the code compiles is by writing:

public __value struct ClipRectangle
Invalidate( ClipRectangle );

However, this doesnt do any good because ClipRectangle seems to encompass the entire form. I dont know how to declare ClipRectangle to be a specific portion of the form. The declarations you give above do not seem to apply in this case.
 
PHP:
System::Drawing::Rectangle *r =  
				  __nogc new System::Drawing::Rectangle(75,20,462,270);
ctrlPtr -> Invalidate(r);
or
PHP:
ctrlPtr -> Invalidate(__nogc new System::Drawing::Rectangle(75,20,462,270));
 
Thanks. Both codes compile well but with no apparent result. I also tried it like this:

Code:
System::Drawing::Rectangle *r = __nogc new System::Drawing::Rectangle(75,20,462,270);
public __value struct r;
this->Invalidate( r );

This also compiles well but the result is again zilch.
 
Omnibus said:
Thanks. Both codes compile well but with no apparent result. I also tried it like this:

Code:
System::Drawing::Rectangle *r = __nogc new System::Drawing::Rectangle(75,20,462,270);
public __value struct r;
this->Invalidate( r );

This also compiles well but the result is again zilch.
public __value struct r;

redeclares it and sets it to null. . .

try
this->Invalidate( r, true );[/CODE]
 
Gives the following error:

error C2664: void System::Windows::Forms::Control::Invalidate(System::Drawing::Rectangle,bool) : cannot convert parameter 1 from System::Drawing::Rectangle __gc * to System::Drawing::Rectangle

When hitting Continue the program works but the above Invalidate again has no effect.
 
try
PHP:
System::Drawing::Rectangle *r =  __nogc new System::Drawing::Rectangle(75,20,462,270);
this -> Invalidate(r);
Application::DoEvents();
 
This is the solution:
Code:
Invalidate(System::Drawing::Rectangle(75, 20, 1000, 250));
Thank you so much for your help and all the best.
 
Back
Top