Quantcast
Channel: Weird Paint Event Problem
Viewing all articles
Browse latest Browse all 5

Weird Paint Event Problem

$
0
0

I am creating a .net program which requires a rectangle to be drawn on the screen,  the code is triggered by a menu item click, which runs the code: 

 

this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::PaintForm);

 

this event draws a rectangle fill, then a rectangle line around it (anybody know how to make that one shape instead of two?) like this:

Graphics^ g = this->CreateGraphics();
Pen^ blackPen = gcnew Pen(Color::Black);
SolidBrush^ whiteBrush = gcnew SolidBrush(Color::White);
Rectangle stage = Rectangle(70, 70, 339, 439);
g->DrawRectangle(blackPen, 69, 69, 340, 440);
g->FillRectangle(whiteBrush, stage)

the code runs fine, but the shape will not appear (the screen won't blit) until I minimize the form, then restore it. I've tried all sorts of things like using e->Graphics-> Instead of the Graphics^ g = this->CreateGraphics();, and nothing seems to fix it. Any help?

By the way, I'm fine with receiving code samples in codes other than c++.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>