Hello,
I am working in VC++ environment.while using gdi+, i want to use a
public member variable of Bitmap. which needs to be initialized at the
time of creation. and i m using this gdi+ in a Dll application. i am
trying to initialize the bitmap object at the constructor. like
Bitmap m-bmpobj; // Bitmap Obj which is a private member of the
TextEffect Class
// TextEffect is the Class name.
CTextEffect::CTextEffect(LPUNKNOWN pUnk, HRESULT *phr)
:bitmap(L"C:\\logo1.bmp")
{
// initializing width and height mem var.
m_nWidth=0;
m_nHeight=0;
}
but the application is not initializing the bitmap with the given file.
because before using gdi+ classes we need to initialize the Gdiplus in
our application with the following two statements.
// Initializing gdi+
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
So, these two statements are to processed before the constructor gets
called. But the constructor is the first function which gets called
when the dll is used.
So Please provide some tips and help to solve this problem.
Waiting for ur reply soon.
vamsi 3 3193
> Hello, I am working in VC++ environment.while using gdi+, i want to use a public member variable of Bitmap. which needs to be initialized at the time of creation. and i m using this gdi+ in a Dll application. i am trying to initialize the bitmap object at the constructor. like
Bitmap m-bmpobj; // Bitmap Obj which is a private member of the TextEffect Class
// TextEffect is the Class name.
CTextEffect::CTextEffect(LPUNKNOWN pUnk, HRESULT *phr) :bitmap(L"C:\\logo1.bmp") { // initializing width and height mem var. m_nWidth=0; m_nHeight=0;
}
but the application is not initializing the bitmap with the given file. because before using gdi+ classes we need to initialize the Gdiplus in our application with the following two statements.
// Initializing gdi+ Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
So, these two statements are to processed before the constructor gets called. But the constructor is the first function which gets called when the dll is used.
So Please provide some tips and help to solve this problem.
Waiting for ur reply soon.
vamsi
Without considering multi-threading:
void init_gdiplus(void)
{
static bool initialized = flase;
if (!initialized)
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput,
NULL);
initialized = true;
}
}
call it in all constructors needing gdiplus resources.
Regards,
Ben
Vamsi wrote: CTextEffect::CTextEffect(LPUNKNOWN pUnk, HRESULT *phr) :bitmap(L"C:\\logo1.bmp") {
.... }
but the application is not initializing the bitmap with the given file. because before using gdi+ classes we need to initialize the Gdiplus in our application with the following two statements.
// Initializing gdi+ Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
So, these two statements are to processed before the constructor gets called. But the constructor is the first function which gets called when the dll is used.
So then execute those statements before the bitmap constructor gets
called. Since you told us no context about this problem, I'm guessing
you have a global variable somewhere so as a lame hack put this above
the definition of it:
int dummy_init()
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
return 0;
}
static int dummy = dummy_init();
....
CTextEffect someProblematicGlobalTextEffect;
Call the gdi+ initialize functions in DllMain() function of dll. This
functions gets called by the Winodws when the dll is loaded in the
memory.
Or you can do the following
CTextEffect::CTextEffect(LPUNKNOWN pUnk, HRESULT *phr)
{
/*---------------------------------
gdi+ intialize code here
-----------------------------------*/
//Bitmap* m_pBitmap
m_pBitmap = new Bitmap( L"C:\\logo1.bmp" );
// initializing width and height mem var.
m_nWidth=0;
m_nHeight=0;
}
Regards This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JKop |
last post by:
Is this them all?:
class Dummy
{
public:
Dummy() {}
Dummy(const Dummy& original) { }
|
by: Thomas Lorenz |
last post by:
Hello,
I'm a little confused about object initialization. According to Stroustrup
(The C++ Programming Language, Special Edition, Section 10.2.3) constructor
arguments should be supplied in one...
|
by: Makis Papapanagiotou |
last post by:
Hello all,
There is a strange case where a class Test is composed from three objects of
other classes. i.e.
class Test
{ public:
Test();
private:
Point x;
|
by: Boni |
last post by:
Dear all,
if I initialize member like this
class A
{
pen _mypen= new pen(...)
}
and class A has 3 constructors will pen be initialized in all of them?
|
by: shu |
last post by:
I get a _CrtIsValidHeapPointer assertion when trying to have a
unmanaged static object linked to my managed project.
I have tried to reduce the problem to a very simple case:
One unmanaged...
|
by: Luke Meyers |
last post by:
Lately I find myself increasingly preferring the practice of going
ever-so-slightly out of my way to avoid the use of the form of
initialization which uses the '=' symbol, on the grounds that it...
|
by: Per Bull Holmen |
last post by:
Hey
Im new to c++, so bear with me. I'm used to other OO languages, where it
is possible to have class-level initialization functions, that
initialize the CLASS rather than an instance of it....
|
by: Jess |
last post by:
Hello,
I understand the default-initialization happens if we don't initialize
an object explicitly. I think for an object of a class type, the
value is determined by the constructor, and for...
|
by: Jess |
last post by:
Hello,
I tried several books to find out the details of object
initialization. Unfortunately, I'm still confused by two specific
concepts, namely default-initialization and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |