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

Managed C++/CLI

 
GeneralRe: Diff between array and list. Pin
Nandu_77b9-Aug-07 4:51
Nandu_77b9-Aug-07 4:51 
Questionminimizing dialog to system tray Pin
dona jain6-Aug-07 18:50
dona jain6-Aug-07 18:50 
AnswerRe: minimizing dialog to system tray Pin
Mark Salsbery6-Aug-07 20:12
Mark Salsbery6-Aug-07 20:12 
GeneralRe: minimizing dialog to system tray Pin
iddqd5157-Aug-07 3:27
iddqd5157-Aug-07 3:27 
QuestionRepainting Display Seems Slow Pin
BuckBrown6-Aug-07 11:03
BuckBrown6-Aug-07 11:03 
AnswerRe: Repainting Display Seems Slow Pin
Luc Pattyn6-Aug-07 11:10
sitebuilderLuc Pattyn6-Aug-07 11:10 
GeneralRe: Repainting Display Seems Slow Pin
BuckBrown6-Aug-07 11:52
BuckBrown6-Aug-07 11:52 
GeneralRe: Repainting Display Seems Slow Pin
Luc Pattyn6-Aug-07 12:14
sitebuilderLuc Pattyn6-Aug-07 12:14 
OK, the situation is clear, the remedy takes two parts:

SPEED

Math::Sin and Math::Cos are expensive methods.
And there is a lot of subexpressions like (Math::Cos(radians) * radius) + 50);
these get evaluated over and over, don't rely on the compiler to optimize them all
away but one or two of them. Instead calculate them yourself and store the result in
a local variable for reuse.
It may be so that it runs much faster in release build, but I would not count on it.
Calling a method in another class (such as Math::Cos) prevents a lot of optimizations,
basically the compiler does not trust every call with same argument will return same
result.

PAINT PROBLEM

The way you organized it, the wafer gets painted when you click a menu item or so,
just once. If your form gets disrupted (covered-uncovered, minimized-restored, ...)
(part of) the wafer is gone, what piece of code would redraw it for you ?

The right approach is to have a Paint handler, that gets fired thru the Paint event
(similar to a Click event for a Button). The Paint handler basically should contain
the code you now have in the menu item handler.

The Paint handler gets invoked automatically when the form got damaged, and also
when you call Invalidate().

Hence your menu item handler should just set up a few variables, maybe a show/hide wafer
flag or so, and then it should end on an Invalidate().


Happy painting !



Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: Repainting Display Seems Slow Pin
BuckBrown7-Aug-07 6:24
BuckBrown7-Aug-07 6:24 
GeneralRe: Repainting Display Seems Slow Pin
Luc Pattyn7-Aug-07 6:51
sitebuilderLuc Pattyn7-Aug-07 6:51 
GeneralRe: Repainting Display Seems Slow Pin
BuckBrown7-Aug-07 7:55
BuckBrown7-Aug-07 7:55 
GeneralRe: Repainting Display Seems Slow Pin
Luc Pattyn7-Aug-07 13:36
sitebuilderLuc Pattyn7-Aug-07 13:36 
Questionhow to convert a String to datetime and do subtraction of time ??? Pin
aefmaaradji6-Aug-07 1:01
aefmaaradji6-Aug-07 1:01 
AnswerRe: how to convert a String to datetime and do subtraction of time ??? Pin
Luc Pattyn6-Aug-07 1:12
sitebuilderLuc Pattyn6-Aug-07 1:12 
Questiondouble(*)[2] ? Pin
dalgados5-Aug-07 21:18
dalgados5-Aug-07 21:18 
AnswerRe: double(*)[2] ? Pin
prasad_som5-Aug-07 22:22
prasad_som5-Aug-07 22:22 
Questionhow to declare a matrix in visual c++.net 2005 c++ cli ? Pin
aefmaaradji5-Aug-07 0:28
aefmaaradji5-Aug-07 0:28 
AnswerRe: how to declare a matrix in visual c++.net 2005 c++ cli ? Pin
mid=57415-Aug-07 5:17
mid=57415-Aug-07 5:17 
GeneralRe: how to declare a matrix in visual c++.net 2005 c++ cli ? Pin
aefmaaradji5-Aug-07 12:09
aefmaaradji5-Aug-07 12:09 
GeneralRe: how to declare a matrix in visual c++.net 2005 c++ cli ? Pin
mid=57415-Aug-07 12:16
mid=57415-Aug-07 12:16 
GeneralRe: how to declare a matrix in visual c++.net 2005 c++ cli ? Pin
George L. Jackson5-Aug-07 13:24
George L. Jackson5-Aug-07 13:24 
GeneralRe: how to declare a matrix in visual c++.net 2005 c++ cli ? Pin
aefmaaradji6-Aug-07 0:52
aefmaaradji6-Aug-07 0:52 
QuestionHow to wrap native array? Pin
mid=57414-Aug-07 9:06
mid=57414-Aug-07 9:06 
AnswerRe: How to wrap native array? Pin
Luc Pattyn4-Aug-07 9:24
sitebuilderLuc Pattyn4-Aug-07 9:24 
GeneralRe: How to wrap native array? Pin
mid=57414-Aug-07 9:30
mid=57414-Aug-07 9:30 

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.