|
I have a wierd situation. I have a MFC based dialog application that loads dynamically an MFC dialog based dll.
If I build the application in release mode and try to load the debug mode dll the application crashes. Likewise if I build the application in debug mode and load the release mode dll the application crashes.
Any ideas why?
Steve
|
|
|
|
|
Hello!
Most probably (for sure) it is because of different memory allocators in release and debug version. Also, there might be problems with alignment (though I do not suspect that you have different alignment in debug and release).
Does it work in both debug and both release?
|
|
|
|
|
Yes, it works fine with either both in debug or both in release.
Both make use of threads if that could have anything to do with it.
What do you mean by different memory allocators?
I will have to look into this alignment issue. I changed several things in the process of
learning to get plug-ins working and everything else working as well.
Oh, I am using a GDI+ header helper file that I believe I found on codeproject that does some strange things to fix some memory issues.
Thanks,
Steve
#ifndef _GDIPLUSH_H_INCLUDED_
#define _GDIPLUSH_H_INCLUDED_
//
// GDI+ helper file v1.0
//
// Written by Zoltan Csizmadia (zoltan_csizmadia@yahoo.com)
//
// GDIPLUS_NO_AUTO_INIT:
// GDI+ won't be initialized at program startup,
// you have to create GdiPlus::GdiPlusInitialize object to
// initialize GDI+ ( GDI+ will be uninitialized, when destructor
// is called.
#define GDIPLUS_NO_AUTO_INIT
// GDIPLUS_USE_GDIPLUS_MEM:
// GdipAlloc and GdipFree is used for memory operations
// In this case _Crt functions cannot be used to detect
// memory leaks
//#define GDIPLUS_USE_GDIPLUS_MEM
// GDIPLUS_NO_AUTO_NAMESPACE:
// Gdiplus namespace wont' be defined as a used namespace
// In this case you have to use Gdiplus:: prefix
//#define GDIPLUS_NO_AUTO_NAMESPACE
#ifdef _GDIPLUS_H
#error Gdiplus.h is already included. You have to include this file instead.
#endif
// Fix for STL iterator problem
#define iterator _iterator
#define list _list
#define map _map
#define _GDIPLUSBASE_H
namespace Gdiplus
{
namespace DllExports
{
#include "GdiplusMem.h"
};
class GdiplusBase
{
public:
#ifdef _DEBUG
static void* __cdecl GdiplusAlloc( size_t nSize, LPCSTR szFileName, int nLine )
{
#ifdef GDIPLUS_USE_GDIPLUS_MEM
UNREFERENCED_PARAMETER(szFileName);
UNREFERENCED_PARAMETER(nLine);
return DllExports::GdipAlloc(nSize);
#else
return ::operator new( nSize, szFileName, nLine );
#endif
}
static void GdiplusFree( void* pVoid, LPCSTR szFileName, int nLine )
{
#ifdef GDIPLUS_USE_GDIPLUS_MEM
UNREFERENCED_PARAMETER(szFileName);
UNREFERENCED_PARAMETER(nLine);
DllExports::GdipFree(pVoid);
#else
::operator delete( pVoid, szFileName, nLine );
#endif
}
void* (operator new)(size_t nSize)
{
return GdiplusAlloc( nSize, __FILE__, __LINE__ );
}
void* (operator new[])(size_t nSize)
{
return GdiplusAlloc( nSize, __FILE__, __LINE__ );
}
void * (operator new)(size_t nSize, LPCSTR lpszFileName, int nLine)
{
return GdiplusAlloc( nSize, lpszFileName, nLine );
}
void (operator delete)(void* pVoid)
{
GdiplusFree( pVoid, __FILE__, __LINE__ );
}
void (operator delete[])(void* pVoid)
{
GdiplusFree( pVoid, __FILE__, __LINE__ );
}
void operator delete(void* pVoid, LPCSTR lpszFileName, int nLine)
{
GdiplusFree( pVoid, lpszFileName, nLine);
}
#else // _DEBUG
static void* __cdecl GdiplusAlloc( size_t nSize )
{
#ifdef GDIPLUS_USE_GDIPLUS_MEM
return DllExports::GdipAlloc(nSize);
#else
return ::operator new(nSize);
#endif
}
static void GdiplusFree( void* pVoid )
{
#ifdef GDIPLUS_USE_GDIPLUS_MEM
DllExports::GdipFree(pVoid);
#else
::operator delete( pVoid );
#endif
}
void* (operator new)(size_t nSize)
{
return GdiplusAlloc( nSize );
}
void* (operator new[])(size_t nSize)
{
return GdiplusAlloc( nSize );
}
void (operator delete)(void* pVoid)
{
GdiplusFree( pVoid );
}
void (operator delete[])(void* pVoid)
{
GdiplusFree( pVoid );
}
#endif
};
};
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <Gdiplus.h>
#ifdef _DEBUG
#undef new
#endif
#pragma comment (lib, "Gdiplus.lib")
namespace Gdiplus
{
class GdiPlusInitialize
{
public:
GdiPlusInitialize()
{
GdiplusStartupInput Startup;
GdiplusStartup( &m_Token, &Startup, NULL );
}
~GdiPlusInitialize()
{
GdiplusShutdown( m_Token );
}
protected:
ULONG_PTR m_Token;
#ifndef GDIPLUS_NO_AUTO_INIT
static GdiPlusInitialize m_Initialize;
#endif
};
#ifndef GDIPLUS_NO_AUTO_INIT
GdiPlusInitialize GdiPlusInitialize::m_Initialize;
#endif
}
#ifndef GDIPLUS_NO_AUTO_NAMESPACE
using namespace Gdiplus;
#endif
// STL problem
#undef iterator
#undef list
#undef map
#endif
|
|
|
|
|
Hello!
"What do you mean by different memory allocators?"
In debug build, memory allocator allocates for example guardians (additional bytes before and after allocated block of memory). Guardians are used to detect memory overwrites.
Generally, there are a lot of differences between allocating memory in release and debug version. See msdn for more details
|
|
|
|
|
Hi all,
I want to write a usb serial device driver for WinXP.
Would any expert here can give me some help?
e.g. source code, document, etc....
Thankyou very much.
Kent
|
|
|
|
|
I am definately no expert, but Microsoft has a driver development kit (ddk). You may be able to do something with that.
|
|
|
|
|
Hi!
I'm using CDialogSK and I have built a skinned dialog.
Now I want to use Child Dialogs in it, but I don't want the grey background... I tried to use CDialogSK in my child dialog class, but it doesn't work.
Either I wan't to use a small bitmap as the background, or if that doesn't work - atleast have the child dialog transparent so I can just see my controls in the child...
Would this be possible?
Thanks
|
|
|
|
|
I dont understand your 100% problem but I guess I did some familar thing some time ago. It was a SplashScreen with Transparency and Controls
(used the CDialogSK class). the problem was, I cant use childwindows because the got the same attributes
from the SetLayeredWindowAttributes call.
So I must create some popup windows and move
them arond if the parent dialog moves.
|
|
|
|
|
I realize this sounds idiot, but how do you <subj>?? I can't find any main() or wmain() function in my project and can't acces any argc or argv.
I tried to acces them anyway but they are undefined.
Searching through the SDK I only found 2 functions:
GetCommandLine();
CommandLineToArgvW
First one seems to work but the second I couldn't convince to work. And I surely tried. Simply hates me.
Does anyone have any ideea,
HOW CAN I READ THE COMMAND LINE ARGUMENTS IN AN ARRAY OR SOMETHING SIMILAR TO ARGC AND ARGV?
TIA!!
|
|
|
|
|
Check here[^].
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
|
search for CCommandLineInfoEx in the MSDN
there is some code from
Microsoft Systems Journal -- October 1999
Paul DiLascia.
the class is realy nice to use.
|
|
|
|
|
I am looking for simple and powerful way of displaying string messages by using CString class, , on a simple console or a text display window for program progress and debug purposes. Is there any extentions of CString class to do that and any example codes to learn and apply it in my own code ?
|
|
|
|
|
|
Thanks alot for your immediate answer
CD
|
|
|
|
|
I tried TRACE macro but this is not the one I'm looking for I would like to manipulate strings using io operators and showing the string to trace the progress of my program. This function also displays the output in the debugger output window but I would like to prefer in a separate or a MFC view window. İs it possible to find such a display class ?
CD
|
|
|
|
|
|
Thanks again, I guess this will work for me, and I would like to know How I can implement a console output which works like a progress, that is, I want to show many lines of progress string but I want to overwrite the new line on the previous line output thereby avoiding the many console output lines, as in the case of running it inside a loop code.
CD
|
|
|
|
|
well, it sounds like you're 'at odds with' / only have a vague idea of what you really want or need - how about you do some some 'functional analysis' .. if what you want is really that simple, what about a single line static text control that you update when required ? - a single line console doesnt really make much sense ...
It is possible to do more with consoles, and there are articles on the web and here on CP which show you these techniques
- the last thing I'll say, is what I commonly end up using if I need info relayed back to a user on various things and/or debugging info for my own purposes, is a derivative of this ->
http://www.codeproject.com/listctrl/logcontrol.asp[^]
'G'
|
|
|
|
|
Thanks for your valueable ideas, and sorry for my simple and boring questions. But you saved my hours of time to be wasted by searching web.
CD
|
|
|
|
|
Is C++ harder than PHP... I know php but I want to learn it...
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
It all depends on what your "definition" of hard is. Some folks find it harder than other programming languages and vice versa.
|
|
|
|
|
Hello!
C++ is easy :P
php is very similar to plain C. C++ is far more complicated in its nature, but you do not have to learn whole language to be able to write something. But for sure, php is simpler subject than c++.
|
|
|
|
|
Hello,
I am looking for a way to detect the system's color palette( On XP color quality). This is setup on the Display Properties at the settings tab. I need to know if the computer is running using "16 Color", "255 Color", "16 Bit" and so on. Any ideas?
|
|
|
|
|