|
Hi Experts
My applicatiom having a WCHAR pointer within a structure.
Whenever i delete WCHAR pointer it display exception
"_ASSERTA(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));. "
|
|
|
|
|
You have either written past the end of the array, or you have changed the pointer somewhere in your code.
|
|
|
|
|
Some possible causes:
- You're delete ing a pointer which was not new ed.
- You've called delete more than once on the block.
- You're calling delete on in the middle of a block instead of at the start.
- The heap is corrupt.
Steve
|
|
|
|
|
Hi
all
I want to set menu font in my application to Japanese, i want to do this through coding in VC++ so which API and functions are used to do it.
Thanks
Atul M
Atool
|
|
|
|
|
There are many ways to do this.
1. In the resource file, set the font of the dialog to your Japanese font.
2. Override OnSetFont()
3. Use CreateFont() and SendMessage() passing the font and WM_SETFONT
|
|
|
|
|
Hi all,
I m trying to do multi threading .Actually what i want is to run multiple instances of one thread at same time. I m new to multi threading but i have done single threaded applications ...
Can anybody tell me how to do it ???
thanks in advance
Sulabh srivastava
|
|
|
|
|
Try looking at this article[^]. It's a good introduction to using threads.
Software Zen: delete this;
|
|
|
|
|
Hi guys,
I've got some code from a classmate that was developed in gcc, and which I need to compile in VC++. I know that my problem is a result of VC++ wanting me to give a constant size for an array, but frankly I don't want to (it's not in the assignment specs). Don't worry, this isn't an integral part of the assignment, just setting it up. Here's the code that's causing the trouble:
<br />
int fixAtoi(char myAry[], int arySize){<br />
char myAry2[arySize+1];<br />
for (int i=0; i<arySize+1; i++){<br />
myAry2[i]=myAry[i];<br />
}<br />
myAry2[arySize]= '\0';<br />
return atoi(myAry2);<br />
}<br />
it's that second line there...
Like I said, I know what the problem is, but apart from pre-defining the array size, I don't know of a fix.
P.S. I hope you guys can appreciate having to read all that since I wrote it all while learning the dvorak layout (my second attempt).
Thanks guys,
Sean
|
|
|
|
|
int fixAtoi(char myAry[], int arySize)<br />
{<br />
char myAry2 = new char[arySize+1];<br />
<br />
for (int i=0; i<arySize+1; i++)<br />
myAry2[i]=myAry[i];<br />
myAry2[arySize]= '\0';<br />
<br />
int iRet = atoi(myAry2);<br />
<br />
delete [] myAry2;<br />
return iRet;<br />
}
|
|
|
|
|
You may need to change this like,
int fixAtoi(char myAry[], int arySize)
{
char *myAry2 = new char[arySize+1];
for (int i=0; i < arySize ;i++)
{
myAry2[i]=myAry[i];
}
myAry2[arySize]= '\0';
int nRet = atoi(myAry2);
delete [] myAry2;
myAry2 = NULL;
return nRet;
|
|
|
|
|
Using a variable for the size is a non-standard extension. Use new instead to allocate the array.
|
|
|
|
|
excellent, thank you very much guys. It works perfectly now!
|
|
|
|
|
Sean Wcisel wrote: I've got some code from a classmate...
Shame on your classmate for giving you bad code.
int fixAtoi(char myAry[], int arySize)
{
char myAry2[arySize + 1];
for (int i = 0; i < arySize + 1; i++)
{
myAry2[i] = myAry[i];
}
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Using Connect API we connecting to the smtp or pop server. Some time while connecting to the server more time to take for the response. It should possible to cancel the connnection. Any one help me.
Thanks in advance!
Have A Nice Day!
Murali.M
|
|
|
|
|
Are you referring to the sockets "connect()" API? If so, then you might try using a non-bocking
socket. If you choose to cancel then just close and destroy the socket. If the connection
succeeds then you can be notified via a Windows message or an event depending on your needs, using
WSAAsyncSelect() or WSAEventSelect().
Mark
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Could anyone tell me how to get the playtime for a mp3 music? I have
no idea of the structure of the mp3 file, I guess maybe there is a
field in the mp3 file structure which value is the playtime.
|
|
|
|
|
chocm wrote: I have
no idea of the structure of the mp3 file...
Have you tried here?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This is probably a dumb question, but how do you use the _MSC_VER macro?
I have created a set of macros, some of which will not work on older compilers, so I obviously need to check for this.
I'm currently making use of the __VA_ARGS__ and __FUNCTION__ macros, so if anybody could also tell me what the minimum VS version required for using these?
-- modified at 21:50 Friday 16th February, 2007
|
|
|
|
|
__VA_ARGS requires VC8 - _MSC_VER 1400
__FUNCTION__ requires VC7 - MSC_VER 1300
#if _MSC_VER >= 1300
#endif
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Thankyou
|
|
|
|
|
1. I create a device context with GetDC(NULL) for the screen and a bitmap with CreateCompatibleBitmap to that context, width and height specified.
The resulting BITMAP (received by GetObject) shows the correct size, but the number of color planes is 1 (although it IS a color monitor), the number of bits per color plane is 32.
Why doesn't the bitmap show bmPlanes = 3 and bmBitsPixel = 8 or 10?
2. I create a memory device context with CreateCompatibleDC(NULL) and a bitmap to it with CreateCompatibleBitmap, width and height specified.
The resulting bitmap shows a black and white context, mbPlanes = 1, bmBitsPixel = 1 (but it does show the proper size).
The online MSDN explains this:
When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected
into it. If this memory device context is used in CreateCompatibleBitmap, the bitmap that is
created is a monochrome bitmap. To create a color bitmap, use the hDC that was used to create
the memory device context, as shown in the following code:
HDC memDC = CreateCompatibleDC ( hDC );<br />
HBITMAP memBM = CreateCompatibleBitmap ( hDC, nWidth, nHeight );<br />
SelectObject ( memDC, memBM );
This produces the same result, which is IMO natural.
How can I get the correct (color) bitmap to the memory DC? (I guess if the bitmap to the device context created by GetDC were correct, that could be Select-ed into the memory context.)
3. Neither the above DDB, nor the memory bitmap points to any storage, i.e. bmBits is zero.
This is ok for the DDB, but bmBits should not be zero for a memory device context. (I want to "paint" directly in the bitmap storage.)
|
|
|
|
|
1) The format of the pixel data is not planar so planes==1. RGB data is interleaved in that case.
2) Are you sure that produces the same result when hDC is a handle to a screen DC?
*EDIT* try this
HDC hDC = ::GetDC(0);
HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, 100, 100);
BITMAP bitmap;
::GetObject((HGDIOBJ)hBitmap, sizeof(BITMAP), &bitmap);
3) I believe you need to use a DIBsection to write directly to pixel data.
Mark
-- modified at 20:12 Friday 16th February, 2007
added sample code
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
1. The non-planar organization is ok on its own. I used GetDeviceCaps to query the characteristics; that too returnes 1. However, the number of colors in GetDeviceCaps is minus 1, although MSDN states, that 1 denotes more than 8 bits per pixel. Though this is not a big issue.
2. Of course if I use GetDC(NULL), then I get a DDB; that is the subject of #1 above. My problem is, that this goes against the documentation. I am doing this way in order to achieve the best performance; I don't know, if that won't be ruined by this usage of bitmap (although this appears logical to me), and I don't know, how I could verify it.
3. Using a DIB format would defeat the purpose (performance advantage with DDB). Either I don't understand something, or there is some way to work directly on the bit map.
Anyway, thanks.
|
|
|
|
|
What are you trying to do exactly?
If all your DC's have the same color depth, you don't need to worry about performance since there is no color conversion going on. If you want to manipulate the bits directly, it's better to use a DIB rather than a DDB.
|
|
|
|
|
Conversion arizes not only from different color depths. The format of the device dependent data can be different from the independent format. Example: the 24-bit color info can be kept in 32 bits.
|
|
|
|