Click here to Skip to main content
15,897,371 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionTesting if Elevated Process Pin
turkmeistr127-Apr-09 5:23
turkmeistr127-Apr-09 5:23 
AnswerRe: Testing if Elevated Process Pin
Mark Salsbery27-Apr-09 6:53
Mark Salsbery27-Apr-09 6:53 
GeneralRe: Testing if Elevated Process Pin
turkmeistr127-Apr-09 9:01
turkmeistr127-Apr-09 9:01 
GeneralRe: Testing if Elevated Process Pin
Mark Salsbery27-Apr-09 9:05
Mark Salsbery27-Apr-09 9:05 
GeneralRe: Testing if Elevated Process Pin
turkmeistr127-Apr-09 10:08
turkmeistr127-Apr-09 10:08 
GeneralRe: Testing if Elevated Process Pin
Mark Salsbery27-Apr-09 11:11
Mark Salsbery27-Apr-09 11:11 
QuestionGetting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster26-Apr-09 19:55
Jeffrey Webster26-Apr-09 19:55 
AnswerRe: Getting the Brush to apply to pictureBox instead of Form Pin
Luc Pattyn27-Apr-09 0:58
sitebuilderLuc Pattyn27-Apr-09 0:58 
Hi Jeff,

I have a standard reply for such a popular question, here it goes:

there are several steps to correctly draw something; it does not matter how complex the paint job is: from a single line, to a complex drawing, or a real work of art.

To make sure it all becomes visible on the screen and gets repainted automatically when moving, resizing, minimizing/maximizing/restoring or uncovering your Form, one should follow these steps:

1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a Form itself. I prefer to add a Panel to a Form, then draw on the Panel.

2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of your drawing. For a rectangle that could be top and left coordinate, and width+height, or just a Rectangle. etc.

3.
create a Paint handler (either add your own paint handler to the Paint event, or
override the OnPaint method) for that Panel, and do all your drawing in there,
using the Graphics class and your variables.

4.
if and when you want to change things, modify the variables and call Panel.Invalidate() or one of its overloads (for selective invalidation).

5.
If you want to animate things, perform the move (step 4) inside the Tick handler of a Windows.Forms.Timer which ticks on the GUI thread, so you are allowed to call Invalidate() from there too.

BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster27-Apr-09 3:13
Jeffrey Webster27-Apr-09 3:13 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Luc Pattyn27-Apr-09 3:43
sitebuilderLuc Pattyn27-Apr-09 3:43 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster27-Apr-09 4:26
Jeffrey Webster27-Apr-09 4:26 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Luc Pattyn27-Apr-09 4:34
sitebuilderLuc Pattyn27-Apr-09 4:34 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster27-Apr-09 6:20
Jeffrey Webster27-Apr-09 6:20 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Luc Pattyn27-Apr-09 6:23
sitebuilderLuc Pattyn27-Apr-09 6:23 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster27-Apr-09 6:34
Jeffrey Webster27-Apr-09 6:34 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Luc Pattyn27-Apr-09 6:52
sitebuilderLuc Pattyn27-Apr-09 6:52 
GeneralRe: Getting the Brush to apply to pictureBox instead of Form Pin
Jeffrey Webster27-Apr-09 8:01
Jeffrey Webster27-Apr-09 8:01 
QuestionHow to Convert Strings[] to LPWSTR*??? Pin
ANURAG VISHNOI22-Apr-09 21:14
ANURAG VISHNOI22-Apr-09 21:14 
AnswerRe: How to Convert Strings[] to LPWSTR*??? Pin
Mark Salsbery23-Apr-09 6:33
Mark Salsbery23-Apr-09 6:33 
QuestionChecking OS and Vista admin rights Pin
turkmeistr122-Apr-09 3:32
turkmeistr122-Apr-09 3:32 
AnswerRe: Checking OS and Vista admin rights Pin
Mark Salsbery22-Apr-09 8:07
Mark Salsbery22-Apr-09 8:07 
GeneralRe: Checking OS and Vista admin rights Pin
turkmeistr122-Apr-09 8:38
turkmeistr122-Apr-09 8:38 
GeneralRe: Checking OS and Vista admin rights Pin
Mark Salsbery22-Apr-09 12:15
Mark Salsbery22-Apr-09 12:15 
GeneralRe: Checking OS and Vista admin rights Pin
turkmeistr122-Apr-09 12:40
turkmeistr122-Apr-09 12:40 
GeneralRe: Checking OS and Vista admin rights Pin
Mark Salsbery22-Apr-09 13:26
Mark Salsbery22-Apr-09 13:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.