|
Do you want to save shapes on device context in a graphic file like bmp,right?
|
|
|
|
|
|
If you have a hbitmap handle one easy way is use CImage class you attach this handle to this class and use of CImage::Save for save graphic file(bmp/jpg,etc)
|
|
|
|
|
Hello guys
I have a question: remember SpecialFX? Great water effect in images ....
Well, i wanna put this effects in my source in MASM (Macro Assembler).
Is possible using .obj? How can i call function? mangled names?
Tnx a lot.
|
|
|
|
|
I checked msdn, and got this
"Objects and variables declared as static retain their values for the duration of the program’s execution"....
but still don't know what is exactly the difference between declaring "int a" and "static int a", what is the difference when using them?
|
|
|
|
|
One difference is that a static variable is assigned a memory address before the applications code executes. A local variable is not pushed onto the stack until that function is entered.
led mike
|
|
|
|
|
int i
your variable will be created when the execution reaches this line, and it will be destroyed when leaving the scope.
static int i
your variable will be created when the program starts (whereever the statement is placed) and will be destroyed when the program exits.
|
|
|
|
|
again, I am still confusing...
is that
int i:
it will be ready when you start use it
static int i:
it will be ready long before you use it
So what's the use of the latter occasion? Since I don't use it, why should I care when it is created.
|
|
|
|
|
static has another meaning. when you declare a variable local to a function as static, then is keeps its last value :
void foo() {
static int i = 0;
i++;
printf("%d\n", i);
}
void main() {
for (int n = 0; n < 5; n++) {
foo();
}
}
this prints :
1<br />
2<br />
3<br />
4<br />
5
another meaning is when you declare a class data member as static. this means that the member is shared between every instances of the class. this is useful when you want a member to be unique, like an instances counter, class constants, etc...
the last meaning is when declaring a class member function as static. it will tell that the function is a class function ; it doesn't know a particuliar instance (no this pointer), it performs general operations...
|
|
|
|
|
bloodwinner wrote: again, I am still confusing...
is that
int i:
it will be ready when you start use it
static int i:
it will be ready long before you use it
So what's the use of the latter occasion? Since I don't use it, why should I care when it is created.
Imagine a function that animates something on the screen. Each call to the function updates the phase of the animation by using a counter to determine what's displayed. To this end you need an int as the counter and you declare it inside the function rather than having your primary program pass the counter to the function. If you declare the int as non-static but you increment the int each time you enter the function the value of the int goes away because the variable was created on the stack when the function began and it was removed when the function ended.
If you declare the int as static, whatever value it had on exit from the function is the value it will have when you call the function again because the variable was created before the program began execution and will not be destroyed until the program ends.
Lilith
|
|
|
|
|
A Static variable has a global scope. So if the value of static variable changed, that change will occur where ever the static variable is used.
Akkott
|
|
|
|
|
|
Hi,
Can any tell me the internal working of the try/catch block in C++.
Thanks.
|
|
|
|
|
|
when i run MFC and MySQL
By Victor M. Valenzuela.
MFC classes to fill ComoBoxes & ListBoxes with MySQL data.
then it gives following error, i am not able to trace out this error,
as far as i am concerened here two files are conflicting.
how to avoid this conflicting problem.
i am solving this problem from last 4 days, but i didn't found any clue about this problem.
please tell me the solution i am very needy.
Linking...
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char=""> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char=""> > &,char const *)" (??6std@@YAAAV?$basic_ostream@DU?$cha
r_traits@D@std@@@0@AAV10@PBD@Z) already defined in mysql++.lib(manip.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char=""> >::~basic_ios<char,struct std::char_traits<char=""> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined
in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char=""> >::~basic_streambuf<char,struct std::char_traits<char=""> >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ
) already defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(void)" (??1?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in mysql++.lib(connection.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(class std::basic_string<c
har,struct std::char_traits<char="">,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in mysql++.lib(connection.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(class std::allocator<char
> const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$allocator@D@1@@Z) already defined in mysql++.lib(connection.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall std::basic_iostream<char,struct std::char_traits<char=""> >::~basic_iostream<char,struct std::char_traits<char=""> >(void)" (??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ) a
lready defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_iostream<char,struct std::char_traits<char=""> >::basic_iostream<char,struct std::char_traits<char=""> >(class std::basic_streambuf<char,struct std::char_traits<char=""> > *)" (??0?$b
asic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z) already defined in mysql++.lib(sql_query.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Q
BEPBDXZ) already defined in mysql++.lib(connection.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: char & __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::operator[](unsigned int)" (??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEA
ADI@Z) already defined in mysql++.lib(field_names.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in mysql++.lib(sql_query.obj)
libcp.lib(iostream.obj) : error LNK2005: "public: __thiscall std::ios_base::Init::Init(void)" (??0Init@ios_base@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(iostream.obj) : error LNK2005: "public: __thiscall std::ios_base::Init::~Init(void)" (??1Init@ios_base@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(iostream.obj) : error LNK2005: "public: __thiscall std::basic_ostream<char,struct std::char_traits<char=""> >::basic_ostream<char,struct std::char_traits<char=""> >(class std::basic_streambuf<char,struct std::char_traits<char=""> > *,bool,bool)" (?
?0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale.obj) : error LNK2005: "public: __thiscall std::_Locinfo::_Locinfo(char const *)" (??0_Locinfo@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale.obj) : error LNK2005: "public: __thiscall std::_Locinfo::~_Locinfo(void)" (??1_Locinfo@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale0.obj) : error LNK2005: "public: class std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned int,bool)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I_N@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale0.obj) : error LNK2005: "public: bool __thiscall std::locale::_Iscloc(void)const " (?_Iscloc@locale@std@@QBE_NXZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(ios.obj) : error LNK2005: "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(ios.obj) : error LNK2005: "public: virtual __thiscall std::ios_base::~ios_base(void)" (??1ios_base@std@@UAE@XZ) already defined in msvcprtd.lib(MSVCP60D.dll)
libcp.lib(ios.obj) : error LNK2005: "protected: void __thiscall std::ios_base::_Init(void)" (?_Init@ios_base@std@@IAEXXZ) already defined in msvcprtd.lib(MSVCP60D.dll)
LIBC.lib(strtol.obj) : error LNK2005: _strtol already defined in msvcrtd.lib(MSVCRTD.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
LIBC.lib(atox.obj) : error LNK2005: _atoi already defined in msvcrtd.lib(MSVCRTD.dll)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in LIBC.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/DlgMySql.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
mee
|
|
|
|
|
you are mixing C/C++ runtime libraries.
make sure all libraries that link into your final EXE are using the same C/C++ RTL . check this in Project/Settings/General (Microsoft Foundation Classes) and Project/Settings/ C/C++ / Code Generation / Use Runtime library.
|
|
|
|
|
CString Convert to LPCTSTR
i write DLL file,it is static dll
i want CString type Convert to LPCTSTR
but error
Code:
<<<<<<<<<<<dll file="">>>>>>>>>
<<<<<<<a.h>>>>>>>
class AFX_NOVTABLE dll
{
public:
__declspec(dllexport) LPCTSTR Fun();
};
<<<<<<<a.cpp>>>>>>
LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
<<<<<<<<exe>>>>>>>>>
#pragma comment(lib,"dll.lib")
#include "A.h"
..................
dll d;
LPCTSTR b=d.Fun();
error,why
thank
|
|
|
|
|
rxgmoral wrote: error,
what it states ?
|
|
|
|
|
CString has an operator for casting to LPCTSTR. There is no need to write code to do it, it is already done for you.
On top of all that, you are creating a memory leak while trying to duplicate code that is written for you.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
rxgmoral wrote: LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
you return a local pointer...
|
|
|
|
|
rxgmoral wrote: LPCTSTR lpszStr=Rxg.GetBuffer();
If you aren't going to be modifying the contents of Rxg , there's no need to call GetBuffer() .
rxgmoral wrote: error,why
Don't know.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
1. First, you have a CString which is only temporary. When Fun() ends, the CString object will be destructed.
2. As has been pointed out, GetBuffer() isn't needed, since there's a perfectly good cast operator for LPCTSTR.
3. As written, the temporary CString (Rxg) will get locked by GetBuffer(). This will no doubt cause problems when the temporary is destructed, since the CString data is now locked.
To get string data back from the DLL function, you could pass in a destination buffer and size as parameters, and after checking size, you can then fill in the string. To retain the semantics of Fun(), have it return the address of the destination buffer (although the parameter should be LPTSTR, not LPCTSTR).
Steve S
Developer for hire
|
|
|
|
|
rxgmoral wrote: LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
better you make memory in heap before sending it outside of function.. though getbuffer create the memory in heap.. but it need subsequent call of releasebuffer for releasing the memory.. which is rather difficult from out side better would be....
LPTSTR lpszStr=new TCHAR[Rxg.GetLength()+1];
lstrcpy(lpszStr,Rxg);
return lpszStr;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
if you want to use GetBuffer then call ReleaseBuffer
|
|
|
|
|
|