|
If you ever download the VS6 samples, about 100megs from msdn, it has a lot of cool things... including wordpad yes the 95 version although there is no difference, lol with the new and old one (95 and xp)... to find this, open the c++ documentation go to mfc samples, go to mfc ole samples and out of the list should be displayed wordpad, yes with all the source code, you can compile it, alter it... unless windows made it so if it is changed it will report you, jk . neat little things can be found by looking at and remembering old stuff.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Hello everyone:
I want to transfer a function pointer from a wtl project to a MFC dll.
Do I need to make the function as a callback function?
How to do?
If having some sample code, please email to me .
Thank you.
-Freehawk.
|
|
|
|
|
Hi guys, I do need your suggestions.
In document based MFC application, there is a menu item “ID_FILE_OPEN”. When you press it, it will run cWinApp::OnFileOpen.
Now, I have a dialog based MFC application. I want to add a button to achieve above function. When I press the button, it can open a file explorer or file manager.
By the way, this MFC application doesn’t have StdAfx files.
What I should do?
|
|
|
|
|
Add an event handler for the button click event. Then use the CFileDialog class to prompt the user to select a file to open. From here it depends on how you have the data saved (serialized). You will have to supply your own file reading function. You can use the CFile class to open and read the file data or the ansi fopen, fread functions.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
allrighte... If I get it, you want a button that will do exactly as if you'd press file->open?
Simple: create that button, then set its ID at ID_FILE_OPEN. It's that simple...
again.. I hope I got it right..
HTH,
Andrei.
|
|
|
|
|
I have a small dialog-type MFC App
In order to not exit the app if I press ESC or Enter I wrote this:
void CVariantDlg::OnOK(){}
void CVariantDlg::OnCancel(){}
In other words I overloaded the functions OnOK() and OnCancel(). It worked! Now I can press ESC or Enter and the app won't close.
My problem is that even if I hit ALT-F4 or right-click it on the taskbar and choose close or hit the x button in the right side of the title bar it won't close!
This sucks. I guess I should check to see what are the latest keys pressed and choose from that point on.
BTW: How did you call the original function from the overloaded version of it?
Anyways... what do you recommend me in order to have the application exit on:
a) X button from title bar
b) ALT-F4
c) Close from the system menu / taskbar rightclick and "Close"
But not:
a) ESC
b) ENter
? TIA!
|
|
|
|
|
Let the user use ESC or Enter, after all that is what most user will expect.
Otherwise you could probably use GetKeyState() to determine which key was pressed, so you can decide when to allow box to close.
INTP
|
|
|
|
|
THANKS!
It worked!
If GetKeyState(VK_ESCAPE) is -127 or -128 then the user pressed ESC and I will NOT exit the app. Otherwise yes.
|
|
|
|
|
Try to leave OnOK and OnCancel like before,
just overload OnClose function like this :
OnClose
{
CDialog::OnOK();
}
rrrado
|
|
|
|
|
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
|
|
|
|