|
Thanks for the answer.
I have now created an application that utilises the createpipe() function.
The application that I am trying to control only uses function keys(F2,F3, etc..). I have tried using Virtual Key Codes (VK_F2, VK_ENTER, etc,..), however this does not seem to have any effect on the application that I am trying to control. Again, does anybody have any ideas?
Thanks again in advance.
|
|
|
|
|
I am alloating and deallocating a byte array as
void OnRecieve
{
if(pBuffer!=NULL)
{
delete []pBuffer;
pBuffer=NULL
}
pBuffer=new BYTE[5000];
}
i get the raw picture data from socket , allocate and dealloate memory as .
This code works fine for quite a long time , but may be after 3 , 4 hr.(So this code works fine for thousands executions )
I get the assertion while deleting this array.
in DBGHEAP.C File.
What might have the cause , Is there some other safer way to do this.
No Worries!
|
|
|
|
|
Could be a few things, the most likely is that you are writing past the end of one of your buffers at some point(probably by very few bytes,most likely one). You should:
- Check your code thoroughly where you write to the heap(allocated by new or malloc)
- Use memory checksumming to home in on the error, there is a CP article on this
- Evaluate a memory leak/overrun detection tool, such as boundschecker - lots of peeps can't live without them. Especialy if they do maintainence programming
5000 bytes is small enough to go on the stack really, and your program will fail in a much more entertaining way if that buffer is the culprit.
Ryan
|
|
|
|
|
It was on the CheckByte statements.in DBGHEAP.C
No Worries!
|
|
|
|
|
If you know you are always going to be allocating 5000 bytes, use Ryan's suggestion and use the stack. Dynamic allocation should be limited to cases where the amount needed is unknown until run-time.
Atif Mushtaq wrote:
I get the assertion while deleting this array.
in DBGHEAP.C File.
What line?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
sorry i wrote 5000 for simplicity of question , actually i recv data range from 4 ot 10 k , so only choice was do it dynamically.
another thing
How can i overwrite the array while deleting it.(It is the delete operator which is cauzing the problem)
throughout the whole program i use this buffer , in read only mode.
actually i get the picture data from remote server and i recieve it ony client side and simply display it .after doing it.On arrival of next packet i delete old memory and allocate new one.
So there is no chance of overwritng .........what u think.
Atif
No Worries!
|
|
|
|
|
Atif Mushtaq wrote:
On arrival of next packet i delete old memory and allocate new one.
This doesn't sound like "read only mode" to me.
Unless you need more memory, there's no need to continually reallocate the same memory. Just use memset() , or ZeroMemory() to "clear" that memory location.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
as i have told u that i get data range from 4 to 10k at random , so heap is the only solution.
Well what if i use malloc and free for allocating and deallocating memory.
No Worries!
|
|
|
|
|
You can also let someone else do the tiresome work of memory management: The STL:
By defining
std:vector<BYTE> buffer;
buffer resize(4000); you get 4000 BYTEs of memory with at
BYTE* adress = &buffer[0]; .
The length of the buffer is given by std::vector::size() , and you can reallocate using buffer.resize() .
To free the memory, you can always let the buffer go out of scope.
Hope this does help you a little
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Your last question was about "overwriting" memory. By suggesting the use of memset() or ZeroMemory() , I did not imply that the heap should be avoided. I was merely indicating that you can continue to use the same block of memory, rather than multiple calls to the memory manager. Since you indicate that the largest packet is 10KB, you could make things a lot simpler by creating a 10KB buffer on the stack.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Ok it looks right that , i should take 10k Static buffer but for example if i get the 5k binary jpeg data , what will happen that first 5 k of the buffer will conatin the right data and remaining 5k invalid data, cauz it is binary data so we cannot place null at the end the end of original 5k(As JPEG Data might oroginally cconatin many nulls).So what will happen that the API which are loading JPEG will simply crash or display incorrectly.
what u say...............
No Worries!
|
|
|
|
|
Presumably the code that is used to display the JPEG picture will want to know the size of the image. The fact that a 5KB image is in a 10KB buffer is irrelevant.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi
(Please let me know if there's a better group to post
this to)
Is there an easy way to extract error messages for a
build started via the VCConfiguration.Build method ?
The ReportError event in VCProjectEngineEvents doesn't
seem to ever be fired for build errors.
.
|
|
|
|
|
Hi!
Is it possible to import for example a Dialog recource from another project. Must I add the .h and .cpp files for the generated Dialog-classes?
APe
|
|
|
|
|
d00_ape wrote:
Is it possible to import for example a Dialog recource from another project.
Yes. If you have two instances of Visual Studio open, you can use drag/drop. If you have one instance of Visual Studio open, you can use copy/paste.
d00_ape wrote:
Must I add the .h and .cpp files for the generated Dialog-classes?
Yes, unless you are going to create new ones.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I may bee stupid but it doesn’t work to drag and drop (or copy paste).
Have tried both VS 6.0 and VS .NET
In VS .NET it seems to work but when I for example drop the ID_MYDIALOG1 on “the resourcemap” in the recourse view nothing happens!?
APe
|
|
|
|
|
can any one send me the microsoft visual c++ source code for under root.
the requirment is that we have to use only increament or decreament operator(++ or --).
I have made functions for adition, subtraction, division and multiplication.
please send me the algoritm for squar root.
|
|
|
|
|
a) From school memory, there was a newtonian expansion that would let you calculate it from
the operators you have already cracked.
b) This sounds a lot like homework, albeit damn hard. People here general frown on doing that
for other people. Hints, maybe. Spoon fed answers, no.
c) I was going to point you to the Visual C++ forum, then I spotted that was in another window.
Oops.
Iain
|
|
|
|
|
Since Newton's method uses the * and / operators, and * is shorthand for fast addition, and / is shorthand for fast subtraction, that should be a big hint.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Aqeel Asghar wrote:
can any one send me the microsoft visual c++ source code for under root.
the requirment is that we have to use only increament or decreament operator(++ or --).
I have made functions for adition, subtraction, division and multiplication.
please send me the algoritm for squar root.
That sounds an awful lot like a homework problem to me.
|
|
|
|
|
I took an image from my MSN Messenger 6 (I use XP and in my user files root it is somewhere in Application Data as a PNG image with a .tmp extension), converted it, using IrfanView 3.80, to a 256-colors 96x96 pix icon (ICO). The colors were still really good and the same as the PNG.
But when I put the ICO into my resouce stuff and load it into an CImageList, the palette is being ignored and my icon gets really 4-bits like.
How to avoid this?!
|
|
|
|
|
VisualStudio is a bit fussy, and if you open it from within the resource editor it will convert it automatically - you have to sneak it in the back (just copy over the existing file) and make sure not to open it from within VisualStudio itself.
|
|
|
|
|
I am also getting the similar kind of problem , i am using VC6.0.
It is relating to winxp ...i needed a folder icon to display in my treeCtrl application.so i exteracted it using a IconExtractor software from the System32\url.dll.Internet Explorer Favorite picks its icons from this dll.
This icon display all right with full quality in all other OS(WIN98,WINME,WIN2000)
But in WINXP it i get the dark shade under these icons .
But it is not only with me my app, i also saw another very famouse software (Neero Burning ROM) which use the same icon , and it also gets the similar shade under that icon.
So there must be some problem regarding WINXP.
But on the other hand IE Favorites in WINXP display that all rightt.
so any clue.
No Worries!
|
|
|
|
|
No, that is an other problem. The icon is 24-bits (I guess it is) and that dark shade is real. But XP can 'convert' that shade to a transparency level and so use it for the Operating System. For instance, in the "Choose an icon" dialog (when choosing an icon for a link or a folder or whatever), you'll see an array of some icons in SHELL32.DLL . You don't see a weird shadow there. But when a not-advanced program opens/extracts the icon, the shade will appear, because it is impreted as an opaque color.
|
|
|
|
|
If you mean a number like IDC_RESETBUTTON, the solution is quite easy. Just take an unique number (e.g. 2001) and define your IDC_ thing as that number using the preprocessor (so no ending semicolon):
#define IDC_RESETBUTTON 2001
Then make sure you declared your CButton* resetButton in you dialog class (well, you declare it as a local member, but then it will be destroyed afterwards and the ID isn't valid anymore...) and call, if the pointer resetButton is valid, the Create member function:
resetButton->Create("Reset Data",0,bRect,parent,IDC_RESETBUTTON);
where "Reset Data" is the window (read: button) title, 0 the style (why not WS_VISIBLE?!), bRect the window (read: button) rect, parent a pointer to the parent window (but you could also creaete it into a button ) and IDC_RESETBUTTON (the compiler will read '2001') the ID number.
This number can be used to get a pointer to the dialog item:
CButton* buttonPointer = (CButton*)YourDialogClassInstance.GetDlgItem(IDC_RESETBUTTON)
Could somebody confirm these things, please?
|
|
|
|