|
Override a PreTranslateMessage :
BOOL CVariantDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
WORD wKeyCode = LOWORD(pMsg->wParam);
if ((wKeyCode == 13) || (wKeyCode == VK_ESCAPE))
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
Robert-Antonio
|
|
|
|
|
Please don't flame me (too much)... I am still a beginner.
I have a dialog type MFC app with 1 string table. I added there strings for all controls and visual messages to the user. All these in order to make my app multi-language prepared.
I thought this way: "I have default strings for everything. Then I try to load a language.ini file and overwrite every string in the string table with the ones that I read from the ini file. This way if the ini file is incomplete, I won't have textless controls or messages"
My problem is that I don't know how to :
a) Modify (IF POSSIBLE?) a string stored in a string table
b) Use a string from the string table as a parameter to a function that requires one. For example for MessageBox.
Thank you.
PS: One way to do b) that I found is:
CString test;
test.LoadString(IDS_STOP);
MessageBox(test,"abc",MB_OK);
Only I fear that there is a simpler way.
|
|
|
|
|
Paul DiLascia wrote such an article 8 or 10 years ago. I think it was called multi-lingual applications for MFC it was when VC5 first came out. Sorry I am no more help than this but I am sure he did such an article. Try his home page or microturd soft.
http://www.dilascia.com/
cppqa@microsoft.com <cppqa@microsoft.com>
Best Wishes,
ez_way
|
|
|
|
|
On the MSDN CD is a book on internationalization (a newer version of the same book was released by Microsoft Press earlier this year). There are also articles at codeproject on internationalization.
KEY WORD: internationalization
Good luck!
INTP
|
|
|
|
|
Thank you! Seems to work... I found a lot of info.
PS: What does INTP mean anyway? Couldn't find it in the acronym finder.
|
|
|
|
|
andreir23 wrote:
What does INTP mean anyway?
From: personalitypage.com
"Logical, original, creative thinkers. Can become very excited about theories and ideas. Exceptionally capable and driven to turn theories into clear understandings. Highly value knowledge, competence and logic. Quiet and reserved, hard to get to know well. Individualistic, having no interest in leading or following others."
INTP
|
|
|
|
|
How can I make an internet explorer plugin bar, kinda like codeproject has... I want to do this for a friend, though I won't make it to annoy anyone lol.. I went to some generic search engine and got so much spam it wasn't funny, anywayz, I looked on the IE bar and there were like 5 new bars. I'm like WTF? thank god for spybot, but anyways could anyone help me maybe find a way I can make a plugin... its for his website, thx.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
|
Hi All
I have a big MFC app, with many FrameWnds, toolbars and menus and so on...
When i move the mouse my CPU usage jumps to 100%. I checked it, and discovered that it happens because the all processing that happends in CWinApp::OnIdle.
so, I made this change:
BOOL CMyApp::IsIdleMessage(MSG* pMsg)
{
if (pMsg->msg == WM_MOUSEMOVE)
return FALSE;
}
It works fine now, no 100 cpu when the mouse is moved.
But my question is this: why CWinApp::IsIdleMessage() is written in this way in first place? why there is a need to update all controls after the mouse has moved?
thanks
|
|
|
|
|
Idle time is where MFC (among other things) calls all your UPDATE_COMMAND_UI handlers. Make sure your handlers aren't doing expensive operations like locking mutexes or hitting the disk.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber | RightClick-Encrypt
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
Ok, but still: why to send UPDATE_COMMAND_UI during mouse move?
why just no return FALSE in IsIdleMessage() when its WM_MOUSEMOVE msg?
|
|
|
|
|
The idle state occurs when no messages are waiting in the message queue. When you move the mouse a little bit, it generates a few WM_MOUSEMOVE messages. Those all get processed very quickly, and then the app goes idle again. So it's not moving the mouse that makes the app go idle, it's stopping the mouse movements.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber | RightClick-Encrypt
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Ok, So If I'll made this change in IsIdleMessage():
BOOL CMyApp::IsIdleMessage(MSG* pMsg)
{
if(pMsg->msg == WM_MOUSEMOVE)
return FALSE;
...
...
}
Can this cause any damage? I thought about it and didnt find any reason to return TRUE(like the original IsIdleMessage does) when its WM_MOUSEMOVE, am i correct?
10x
|
|
|
|
|
|
Hi!
I've been using MSVC++ 6.0 for about 5 years now, and by now, I haven't got any serious problems.
But today, I'd have liked to create a simple std::list with class-pointers in it. By that point everything were fine. But when I wanted to sort the list by a custom sorter, everything went wrong. I could not mangeged to sort the list, I always got the same compile error:
d:\projects\dc\try\try.cpp(42) : error C2664: 'void __thiscall std::list<class CTest *,class std::allocatorclass CTest *> >::sort(struct std::greater<class CTest *>)' : cannot convert parameter 1 from 'class CTestSorter' to 'struct std::greater<cla
ss CTest *>'
No constructor could take the source type, or constructor overload resolution was ambiguous
Please tell me, how could I sort such kind of lists in Visual C++ 6.0.
Thx in forward.
The code I tried to compile is here:
#include <iostream><br />
#include <list><br />
#include <math.h><br />
<br />
using namespace std;<br />
<br />
class CTest<br />
{<br />
friend class CTestSorter;<br />
protected:<br />
int sortby;<br />
int other;<br />
<br />
public:<br />
CTest() : sortby(0), other(0) { };<br />
CTest(int first, int second) : sortby(first), other(second) { };<br />
void Write()<br />
{<br />
cout << sortby << ". - " << other << "\n";<br />
} <br />
};<br />
<br />
class CTestSorter<br />
{<br />
public:<br />
bool operator() ( CTest* first, CTest*second )<br />
{<br />
return first->sortby < second->sortby;<br />
}<br />
};<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
list<CTest*> mylist;<br />
int i;<br />
cout << "Hello!\n";<br />
for( i=0;i<10;i++ )<br />
{<br />
CTest* obj=new CTest( 10-i, rand() );<br />
mylist.push_back( obj );<br />
}<br />
mylist.sort( CTestSorter() );<br />
for( list<CTest*>::iterator it=mylist.begin();it!=mylist.end();it++ )<br />
{<br />
(*it)->Write();<br />
}<br />
return 0;<br />
}
|
|
|
|
|
You're doing it fine... the problem lies in Dinkumware STL's implementation. The version you have was written many years ago for VC 5.0, which lacks proper support for template members, like templatized list::sort . Not that MSVC 6.0 is much stronger wrt to templates, but at least it can manage this one. You just have to slightly modify the list::sort declaration in <list> as described here[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
A lot of thanks for the help Joaquín. You've got me off a great trouble.
|
|
|
|
|
Actually, the page you linked containened a unworkin solution, but I browsed that thread, and found a really working one.
I was very close to the correct solution, so to derive the std::greater<...> from the compare func, just I did it reverse.
Anyway really a 'big' thanks you for the help.
|
|
|
|
|
Hi,
I have the same problem in a project.
As I am a beginner, Could you write your solution; please ?
thank you for you help.
|
|
|
|
|
Yes, of course.
The solution is quite simple, almost trivial, but only if you think "with a microsofter's head".
So the secret is that you, instead of deriving your sorter class from the std::greater<...>, have to derive the std::greater<cyourclass> from your CYourSorterClass, which actually doesn't exists.
to be clear:
so just extend std with the following lines:
<br />
namespace std<br />
{<br />
template<> struct greater<CYourClass*> : public binary_function<CYourClass*, CYourClass*, bool><br />
{<br />
bool operator()(const CYourClass*& x, const CYourClass*& y) const<br />
{<br />
return x->sortbyvalue < y->sortbyvalue;<br />
return x < y;<br />
}<br />
};<br />
}<br />
then sort your list just the same way as it was a 'int' etc...:
<br />
nodes.sort( std::greater<CYourClass*> ( ) );<br />
that's it. I hope I could help.
|
|
|
|
|
|
Newbie question I am afraid.
I want to share a number of common utility classes across multiple projects. These common classes are NOT stable and are still under development.
From the documentation I have read, I am supposed to use the component gallery.
I have created a 'utility' project to hold the source code of my common classes. From this project I can add classes into the gallery.
When I use the add mechanism to include 'common' components from the gallery, the 'common' class is included into the target project.
However a copy of the source files are included into the target project and subsequent changes to the source common class are not reflected in the target project.
Can anybody give me direction on this?
|
|
|
|
|
1- Put all your classes in a directory
2- Add the directory where the clases are in Tools/Options/Directories
3- When you need a class only add the fields in your project.
4- when you include the header make it into tags....
<br />
#include <yourheader><br />
Carlos Antollini
Do you know piFive[^] ?
|
|
|
|
|
Create a 'utility' dll and include it in your project. Mark each exported class like the following:
class AFX_EXT_CLASS MyUtilClass{
}
I use a little script in the prebuild instructions of projects that use common classes that copies the header files and dll/lib into the project.
Hope that at least gets you started. I think there are some alternative articles on the site as well as the previous post.
ed
Regulation is the substitution of error for chance.
|
|
|
|
|
i would like my program to start when a user logs (i use Win2K), but that would be too easy to put a link on the start menu. what is the way to access the windows registry, to write or read inside, and finally, how may i proceed to insert a program in the registry start list.
is there anyone to help please?
TOXCCT
|
|
|
|