Click here to Skip to main content

Managed C++/CLI

   

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
GeneralRe: Class Constructor in C++ PinmemberLamos Paul10:50 20 Feb '12  
GeneralRe: Class Constructor in C++ PinmvpRichard MacCutchan22:11 20 Feb '12  
AnswerRe: Class Constructor in C++ Pinmemberjschell10:29 20 Feb '12  
QuestionFading a Form PinmemberLucidation7:15 18 Feb '12  
AnswerRe: Fading a Form PinmemberPhilippe Mori8:28 18 Feb '12  
GeneralRe: Fading a Form PinmemberLucidation13:55 18 Feb '12  
AnswerRe: Fading a Form PinPopularmvpLuc Pattyn14:15 18 Feb '12  
There are at least two problems with your code:
 
1. there is no delay in your loop, it will sprint from 0 to 1 as fast as it can, all will be over in a fraction of a second.
 
2. the Form isn't visible while the Load handler is executing; it is only when Load is done that the Form becomes visible, so this is the wrong place for such loop.
 
The recommended solution to both these issues is as follows:
- give your Form an initial opacity of zero;
- in your Load handler, start a Windows.Forms.Timer with an interval of say 100 msec;
- in the timer's Tick handler, check the Form's opacity; if it is less than 1.0, add 0.05 to it; otherwise, stop the timer.
 
The reason you choose a Windows.Forms.Timer is that its events get handled by the main thread, and that is the only thread that is allowed to touch Controls and Forms. Other timers would tick on some threadpool thread, resulting in either some InvalidCrossThread exception, or the need for more code, based on Control.Invoke
 
Also notice there is no explicit loop anywhere; the timer will keep firing until you tell it to stop (when opacity reached 1.0).
 
Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionCArchiveException exception is not caught in catch(CArchiveException* e) block Pinmemberptr_Electron5:21 17 Feb '12  
AnswerRe: CArchiveException exception is not caught in catch(CArchiveException* e) block Pinmemberjohny101519815:51 17 Feb '12  
GeneralRe: CArchiveException exception is not caught in catch(CArchiveException* e) block Pinmemberptr_Electron20:16 17 Feb '12  
AnswerRe: CArchiveException exception is not caught in catch(CArchiveException* e) block PinmvpRichard MacCutchan6:35 17 Feb '12  
GeneralRe: CArchiveException exception is not caught in catch(CArchiveException* e) block Pinmemberptr_Electron20:14 17 Feb '12  
GeneralRe: CArchiveException exception is not caught in catch(CArchiveException* e) block PinmvpRichard MacCutchan21:10 17 Feb '12  
GeneralRe: CArchiveException exception is not caught in catch(CArchiveException* e) block Pinmemberptr_Electron21:29 17 Feb '12  
AnswerRe: CArchiveException exception is not caught in catch(CArchiveException* e) block PinmvpLuc Pattyn6:42 17 Feb '12  
AnswerRe: CArchiveException exception is not caught in catch(CArchiveException* e) block PinmemberJohn Schroedl7:37 17 Feb '12  
GeneralRe: CArchiveException exception is not caught in catch(CArchiveException* e) block PinmvpRichard MacCutchan21:30 17 Feb '12  
QuestionCalling DLL problem PinmemberMember 447869223:32 16 Feb '12  
QuestionConstructor PinmemberLamos Paul13:42 15 Feb '12  
AnswerRe: Constructor PinmemberRichard Andrew x6413:55 15 Feb '12  
AnswerRe: Constructor PinmvpLuc Pattyn8:48 20 Feb '12  
Questionerror C2143: syntax error : missing ';' before '*' PinmemberSam Hobbs18:56 13 Feb '12  
AnswerRe: error C2143: syntax error : missing ';' before '*' PinmvpRichard MacCutchan22:34 13 Feb '12  
GeneralRe: error C2143: syntax error : missing ';' before '*' PinmemberSam Hobbs23:36 13 Feb '12  
GeneralRe: error C2143: syntax error : missing ';' before '*' PinmvpRichard MacCutchan23:43 13 Feb '12  

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

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


Advertise | Privacy | Mobile
Beta | 2.5.120517.1 | Last Updated 22 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid