|
Hi,
I have created an SDI application. The View of my application has an ::OnCommand handler in order to catch a message from an external engine. At some point in the …::OnCommand handler of my View, I call a Modal dialog which also has an …::OnCommand handler in order to be able to catch the subsequent same-type of messages from the external engine. The Modal Dialog is called and displayed but the subsequent messages from the external engine are still caught by the ..:OnCommand handler of my View and not from the corresponding handler of my Dialog. Is it possible to, somehow, de-activate the handler of the View once the Dialog is displayed, so as the subsequent messages from the engine to be serviced by the …:OnCommand handler of my Dialog?
I thank you in advance and I hope you have a nice day,
Christos P.
|
|
|
|
|
You know how you see some programs where all the text in the edit box scrolls the text automatically and without scroll bars on the side?
How do I do that in an MFC application?
If you can help, Id appreciate it alot!!
Thanks
Ashman
|
|
|
|
|
Tick the box that says autoscroll in the dialog editor, in the properties for the edit control.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
or do you mean like a scrolling credits window thingie?
if so theres a couple here on codeproject in one of the sections (cstatic i think)
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Yeh, where the text goes from the top to the bottom at a set speed like you see in some Nukes, Hacking progs, etc?
What projects are there on Codeproject, can you get an URL for me plz?
Thanks
Ashman
|
|
|
|
|
I'm a junior WTL Programer.
I want to know how to use CList and CArray in my WTL code.
Thanks in advance
|
|
|
|
|
CList and CArray is MFC not STL....
I dunno how to use both MFC and WTL in the same project...
- Anders
|
|
|
|
|
If you really want the STL classes, use list<> and vector<>. As already stated, CList and CArray are MFC.
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
|
A prooject I have inherited at work uses MFC extension DLLs which contain Dialog classes. The DLLs are loaded using AfxLoadLibray.
The overall build environment was set up under Win95 DOS using GNU tools with a BASH shell. When building the Japanes version of the program the only thing that is different is the RC with the Japanese strings. However, the release build of only ONE DLL results in a faulty DLL which fails at the LoadLibray point. If I rebuild the DLL using Visual Studio it is fine. If I copy the OBJ and RES file across and let the Make file link them the DLL is fine. Debug builds are fine. I am at a loss where to look.
The reason make was used is because a large amount of the code is generated using Awk, parsing an export from an Access database.
ANY suggestions will be welcome.
Happy programming!!
|
|
|
|
|
if(lpCacheEntry->CacheEntryType&URLHISTORY_CACHE_ENTRY)
{
if (strstr(lpCacheEntry->lpszSourceUrlName,"http") != NULL)
{
times = new CTime(lpCacheEntry->LastAccessTime);
if (strcmp(times->Format("%Y/%m/%d/%H%M%S"),Last_Connect) > 0 )
{
fprintf(fp,"%s;%s;%d\n",strstr(lpCacheEntry->lpszSourceUrlName,"http"),times->Format("%Y/
m/%d/%H%M%S"),lpCacheEntry->dwHitRate);
strcpy(temp,strstr(lpCacheEntry->lpszSourceUrlName,"http"));
strcpy(tmp,"http://");
strcpy(temp,temp+7);
strcat(tmp,strtok(temp,"/"));
fprintf(fp,"%s;%s;%d\n",tmp,times->Format("%Y/%m/%d/%H"),lpCacheEntry->dwHitRate);
nCount++;
}
lpCacheEntry->dwHitRate = 0;
SetUrlCacheEntryInfo(lpCacheEntry->lpszSourceUrlName, lpCacheEntry, CACHE_ENTRY_HITRATE_FC);
}
}
delete[] lpCacheEntry;
what's this?
|
|
|
|
|
Hello all!
Does anyone know how I can determine (on Win NT4, Visual C++) the application (executable file name including the path) that is registered to a document?
I just need the application name, I do not want to spawn a process with ShellExecute. The way I'm doing it right now is calling the 'GetClassFile(FileName, &ClsID)' method and then searching for the matching registry entry.
This works fine for most file types but it fails for example for '.txt'-files. 'GetClassFile(...)' returns 'MK_E_INVALIDEXTENSION' in this case although '.txt' is registered...
I'm sure the solution must be a very obvious one, can someone give me a hint on this?
Chris
|
|
|
|
|
Serendipitous - was just perusing DiLascia's latest, where he mentions FindExecutable .
|
|
|
|
|
Hi any 1 out there
I have a problem and it is so interesting to me...
Ok here it comes
IDE: VC++ 5.0
Project: A simple console application that compresses files using LZW algorithm...(It has to be Win32)
Problem(s)
Project Setting: Win32 Debug >> Everyhing is OK.App. is slow but fine.
Project Setting: Win32 Reelase Optimization : Default >> Hmm...Memory Access Violation error!!! And app. is down...
Project Setting: Win32 Reelase Optimization :Maximize Speed >> No memory access error but the compressed file is ooo 22 bytes.It doesn't matter whether src file is 2M or 2K it is still 22 bytes ??
Thanx....
|
|
|
|
|
Hi any 1 out there
I have a problem and it is so interesting to me...
Ok here it comes
IDE: VC++ 5.0
Project: A simple console application that compresses files using LZW algorithm...(It has to be Win32)
Problem(s)
Project Setting: Win32 Debug >> Everyhing is OK.App. is slow but fine.
Project Setting: Win32 Reelase Optimization : Default >> Hmm...Memory Access Violation error!!! And app. is down...
Project Setting: Win32 Reelase Optimization :Maximize Speed >> No memory access error but the compressed file is ooo 22 bytes.It doesn't matter whether src file is 2M or 2K it is still 22 bytes ??
Thanx....
|
|
|
|
|
Well, there are many assumptions an optimizer must make. And while there are indeed bugs in the optimizer, chances are you are depending on some side effect in your code that gets optimized away.
What you need to do is isolate your code down to the smallest possible reproduceable case and then post it, perhaps we can help.
|
|
|
|
|
Hello everybody,
I am writing an circular queue buffer utility .when u are using createFileMapping Apis we specify the size of memory .. I have specified it to 30MB and I am writing and reading from the file and deleting it from it . these operations are done in FIFO .Now after couple of deletes and Number of write operations assume that it reaches the end of the file .. I need to go to top of the file and fill in the gaps . Now my question how will i know whether I have reached the end of the file ...
thanks in advance
|
|
|
|
|
are u writing sequentially to the file (ie, like playing a sound file from a circular buffer) or are u writing randomly?
sequentially is easier as you can just check how many bytes u have written and when you hit 30Mb zero the index or reset the pointers
random writing requires that you keep an upper and lower bound pointer and check for when u are about the exceed the upper limit ... then switch it to the lower limit
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I've come across an oddity recently where an app that links MFC dynamically, along with some third party DLL's, happens to load both the debug version and the release version of MSVCRT. According to Dependacy Walker, MSVCRTD.DLL is loaded on behalf of my app and MSVCRT.DLL is also loaded on behalf of a third party DLL. I'm asking the question because I'm trying to track down a bug that only happens with the debug version of the app, but the release version does not exhibit the bug at all. So far this is the only difference between the two releases that I can dig up.
Anyone with some experience in mxing debug with release?
Thanks.
Chris Meech
|
|
|
|
|
its wierd to see how an app can load a debug version of the dll without either being a debug build or explicitly loading the debug dll ... are the 3rd party dll's not causing the debug dll to load?
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Sorry if I was unclear, but it is Dependancy Walker that is showing me that for the DEBUG version of my app that both the DEBUG and RELEASE versions of the MSVCRT DLL will be loaded. I'm not sure whether that actually happens in practice, nor if it is even a problem! But I was just wondering because at the moment it is the only difference between the debug and release version of my app that I can figure out.
Thanks for the reply and I like your sig
Chris Meech
|
|
|
|
|
Yes, don't do it.
Mixing the two, you end up with two different heap managers. MFC uses all kinds of tricks to get around the module heap limitations, and you've now created two different kinds of memory. What happens when your debug code tries to delete memory allocated by the release manager? You might as well try to guess how Buddy Hacket will look in a singularity with better success
Contact your library vendor and request a debug version of their DLL, or else enable debugging information in the release mode and debug that way. You will be chasing your tail for no reason otherwise.
|
|
|
|
|
Thanks Eric. I read into your words that I am likely creating an environment where all kinds of odd and unpredictable behaviour will occur. I get enough of that at home with my teenage kids, so I don't need anymore here at work
Chris
|
|
|
|
|
Hi Chris,
If you look under the hood, you'll see that for Release MFC/MSVCRT that
new calls malloc() and delete calls free().
For Debug MFC and MSVCRT all calls to malloc() and free() actually go to malloc_dbg()
and free_dbg(). Since malloc and malloc_dbg() are exported functions they are only accessible via the jump table in the IAT of your DLL that is linked to MFC42uD.DLL (or MFC42D.DLL if you are MBCS). The import library will indicate that it wants MFC42uD.DLL or MFC42.DLL and will not resolve to the incorrect DLL (ie if it wants the release on it won't link against the debug one).
So that being the case it is pretty hard to call the release malloc() if you know you linked against the debug malloc(). If you want to try, put a breakpoint on a call to
new/malloc or free/delete and drop into assembly level and walk the calls, you can
tell very quickly if you ended up in the release or debug dll (for a start the source code only comes up in the debug dll as there is no debug info in the release dll to main to the release CRT source code that MFC ship.).
You should also note that many big name tools, such as Purify, will report that your program is using both MSVCRTD.DLL and MSVCRT.DLL at the same time. Why do they do this?
Your program is debug, so that explains MSVCRTD.DLL. Their program (the one that has
been injected into your program to inspect it) is almost certainly release code(*),
which explains MSVCRT.DLL. So why would they do that? The reason is that:-
a) Microsoft forbids the redistribution of DEBUG dlls.
b) The performance gains of using the release DLLs and the knowledge that an ASSERT
(that may just be a warning, not a genuine problem) can't come up.
As long as their program never mixes its calls up and always calls its MSVCRT.DLL
then it will be OK. So there are occasions when it is OK, but as other posters here
have noted, usually it is NOT ok.
It sounds like the 3rd party dll may be incorrectly assuming any memory that is passed to it to manage is always 'release mode' (for want of a better term) memory. In that case you are out of luck.
The memory management for DEBUG is pretty straightforward. The source code is in the MFC directory and implements its own linked list manager with a lot of overhead to
allow you to track it. It grabs larger chunks using HeapAlloc on a private heap.
The Release memory management consists of a small block heap, implemented in a way
that will not map in any way to the DEBUG memory management. For larger blocks
(greater than the value returned by sbh_get_threshold(), typically 0x03f8) the release
manager goes to HeapAlloc() in a private heap. Consult sbheap.c and winheap.c for
more details.
Hope this is some use. Any chance of naming the vendor/dll?
Stephen Kellett
|
|
|
|
|
I disagree. It's quite easy to call the wrong malloc or free. For instance, if you are in debug, and you link to a release DLL. If that DLL allocates memory and returns it to your debug application, and your debug application frees that memory itself, you get major problems.
Another problem, especially with MFC, is that the size of objects can change between debug and release, thus if you allocate an object in release, but use it debug, it's going to assume a different memory layout. You might be using something like Stingray's ObjectiveToolkit, that implements it's own MFC derived classes in a DLL, for instance. In debug, the objects include dump information and additional functions. This can cause page faults or other nasty problems.
|
|
|
|