|
When I wrote:
Bitmap *p=new Bitmap(w,h);
In debug mode, it reports an error(VC9):
error C2660: 'Gdiplus::GdiplusBase::operator new' : function does not take 3 arguments
Though, I've include mygdiplus.h instead of gdiplus.h .
Here is the content of mygdiplus.h (copied from msdn), what's the problem?
#ifndef _MY_GDIPLUS_H_
#define _MY_GDIPLUS_H_
#define iterator _iterator
#ifdef _DEBUG
namespace Gdiplus
{
namespace DllExports
{
#include <GdiplusMem.h>
};
#ifndef _GDIPLUSBASE_H
#define _GDIPLUSBASE_H
class GdiplusBase
{
public:
void (operator delete)(void* in_pVoid)
{
DllExports::GdipFree(in_pVoid);
}
void* (operator new)(size_t in_size)
{
return DllExports::GdipAlloc(in_size);
}
void (operator delete[])(void* in_pVoid)
{
DllExports::GdipFree(in_pVoid);
}
void* (operator new[])(size_t in_size)
{
return DllExports::GdipAlloc(in_size);
}
void * (operator new)(size_t nSize, LPCSTR lpszFileName, int nLine)
{
return DllExports::GdipAlloc(nSize);
}
void operator delete(void* p, LPCSTR lpszFileName, int nLine)
{
DllExports::GdipFree(p);
}
};
#endif // #ifndef _GDIPLUSBASE_H
}
#endif // #ifdef _DEBUG
#include <gdiplus.h>
#undef iterator
#endif
modified on Wednesday, May 21, 2008 2:48 AM
|
|
|
|
|
See here[^]. BTW, took me 5 seconds to find it with google
|
|
|
|
|
I've followed the advice, but still error in VC9 project.
I've tested using #pragma message , and found that the code after
#ifndef _GDIPLUSBASE_H<br />
#define _GDIPLUSBASE_H
doesn't compile.
I include mygdiplus.h before some other header files, now it works.
modified on Wednesday, May 21, 2008 3:12 AM
|
|
|
|
|
check whether somewhere (may be in " stdafx.h ") <gdiplus.h> is included before "mygdiplus.h".
|
|
|
|
|
No gdiplus.h in stdafx.h , I think it may be included by some header file.
|
|
|
|
|
well, I said may be in stdafx.h, seems you solved now, but then in your previous post you said it didn't work if you include above some other header files.
|
|
|
|
|
|
hai all,
I wrote an application that do some schedule task creation, It works smooth in XP machine, It does not create schedule task in vista,but that i solved by adding the manifest file... My new problem is my application is blocked when it invoked at startup(login or reboot time)...
Pleaser help me if u have any idea ..
Thanks
|
|
|
|
|
After migarating the project to VC9.0, I forgot to initializie for Gdiplus.
====================
CCoolTower::CCoolTower(UINT nIDBmp)
: m_bmp(AfxGetInstanceHandle(),MAKEINTRESOURCEW(nIDBmp))
{
m_rtDev.Width=m_bmp.GetWidth();
m_rtDev.Height=m_bmp.GetHeight();
}
modified on Wednesday, May 21, 2008 4:59 AM
|
|
|
|
|
followait wrote: m_bmp(AfxGetInstanceHandle(),MAKEINTRESOURCEW(nIDBmp))
check why loading of bitmap failed, might not be the constructor issue. move the m_bmp creation statement to normal function (not constructor) and verify why it is failed check the error value. And as a side note, use MAKEINTRESOURCE inplace of MAKEINTRESOURCEW.
|
|
|
|
|
MAKEINTRESOURCE not work, the constructor:
Bitmap(HINSTANCE hInstance,const WCHAR *bitmapName);
In VC6.0 the code;
Bitmap *p=new Bitmap(AfxGetInstanceHandle(),MAKEINTRESOURCEW(nIDBmp));
works fine.
modified on Wednesday, May 21, 2008 3:24 AM
|
|
|
|
|
ok, that's correct, but what about checking the status, Image::GetLastStatus.
|
|
|
|
|
HINSTANCE h=AfxGetInstanceHandle();
m_pBmp=new Bitmap(h,MAKEINTRESOURCEW(nIDBmp));
When debuging into the code, the function below returns NULL:
void * (operator new)(size_t nSize, LPCSTR lpszFileName, int nLine)
{
lpszFileName;
nLine;
return DllExports::GdipAlloc(nSize);
}
|
|
|
|
|
ok, use a temporary variable,
Bitmap bmp(h,MAKEINTRESOURCEW(nIDBmp));
Status gdiSts = bmp.GetLastStatus();
may be GDI+ is not initialized.
|
|
|
|
|
Yes, after migrating, I forgot to initialize GDI+.
|
|
|
|
|
Hi to all
i am using Date Time picker control
at run time i am selecting date and month , and storing this date to somewhere else.
i have one another date & month which is already there in my programme.
then i am comparing both dates , if both dates are not equal then Message Box pops up telling that "stored date & selected dates are not equal "
This is working fine.
But if i select month from the arrow button which is available in calender, then dates are keep on going ,so many message boxs are coming, how can i avoid it ?
or
can i hide that arrow button ?
varun
|
|
|
|
|
what about you compare the date only at DTN_CLOSEUP Notification if you already got DTN_DROPDOWN notification, that is you compare the date only when calender is closed if the calender is opened by the user.
|
|
|
|
|
Hi all,
I want to clean my registry like i want to delete all the items from my registry which are not in use but are occupying spcae. I want to do this through coding....
Can anybody give me any idea to how to do it????
Thanks in advance
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: Can anybody give me any idea to how to do it????
By using the registry API. For example, RegDeleteKey() and RegDeleteValue() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think you would better use a ready registry cleaner as TuneUp or RegCleaner.
The biggest problem is not how to delete the key, the problem is how to identify the keys that are not usefull anymore. Good Luck and don't forget to make backups of your registry before trying your code :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
In VC6.0, the header files are like:
#ifndef _HEADER_FILE_H_
#define _HEADER_FILE_H_
#pragma once // sometimes with this line
...
#endif
In VC9.0 it simplified to this:
#pragma once
Did the semantic of #pragma once changed?
|
|
|
|
|
I believe behaviour of "#pragma once" is not changed. I think that code is written to support older compiler also where "#pragma once" is not supported, unsupported pragma directive is ignored by the compiler. And i can find such coding in MFC headers even in VC8, may be it is reused code from earlier version; search files in MFC include directory for "#pragma once", i think you can still find such code in VC9 also.
|
|
|
|
|
as #pragma directives are compiler specific, they may not work with another compiler. Of course, if your only compiler is Visual C++, you don't really have to care about.
but if you wish to be portable, then you have to go with #ifndef stuff...
|
|
|
|
|
Hi,
Hope somebody can help me with this one.
I want to capture pressing "[" and "]" on OnKeyDown() event.
For controls like shift
if(VK_SHIFT)
For capturing letters, I use example pressing s.
if(nChar=="s")
but for other keys like "[", "]" and numerics
it's not applicable.
How can i capture other keys?
|
|
|
|
|
TooShy2Talk wrote: For capturing letters, I use example pressing s.
if(nChar=="s")
you mean if (nChar == 'S') but you should always use Virtual Key codes, because nChar is the virtual key code, capital letter is identified by the Shift/caps key status. you may refer the list of key codes [Virtual-Key Codes ^] to use in your code.
TooShy2Talk wrote: but for other keys like "[", "]" and numerics
for numbers you may use '0'(30) - '9'(39) or VK_NUMPAD(0 - 9) because number can be entered in two different keys num pad and other above characters.
"[" can still be identified by VK_OEM_4 by Virtual-Key Codes but depends on keyboard layout. so it is better to use [VkKeyScan(Ex)^] to convert character to virtual key code and compare,
SHORT iSqrBracketOpen = VkKeyScan(_T('['));
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == iSqrBracketOpen)
{
MessageBox(_T("Open Square Bracket"));
}
...
}
or use [ToAscii(Ex)^] or ToUnicode(Ex) to convert virtual key code to character and compare.
|
|
|
|