Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: char buff !! :( Pin
Eytukan6-Mar-06 22:40
Eytukan6-Mar-06 22:40 
GeneralRe: char buff !! :( Pin
Eytukan6-Mar-06 22:49
Eytukan6-Mar-06 22:49 
GeneralRe: char buff !! :( Pin
ThatsAlok10-Mar-06 14:57
ThatsAlok10-Mar-06 14:57 
GeneralRe: char buff !! :( Pin
Eytukan15-Mar-06 5:17
Eytukan15-Mar-06 5:17 
QuestionProper way to save files in dialog app? Pin
ldsdbomber2-Mar-06 4:45
ldsdbomber2-Mar-06 4:45 
AnswerRe: Proper way to save files in dialog app? Pin
Roger Stoltz2-Mar-06 7:46
Roger Stoltz2-Mar-06 7:46 
QuestionMessageQ inside member function Pin
RichardS2-Mar-06 4:24
RichardS2-Mar-06 4:24 
AnswerRe: MessageQ inside member function Pin
Stephen Hewitt2-Mar-06 13:04
Stephen Hewitt2-Mar-06 13:04 
This code has a few problems. Here’s is an edited down version of your code which shows the biggest:
UINT uMsg = 0;
::PeekMessage((LPMSG)(&uMsg), m_hWnd, 0, 0, PM_REMOVE)


The first parameter to PeekMesage is a LPMSG but your variable is of type UINT. You would get a compiler error if you tried the following code:
::PeekMessage(&uMsg, m_hWnd, 0, 0, PM_REMOVE)


You "solve" this by adding the following C-style cast:
(LPMSG)


This will never work, all you've done with this cast is say to the compiler, "Yeah I know a LPMSG isn't the same as a UINT* and you normally wouldn't compile this code but I'm the man, just blindly push ahead and compile it anyway". The problem is a UINT isn't a MSG, cast or no cast.

Here's what it should look like (edited down version):
MSG m;
::PeekMessage(&m, m_hWnd, 0, 0, PM_REMOVE)


A word of advice:
   Never use C-style casts (a type in brackets). Always use function style casts instead. When you find yourself tempted to write (UINT)i write static_cast<UINT>(i) instead. If the cast doesn't make sense the compiler will complain (you can still get into trouble but the chances are a lot less). If you want to make the compiler do what you say as a C-style cast does use a reinterpret_cast. Casts are ugly (but occasionally necessary) and generally indicate a design flaw. The function style casts syntax allows you to spot casts more easily. Also C-style casts are not fine grained enough where as function style casts come in four types: dynamic_cast, static_cast, reinterpret_cast, const_cast so it is clearer and harder to abuse.


Steve
GeneralRe: MessageQ inside member function Pin
RichardS2-Mar-06 21:12
RichardS2-Mar-06 21:12 
QuestionQuestion about richedits Pin
KellyR2-Mar-06 4:22
KellyR2-Mar-06 4:22 
QuestionGetting USB flash drive lettter from vendor & product ID Pin
zebelge2-Mar-06 4:10
zebelge2-Mar-06 4:10 
Question"Catching" messages to the tab control on a PropertySheet? Pin
Phil.Benson2-Mar-06 4:02
professionalPhil.Benson2-Mar-06 4:02 
AnswerRe: "Catching" messages to the tab control on a PropertySheet? Pin
Phil.Benson3-Mar-06 0:05
professionalPhil.Benson3-Mar-06 0:05 
Questionwhat can mingw do for me? Pin
derek72-Mar-06 2:34
derek72-Mar-06 2:34 
AnswerRe: what can mingw do for me? Pin
walter762-Mar-06 3:31
walter762-Mar-06 3:31 
Questionmapi problem Pin
gamitech2-Mar-06 2:14
gamitech2-Mar-06 2:14 
AnswerRe: mapi problem Pin
David Crow2-Mar-06 6:39
David Crow2-Mar-06 6:39 
AnswerRe: mapi problem Pin
ThatsAlok10-Mar-06 15:23
ThatsAlok10-Mar-06 15:23 
GeneralRe: mapi problem Pin
gamitech10-Mar-06 22:33
gamitech10-Mar-06 22:33 
GeneralRe: mapi problem Pin
ThatsAlok11-Mar-06 0:00
ThatsAlok11-Mar-06 0:00 
QuestionWindow Message Pin
Nishad S2-Mar-06 2:05
Nishad S2-Mar-06 2:05 
AnswerRe: Window Message Pin
Stephen Hewitt2-Mar-06 2:24
Stephen Hewitt2-Mar-06 2:24 
AnswerRe: Window Message Pin
Malli_S2-Mar-06 2:42
Malli_S2-Mar-06 2:42 
AnswerRe: Window Message Pin
Robert W.2-Mar-06 3:52
Robert W.2-Mar-06 3:52 
QuestionCustom Recordset Building...! Pin
Malli_S2-Mar-06 1:42
Malli_S2-Mar-06 1:42 

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.