|
Whenever the return key is hit on a dialog Windows will by default fire a WM_COMMAND event saying that the default button was clicked (usually with the id of IDOK). To override it you'll need to watch any keyboard messages received and filter them out.
To do this override the PreTranslateMessage event for the dialog using the Class Wizard and add something like:
BOOL CYourDialogClass::PreTranslateMessage( MSG* pMsg )
{
switch( pMsg->message )
{
case WM_KEYDOWN:
{
if( pMsg->wParam == VK_RETURN )
{
if( pMsg->hwnd == GetDlgItem( IDC_EDIT1 )->GetSafeHwnd( ) )
{
return TRUE;
}
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Gavin Taylor
w: http://www.gavspace.com
-- modified at 19:33 Monday 6th February, 2006
|
|
|
|
|
Much easier would be to give the edit control the "Want return" property, which is on the "Styles" tab of the properties. When you do that, the edit control will automatically catch enters itself and not cast them to the parent dialog box. This property is mainly valid for multiline edit controls (where you want to be able to enter newlines, without quiting your program every time)
William Engberts
|
|
|
|
|
hi there,
You guys are the best...Thank you so much...Cool! this website is golden and so heplfull in term of educational...
Again, thank to both of you...
J.
Jim
|
|
|
|
|
I'm looking for a good book to learn about Visual C++ .net
I have a moderate amount of experience with C and C++, and have used older versions of Visual Studio, but never felt completely comfortable in the environment.
Most books I've looked at concentrate too heavily on language, not enough on Visual Studio, etc for me.
Any suggestions are welcome!
-mutty
|
|
|
|
|
Are you asking for a book on C++/CLI ( that is, managed C++ ) ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If your are specifically looking for .NET stuff (i.e. managed extensions) I have no idea. For learning visual studio and MFC I'd recommend:
-Practical Visual Studio C++ 6.0, Bates & Tompkins, ISBN 0-7897-2142-2
deals with an older version of visual studio, but it's a very good introduction
-Visual C++ .NET bible, Archer & Whitechapel, ISBN 0-7645-4837-9
mostly MFC related, but under the VS.Net enviroment. Bit in at the deep end compared to
the book above, but written for the right version of VS
Have fun!
Cheers,
Mark
|
|
|
|
|
Ok, i can easily write _T("Charge Control Valve") to make a Unicode string out of my ASCII string at compile time.
But _T("チャージコントロール") in the same source file doesn't work. I can't even write or paste it into my source file.
The only idea i have is
WCHAR myString[] = {0x1234, ... , 0x0000 };
Another question, can i avoid LoadString and get a pointer to the strings in the stringtable?
Thanks
|
|
|
|
|
Look up the definition of the _T macro
#ifdef UNICODE
#define _T(x) L##x
#else
#define _T(x) x
#endif So in a UNICODE build _T("Hi") becomes L"Hi" and in an SBCS or MBCS build it becomes "Hi" .
Try using L instead of _T .
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks for your reply, but that doesn't solve my problem.
My problem is that i want japanese strings in the source code, but the IDE and Compiler doesn't support unicode source files (VC6). I've now made a Perl Script that creates arrays or WCHAR's from the unicode string. Any better idea?
WCHAR jpn[] = {0x0032, 0x6B21, 0x30A8, 0x30A2, 0x0000};<br />
AfxMessageBox (jpn);
|
|
|
|
|
Hi,
Do I have any realistic hope of being able to diagnose a bugcheck if I have the minidump file?
I am an app developer, and I know nothing about kernel-mode. I know the error code: 0x10000050.
Is there a resource I could use to learn how to use the dump file, or would it just be a goose-chase since I am not expert at kernel-mode stuff?
Thanks,
Rich
|
|
|
|
|
Hi everyone,
I am trying to use the boost multithreading library. I am having a
problem as the join() function for the thread never returns. I am using
a boolean variable to indicate when the thread should stop running.
Here is basically a stub of what I am doing:
<br />
bool m_RunThread = false;<br />
scoped_ptr<boost::thread> myThread;<br />
<br />
void MyObject::StartThread()<br />
{<br />
m_RunThread = true;<br />
myThread.reset(new boost::thread(boost::bind<br />
(&MyObject::MyThreadFunc, this)));<br />
}<br />
<br />
void MyObject::StopThread()<br />
{<br />
m_RunThread = false;<br />
myThread.join();
<br />
... Never gets here....<br />
<br />
}<br />
<br />
void MyObject::MyThreadFunc()<br />
{<br />
while (m_RunThread)<br />
{<br />
}<br />
}<br />
However, the join() function in StopThread never returns. I think that
using a variable to synchronize this is probably not a good idea. Any
thoughts and suggestions?
Cheers,
K
|
|
|
|
|
Have you verified that MyObject::MyThreadFunc ever exits? Perhaps it's spinning in a loop.
Steve
|
|
|
|
|
Yup. It definitely exits, as if you put a breakpoint in there after the condition is met, it never gets there. Also, m_RunThread member is declared as volatile.
Cheers,
K
|
|
|
|
|
Sorry, but I'm not sure if it exits or not after reading you reply. When you say, "It definitely exits" it makes me think it exits but when you say, "it never gets there" I'm not so sure. If you put a breakpoint at all return points of the thread function does one get hit?
Steve
|
|
|
|
|
Anyone know of an easy way to search a vector for the following:
Lets say I have a vector with 80,000 structures in it and I want to search for duplicate strDevice strings in each struct. Is there a easy or fast way to do this with out pulling the first string and compairing it to the other 79,999 then pulling the second and third etc...
const struct s_item
{
CString strDevice,
strIP,
strLID;
};
std::vector<s_item> v_items;
Any ideas?
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
you could add them to a std::map and in each node, keep the index of the std::vector of the string ...
for example ( with letters )
vector : a b c d a b a a c d e f a b
loop the vector, for each item, insert in the map
a (idx 0, 4, 6, 7, 12 )
b (idx 1, 5, 13 )
...
at the end, you have a map of all uniq words, with a vector of the index in the vector of each string ( or structure )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
using stl::find() algorithm seems to work fine for me.
My articles
BlackDice
|
|
|
|
|
First you need a way of comparing s_item s for equality based on the strDevice string:
struct DeviceIDsEqual : binary_function<s_item, s_item, bool>
{
bool operator()(const s_item& f, const s_item& s) const
{
return f.strDevice == s.strDevice;
}
}
We also need the vector sorted so we need to compare if one s_item is less the another based on the strDevice string.
struct DeviceIDsLess : binary_function<s_item, s_item, bool>
{
bool operator()(const s_item& f, const s_item& s) const
{
return f.strDevice < s.strDevice;
}
}
Now we first sort then eliminate duplicates:
typedef vector<s_item>::iterator VI;
sort(v_items.begin(), v_items.end(), DeviceIDsLess());
VI newEnd = unique(v_items.begin(), v_items.end(), DeviceIDsEqual());
m_items.erase(newEnd, v_items.end());
Of if you just want to find the duplicates you can use the adjacent_find algorithm.
This code needs the following includes:
<functional>
<algorithm>
and the following:
using namespace std;
Steve
-- modified at 23:48 Monday 6th February, 2006
|
|
|
|
|
Thank you this is exactly what I was looking for. I need to brush up on templates and STL
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
My software has unicode display problem. I followed UNICODE articles from this site. But my software menu still can not display UNIcode under the English Win XP OS (Unicode font was installed. On the same computer, the notepad can display unicode. )
Any body has same experience and how you solved this problem?
Many thanks,
|
|
|
|
|
I am looking for some gauge controls like the Dundas gauges, but for MFC and not .NET.
Commercial is ok, but as always free would be better
Thanks
|
|
|
|
|
Hi All,
I remember seeing a call that would allow you to download a file via a url in MSDN, I can't for the life of me, remember what it was called.
Anybody know?
Thanks.
Mike
|
|
|
|
|
I think URLDownloadToCacheFile(...) and URLDownloadToFile(...) are what you are looking for. There is an article here on CP that demonstrates at least one of those functions.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
URLDownloadToFile
rrrado
|
|
|
|
|
I have a dialog MFC application. Sometimes I show the modeless dialog above parent dialog to display some progress of worker thread. Progress window can be currently moved along the screen. How to make it clipped by parent dialog ? (Something like a view window in the MDI Frame)
Thank you!
rrrado
|
|
|
|