Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiontypedef template Pin
Erock1232-Feb-06 6:23
Erock1232-Feb-06 6:23 
QuestionChanging caption of static control at run time Pin
BiswaR2-Feb-06 5:31
BiswaR2-Feb-06 5:31 
AnswerRe: Changing caption of static control at run time Pin
Iain Clarke, Warrior Programmer2-Feb-06 6:03
Iain Clarke, Warrior Programmer2-Feb-06 6:03 
GeneralRe: Changing caption of static control at run time Pin
BiswaR2-Feb-06 21:31
BiswaR2-Feb-06 21:31 
AnswerRe: Changing caption of static control at run time Pin
RChin2-Feb-06 6:05
RChin2-Feb-06 6:05 
AnswerRe: Changing caption of static control at run time Pin
Andre xxxxxxx2-Feb-06 6:36
Andre xxxxxxx2-Feb-06 6:36 
QuestionStatus bar, Tool bar, invalid handle problem Pin
StelzbocK2-Feb-06 5:30
StelzbocK2-Feb-06 5:30 
AnswerRe: Status bar, Tool bar, invalid handle problem Pin
Iain Clarke, Warrior Programmer2-Feb-06 6:01
Iain Clarke, Warrior Programmer2-Feb-06 6:01 
I'll try to address some of your problems... Just bare in mind I'm not on my development machine, so this if from memory.

0/ To get a pointer to your CMainFrame, just use CMainFrame *pMain = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd ()).
Once you have that, you can get at any method you've exposed for changing toolbars / status bars, etc. Or use them as public members if you're brave / silly.

1/ Using (0), you could do pMain->m_barStatus.Invalidate (FALSE) to make the text refresh. But if you get a rush of data, your numbers could change annoyingly quickly. I'd change the value as you get data in, but have a timer updating the status bar from that value, rather than doing directly. And if you set the integer with one of the ::InterlockedXXXX functions, you have thread safety too.

2/ You *could* have a toolbar button changing, but that may not be necessary. Have a Play button (green arrow pointing right?). Add an OnUpdateUI handler in your view (look for ON_UPDATE_COMMAND macro). There, use pCmdUI->SetChecked (m_bImPlayingWheeeeee); to make the button sunken when playing, and not sunk when not playing. That should be more than sufficient, a lot easier to hook up, and flicker free.

3a/ If the handle is created from CreateFile, initialise and test against INVALID_HANDLE_VALUE, rather then 0 (You do set it to a value before you use it, don't you?). That was you only have one test, not too. More likely to be correct that way. The less work you do, the less mistakes you can make... That's my excuse for laziness, and I'm sticking to it.

3b/ You don't show your closing function, but after you close the handle, you should set it to INVALID_HANDLE_VALUE again. Then your tests work once more!

3c/ The above will work 99% of the time. But if you can access serial_handle from more than one thread, you need to wrap changes to it in EnterCriticalSection / LeaveCritical section. You can search for *lot* of examples.

I hoped that helped. If not, tough, as my fingers are tired out!

Good luck,

Iain.
GeneralRe: Status bar, Tool bar, invalid handle problem Pin
StelzbocK2-Feb-06 6:36
StelzbocK2-Feb-06 6:36 
QuestionLib Files that we use Pin
kanduripavan2-Feb-06 5:25
kanduripavan2-Feb-06 5:25 
AnswerRe: Lib Files that we use Pin
Chris Losinger2-Feb-06 8:28
professionalChris Losinger2-Feb-06 8:28 
QuestionMultiple documents and multiple views for each Pin
Andre xxxxxxx2-Feb-06 5:08
Andre xxxxxxx2-Feb-06 5:08 
AnswerRe: Multiple documents and multiple views for each Pin
Iain Clarke, Warrior Programmer2-Feb-06 5:24
Iain Clarke, Warrior Programmer2-Feb-06 5:24 
GeneralRe: Multiple documents and multiple views for each Pin
Andre xxxxxxx2-Feb-06 6:11
Andre xxxxxxx2-Feb-06 6:11 
QuestionNetworking Pin
Girish6012-Feb-06 3:13
Girish6012-Feb-06 3:13 
QuestionRe: Networking Pin
David Crow2-Feb-06 4:56
David Crow2-Feb-06 4:56 
QuestionDynamic memory allocation in MFC Pin
Odiee2-Feb-06 1:33
Odiee2-Feb-06 1:33 
AnswerRe: Dynamic memory allocation in MFC Pin
Maximilien2-Feb-06 2:47
Maximilien2-Feb-06 2:47 
QuestionSB_THUMBTRACK in ListCtrl Pin
Nishad S2-Feb-06 0:21
Nishad S2-Feb-06 0:21 
AnswerRe: SB_THUMBTRACK in ListCtrl Pin
Jagadeesh VN2-Feb-06 0:51
Jagadeesh VN2-Feb-06 0:51 
GeneralRe: SB_THUMBTRACK in ListCtrl Pin
Nishad S2-Feb-06 1:01
Nishad S2-Feb-06 1:01 
QuestionRe: SB_THUMBTRACK in ListCtrl Pin
David Crow2-Feb-06 4:59
David Crow2-Feb-06 4:59 
AnswerRe: SB_THUMBTRACK in ListCtrl Pin
PJ Arends2-Feb-06 6:53
professionalPJ Arends2-Feb-06 6:53 
GeneralRe: SB_THUMBTRACK in ListCtrl Pin
Nishad S2-Feb-06 16:56
Nishad S2-Feb-06 16:56 
QuestionProblem in compiling in debug mode with msxml2.lib Pin
kanduripavan2-Feb-06 0:10
kanduripavan2-Feb-06 0:10 

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.