|
that code is pretty bad, you essentially overwrite direction_comp in the second set of if/else statements, therefore it doesn't matter what the first one does, so combining them is as easy as just keeping the second block
if(segments_comp[head_comp]->panel->Top <= Food->Top)
{
if(segments_comp[head_comp]->panel->Left <= Food->Left)
direction_comp =-1;
else
direction_comp=-2;
}
else
{
if(segments_comp[head_comp]->panel->Left >= Food->Left)
direction_comp =1;
else
direction_comp=2;
}
|
|
|
|
|
Thanks. That code works better.
|
|
|
|
|
Hi all,
i m using this
char buffer[250];
CString str=_T("Test");
strcpy_s(buffer, str);
and this error 'strcpy_s' : none of the 2 overloads could convert all the argument types
comes please help me to resolve this.
|
|
|
|
|
This is happening because you are compiling for Unicode (UNICODE and/or _UNICODE is defined).
If you check on this MSDN page: http://msdn.microsoft.com/en-us/library/td1esda9%28v=vs.80%29.aspx[^] you will see that there is no overload that takes (char *, wchar_t *) (which is what you are passing; the CString in Unicode builds is wchar_t). So you have to convert your char string to wchar_t, or convert your CString to char. Or, don't build for Unicode.
|
|
|
|
|
I compulsory need to build in Unicode mode,
please give any example to solve it with Unicode.
|
|
|
|
|
|
Use the unicode version of the function - wcscpy_s .
Or you could use _tcscpy_s which will work for both unicode and non-unicode builds.
You would also need to define buffer with wchar_t or TCHAR instead of char .
|
|
|
|
|
now its done. but now one more problem generate.
fun1(char * buf);
fun1(char * buf)
{
HRESULT result = _channel->WritePacket((unsigned char*)buf, strlen(buf));
return ( !FAILED(result));
}
wchar_t * wbuf;
_tcscpy_s(wbuf,str.GetLength(),str);
fun1(wBuf);
|
|
|
|
|
You said you want a unicode build.
And char does not support unicode.
Remember that char and wchar_t are different data types and you CANNOT typecast between them.
|
|
|
|
|
Le@rner wrote: fun1(wBuf);
Seems self explanatory. wBuf is a wchar_t but fun1() is expecting a char .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
there don't use str, use str.GetBuffer(0); or other function to change CString to const char *;
|
|
|
|
|
linc_lee wrote: ...use str.GetBuffer(0);
Completely unnecessary, since CString has a LPCTSTR operator.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
int i;
char *pmbnull = NULL;
char *pmbhello = (char *)malloc( MB_CUR_MAX );
wchar_t *pwchello = L"Hi";
wchar_t *pwc = (wchar_t *)malloc( sizeof( wchar_t ));
printf( "Convert to multibyte string:\n" );
i = wcstombs( pmbhello, pwchello, MB_CUR_MAX ); // Look here !
printf( "\tCharacters converted: %u\n", i );
printf( "\tHex value of first" );
printf( " multibyte character: %#.4x\n\n", pmbhello );
printf( "Convert back to wide-character string:\n" );
i = mbstowcs( pwc, pmbhello, MB_CUR_MAX ); // And here !
printf( "\tCharacters converted: %u\n", i );
printf( "\tHex value of first" );
printf( " wide character: %#.4x\n\n", pwc );
}
Best wish!
|
|
|
|
|
Hi All,
Where can i get the visual studio 4.1 software for downloading?
|
|
|
|
|
There is no software called Visual Studio 4.1 .
You can however get to download Visual C++ 4.2 and Visual Basic 4.0 separately.
For this you will need to buy an MSDN Subscription.
I even see older vesions like Visual C++ 1.52 and Visual Basic 2.0 in the subscription that I have.
|
|
|
|
|
Hi, I am coding an algorithm that searches for a box on the screen. So far I got the snake to find the food which works great except that for example. If the snake is moving right it will sometimes move left and move ontop of it's self. I've spent awhile trying to figure it out on my own with no success. I think it has to do with the two blocks of if statements but I'm not sure. Maybe they need to be combined somehow? This is the last thing I need to figure out and my program is finished. Thanks in advance.
I tried.
if(direction_comp!=1){direction_comp=-1;} else {direction_comp=2;}
direction_comp of 1 = left;
direction_comp of -1 = right;
direction_comp of 2 = up;
direction_comp of -2 = down;
void comp_direction()
{
if(segments_comp[head_comp]->panel->Left <= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=-1;}
}
else if(segments_comp[head_comp]->panel->Left >= Food->Left)
{
if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
else{direction_comp=1;}
}
if(segments_comp[head_comp]->panel->Top <= Food->Top)
{
if(segments_comp[head_comp]->panel->Left <= Food->Left){direction_comp =-1;}
else{direction_comp=-2;}
}
else if(segments_comp[head_comp]->panel->Top >= Food->Top)
{
if(segments_comp[head_comp]->panel->Left >= Food->Left){direction_comp =1;}
else{direction_comp=2;}
}
}
modified on Friday, April 15, 2011 7:47 PM
|
|
|
|
|
|
I have a VC project built by VC6 was a MFC app format.
Last year, someone convert it to MFC DLL format and I have to turn it backup, now!
I used VC2008 + sp1 do it, but I got a warning:
Linker Tools Warning LNK4086: entrypoint '_wWinMainCRTStartup' is not __stdcall with 12 bytes of arguments; image may not run.
How to overcome it ?
Best Regard!
|
|
|
|
|
Without seeing the code, it's hard to say what the problem is.
If you can't figure this out, maybe you should consider creating an empty MFC app, and then adding the code from the DLL, piece by piece.
|
|
|
|
|
Hi, Hans
THX
ye, after I pieced code from the DLL, I got a lot of "error LNK2001" and "error LNK2019"
Very peculiar, the Dll project didn't import any libs !?
|
|
|
|
|
Post errors here if you need help.
|
|
|
|
|
error LNK2019: unresolved external symbol "public: void __thiscall CHdtaVwRenderThread::AddJobW(int,int,class CSize const &,struct CHdtaVwDisplaySettings const &,int)" (?AddJobW@CHdtaVwRenderThread@@QAEXHHABVCSize@@ABUCHdtaVwDisplaySettings@@H@Z),the symbol called in function "protected: void __thiscall CHdtaVwBaseView::UpdatePageCache(int,class CRect const &,bool)" (?UpdatePageCache@CHdtaVwBaseView@@IAEXHABVCRect@@_N@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall PageInfo::~PageInfo(void)" (__imp_??1PageInfo@@QAE@XZ) dtaVwBaseView.obj
Best Regard.
|
|
|
|
|
OK, none of these are MFC or Windows APIs. You're going to need to track down where CHdtaVwRenderThread , CHdtaVwBaseView , and PageInfo are located. Look at the .dsp (or .vcproj) file of the DLL (open in regular text editor). Search for these names, or for 'hdta'. The DLL must be linking with these APIs somehow. Also, search your HD for 'hdta*'. If you're able to compile and build the DLL on your system, they must be there someplace. In particular, look at any include directories or lib directories that the DLL links to.
|
|
|
|
|
HI, Hans
I have solved the problem after I erased the word "AFX_EXT_CLASS" before CHdtaVwRenderThread!
Thank you for your help again.
Best wishes.
|
|
|
|
|
The following code results in a Build Error error LNK2001: unresolved external symbol _IID_IDirectSoundBuffer8 if I un-comment the 5th line:
hr = pDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) ppDirectSoundBufferInterface);
I've added Dsound.lib to the Additional Dependencies for the Linker in this project.
I've included Dsound.h which has the definition of IID_IDirectSoundBuffer8 in my .cpp file, so it should know all about the GUID Definition.
Why has it pre-pended an underscore in the Build Error message (i.e. "_IID_IDirectSoundBuffer8")? I don't have one in my code. I used "IID_IDirectSoundBuffer8".
hr = lpDirectSound->CreateSoundBuffer(&dsbDescription, &pDirectSoundBuffer, NULL);
if(SUCCEEDED(hr))
{
pDirectSoundBuffer->Release();
}
With the offending line commented out as above, the code builds ok and runs. Putting in a break-point and investigating the various values just prior to the offending line I have the following:
hr = S_OK ......So it apparently created the Secondary Buffer Ok
pDirectSoundBuffer.IUnknown.__vfptr[0] = 0x73f5d348
pDirectSoundBuffer.IUnknown.__vfptr[1] = 0x73f38f8c
pDirectSoundBuffer.IUnknown.__vfptr[2] = 0x73f19105
dsbDescription.dwSize = 36
dsbDescription.Flags = 32960 (i.e. DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS)
dsbDescription.dwBufferBytes = 5930
dsbDescription.dwReserved = 0
dsbDescription.lpwfxFormat.wFormatTag = 1
dsbDescription.lpwfxFormat.nChannels = 1
dsbDescription.lpwfxFormat.nSamplesPerSec = 11025
dsbDescription.lpwfxFormat.nAvgBytesPerSec = 11025
dsbDescription.lpwfxFormat.nBlockAlign = 1
dsbDescription.lpwfxFormat.wBitsPerSample = 8
dsbDescription.lpwfxFormat.cbSize = 0
dsbDescription.guid3DAlgorithm = {GUID_NULL}
All values in dsbDescription correlate with what we should see for the selected Wave file.
The QueryInterface method is supposed to retrieve a pointer to the interface for my object.
i.e. it's supposed to fill the pointer ppDirectSoundBufferInterface with the correct pointer address for the DirectSound Buffer Interface of my new DirectSoundBuffer object.
Any clues at to why this Build Error occurs would be most appreciated.
Thank you in advance
Paul.
modified on Friday, April 15, 2011 11:25 AM
|
|
|
|