|
Matt Newman wrote:
cannot convert parameter 1 from 'CString' to 'const char *'
That tells me you're doing a Unicode build. CString has an LPCTSTR converter, which is a Unicode string in Unicode builds. Since you need a single-byte string, you'll need to convert it. The quickest way is an ATL conversion macro.
#include <atlconv.h>
{
USES_CONVERSION;
CString strDest = _T("192.168.0.6");
...
dwForwardDest = inet_addr( T2CA((LPCTSTR)strDest) );
}
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
T2CA
DOH! I with I knew about this several months ago. I know how to do it manually, but this is much, much easier.
|
|
|
|
|
I tell you all higher education does is makes you for get the UNICODE/MBCS conversion macros Thanks for the help!
- Matt Newman / Windows XP Activist
"Well, the guy that's giving you a hard time is a f***in moron, and you can tell him thats straight from another Linux user." - John Simmons on Linux Users Just do the American thing and shoot him... - Jim Crafton on Linux Users Wh3n my l33t skillz 1mpr0v3, I w1ll h4ck M$, 4nd th3n wh0 w1ll b3 l4ugh1ng ? N0t Bill. H4 h4 h4 h4 h4 h4 h4. - Christian Graus
|
|
|
|
|
thanks a lot !
|
|
|
|
|
hi
is there any simple way to load images such as BMP or Gif or any other formats from Resources and NOT FROM THE FILE using GDI+ .
for example i include a bitmap in Resource .how can i Load it in my project that project.EXE don't need that picture file anymore.
regards
|
|
|
|
|
Bitmap::FromResource()
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
i use this code line but it's not work . what is wrong with me?
<br />
Graphics graphics(dc.m_hDC);<br />
<br />
graphics.DrawImage(Bitmap::FromResource(AfxGetInstanceHandle(), L"IDB_BITMAP1"),0,0,400,400);
|
|
|
|
|
Use passing the string "IDB_BITMAP1" instead of the numeric value of IDB_BITMAP1.
Bitmap::FromResource ( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1) )
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
i did my best but this error occures again :
cannot convert parameter 2 from LPSTR to Const WCHAR *
how can i fix this
|
|
|
|
|
Your problem has to do with the fact that GDI+ uses all wide character strings (UNICODE) so you have to convert all strings passed to GDI+ functions to wide characters.
#include <afxpriv.h>
...
USES_CONVERSION;
Bitmap::FromResource ( AfxGetResourceHandle (), T2W ( MAKEINTRESOURCE (IDB_BITMAP1) ) );
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Actually, that's not correct in this case. MAKEINTRESOURCE just expands to a cast, it doesn't create an actual string. So that code will probably crash or give incorrect results when something that isn't a string is passed to T2W .
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Bitmap::FromResource ( AfxGetInstanceHandle(), (LPCWSTR) MAKEINTRESOURCE(IDB_BITMAP1) )
The cast to (LPCWSTR) is the correct way in this case due to the way the APIs handle resource IDs. All resource ID parameters are strings, usually LPCTSTR , because a resource ID can be either a real string or a number. When you pass a numeric ID, you use the MAKEINTRESOURCE macro to convert it to a string - the macro just expands into a cast to LPCTSTR .
The problem with GDI+ is that its functions take LPCWSTR parameters. Since I assume you're doing an ANSI build, MAKEINTRESOURCE casts to LPCSTR , not LPCWSTR . Since you are passing a number, not a real string, you need to cast to LPCWSTR to satify the compiler. The API will know what to do with the value.
[edit]
Actually, never mind all that (but it's still good to know the technicalities of resource IDs ). Use the MAKEINTRESOURCEW() macro which always casts to LPCWSTR .
[/edit]
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thats Workkkkkk i can't believe itttttt
Thanksss A LOOOTTTTT
|
|
|
|
|
Hi,
I am developing a program that needs to read a text file to the user. Could anybody tell me where I can find such a open source program or API? Thanks
|
|
|
|
|
Use the Speech SDK.
A tutorial on it can be found at:
http://www.ltpb.8m.com/tutorial/Listall.html[^] (i forgot the direct url, but this is the list)
-Steven
CP.Lounge.Addicts+="Steven";
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
I'm having trouble linking to a DLL that I've made. I have a project that uses multiple DLLs that we've created in house. Everything uses this one DLL that's has the most commonly used classes. Amazingly enough it's called common.dll. Anyway I'm having trouble linking to it in one of the other dlls. The signature that it gives in the error is ?StartServiceA@CTcpClient@@UAEHXZ. BUT the signature in the mapfile of common.dll and according to dependency walker is ?StartService@CTcpClient@@UAEHXZ. Common.dll as well as the CTcpClient class inside of it is used in many other things. They all link fine. One other note of interest. This linking error only happens when CTcpClient is created dynamically. If I create it using CTcpClient newClient(blah,blah,blah) all works. Thanks for the help.
Here's the full linking error.
Linking...
Creating library ..\..\..\lib/NetTraffic.lib and object ..\..\..\lib/NetTraffic.exp
ClientInterface.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CTcpClient::StartServiceA(void)" (?StartServiceA@CTcpClient@@UAEHXZ)
..\..\..\lib/NetTraffic.dll : fatal error LNK1120: 1 unresolved externals
nay
|
|
|
|
|
A few questions to the wise:
1) If I call strdup for a pointer to a string which is a member of class do I need to call free before recalling?
eg. cMyClass.szString = strdup(szString1);
cMyClass.szString = strdup(szString2);
Does the above cause a memory leak if I don't use free(cMyClass.szString); before the second call to strdup?
2) In a similar case if I am using strdup but there are pointer to class as in a linked list and I use delete to delete the pointer does that also free the memory taken up by strdup or I would have to free that memory first and then call delete on the pointer?
|
|
|
|
|
1) Yes
2) Yes
strdup() does always allocate a new copy of the string.
Therefor you must always free the the memory "manually".
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
For the second question you mean yes as in called free first on all objects of the pointer to class and then call delete or just delete will clean up everything? Thanks.
|
|
|
|
|
Sorry, didn't read #2 well enough...
You should use
<br />
if(m_lpszString != NULL)<br />
{<br />
free(m_lpszString);<br />
}<br />
in the destructor of the class
The basic rule is:
If you ever call strdup(), you must free() it somewhere.
A better alternative is to use a string class, either MFC or STL.
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Ok, I understand now, thanks.
|
|
|
|
|
hi
i have an empty document. and i draw some line and image in it, even i minimize and then maximize the window, all of the document window content will be cleaned. how can i stop this ? i think i sould Invalidate() it but how can i findout that the window in minimized (or even window goes under another windows it will be cleand)
thnx anyway
|
|
|
|
|
HellShrimp4free wrote:
how can i stop this ?
You can't. It's by design. How else can it work ?
HellShrimp4free wrote:
i think i sould Invalidate() it
It invalidates itself, the problem is that you're not doing your drawing in the OnPaint or OnDraw or OnEraseBackground message handlers, which means that it's not redrawn when the Invalidate occurs.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanks mr christian. i write the drawing code in OnPaint and the content saved. So it mean that it will redrawn itself when needed and i don't have to check for redrawn opearation?
my another question is : in a sample in MSDN it loads and shows a Bitmap from a .bmp file. is there any way to load bitmaps from Resources ? (for Emxaple IDB_BITMAP1)
in GDI+ i mean.
|
|
|
|
|
HellShrimp4free wrote:
is there any way to load bitmaps from Resources ?
Look up the LoadBitmap() API.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|