|
In that case, is there any way to undef the DEBUG_NEW just before the conflicting code, and then re-define it right afterward?
Something like below: (except this one generated one warning)
static void* Alloc(UINT size)
{
#ifdef _DEBUG
#undef new DEBUG_NEW // <-- compile warning C4067: unexpected tokens following preprocessor directive - expected a newline
#endif
return operator new(size);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
} Thanks.
|
|
|
|
|
Sorry for the late reply - did you get this working?
The line with the warning should be just
#undef new As I mentioned before, I'm just not sure where this should be in a template class.
Since the actual class is built where an object is instantiated, I'm not sure if
the #undef stuff needs to be there or if it worke by putting it in the template declaration.
If it works in the template declaration (as you've shown) then that's cool
It's easy enough to test.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
hey all!
i am an amateur in VC++! i ve got a problem and that is by pressing Enter Key of keyboard, my program shuts down as i guess its by default!
Now my program uses a text box and what i want is is when i write something and press Enter! the Enter key activate an Event Handler! or a specified function say displaying the text what is written in the text box in other list box etc!
plzz anyone who can help in this regard!
also is there any way to creat my own event handler????
Like for Enter key? as there is one for helpinfo with WM_HELPINFO which activates if F1 is pressed!
I ll be grateful if anyone lead me to the solution!
whats wrong wit'cha?
|
|
|
|
|
In a Dialog box the enter key causes the OnOK method to get called.
There are a couple of ways you can do this, you can do your processing in OnOK but not call CDialog::OnOK, and to make the OK button work again, you will need to add an event handler for the ok button and in there call CDialog::OnOK.
Or you can catch the WM_KEYDOWN message for the VK_ENTER key in PreTranslateMessage and do your processing there, but don't call CDialog::PreTranslateMessage when the enter key is pressed.
AliR.
Visual C++ MVP
|
|
|
|
|
well i didn get ya !
wat i wanna do is to use tht Enter key for activating any of my desired button! Like say a button Send! if i write something in the text box and press Enter! it works if i ve CLICKED Send!
i ll be grateful if u clearify it a bit!
|
|
|
|
|
ddspliting wrote: I ll be grateful if anyone lead me to the solution!
See here and here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
well thnxx david! but see this!
switch (nChar)
{
case VK_RETURN: OnBsend();
}
so if VK_RETURN is the case then call OnBsend() function!
am i right? but if now i press Enter ! then still the program closes!!?
please reflect light on tht
|
|
|
|
|
What is happening in the OnOK() handler()?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key?
u know clicking Send Button while working in a TextBox is cumbersome! just like chat in msn messenger or yahoo ones window! where when we press Enter! or wat u call RETURN the message is sent or we can say tht Send button is activated!
|
|
|
|
|
ddspliting wrote: well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key?
So did you bother to read this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Read? What programmers read? Pfffffffft we "write" .... code. We don't need no stinkin readin
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry!
I read tht a bit late! and my problem is solved now! thanxx to u David and to the codeproject! Really Nice Service! top that!
|
|
|
|
|
I have a CSpinButtonCtrl in a dialog box and want to check changes to its value only after the user releases the mouse button. It seems that the spin control sends WM_VSCROLL messages with SB_THUMBPOSITION set even before the user releases the mouse button. Can anyone tell me how to process only the final message, and not all the ones in between (I don't think WM_LBUTTONUP would do it, since I need to determine which control it came from, and that message doesn't seem to tell me that.)
Thanks!
|
|
|
|
|
Californian2 wrote: ...(I don't think WM_LBUTTONUP would do it, since I need to determine which control it came from, and that message doesn't seem to tell me that.)
How are you verifying this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have an OnVScroll handler in my dialog box procedure which checks whether nSBCode equals SB_THUMBPOSITION, and the part of the code that should only run if SB_THUMBPOSITION is set is being run before the mouse button is released.
|
|
|
|
|
Californian2 wrote: I have an OnVScroll handler in my dialog box procedure...
And the third parameter of that override is (a pointer to) the control you are after.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You got mixed up! I didn't ask how to find out which control sent the message. I asked how to process spin control messages only after the mouse button is released, and not for every WM_VSCROLL message!
|
|
|
|
|
Californian2 wrote: I didn't ask how to find out which control sent the message.
Actually, you did:
"I need to determine which control it came from..."
Californian2 wrote: I asked how to process spin control messages only after the mouse button is released, and not for every WM_VSCROLL message!
Check out the difference between SB_THUMBPOSITION and SB_THUMBTRACK .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Look, here's my original question again:
I have a CSpinButtonCtrl in a dialog box and want to check changes to its value only after the user releases the mouse button. It seems that the spin control sends WM_VSCROLL messages with SB_THUMBPOSITION set even before the user releases the mouse button. Can anyone tell me how to process only the final message, and not all the ones in between (I don't think WM_LBUTTONUP would do it, since I need to determine which control it came from, and that message doesn't seem to tell me that.)
---------
What I said was that WM_LBUTTONUP was not the answer to my problem because I'm using information (given to me through OnVScroll) about which control sent me the message.
I want to know how to process a change to a value in a spin control only after the user releases the mouse button.
I already know the difference between SB_THUMBPOSITION and SB_THUMBTRACK. The use of SB_THUMBTRACK would be decidedly unhelpful. If you don't know the answer to my question, don't waste my time by pretending I asked some other, obviously stupid, question.
|
|
|
|
|
By deriving a class from CSpinButtonCtrl , you can easily handle the WM_LBUTTONUP message. No need to mess with the other SB_* notifications (unless you really want to).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks, but see the answer from Mark Salsbery for the solution I was looking for.
|
|
|
|
|
Californian2 wrote: Can anyone tell me how to process only the final message, and not all the ones in between
What about the SB_ENDSCROLL scroll code?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks so much, Mark! I somehow missed the SB_ENDSCROLL code in the documentation, but I tried it, and it is exactly what I needed!
Thank you, thank you, thank you!
|
|
|
|