|
Have a look at CDC::SaveDC() ( There is also an excellent article by Joe Newcomer on this site about SaveDC(), look it up ) and also why not just use local GDI objects that go out of scope when you are done with them? saves having to mess around with new and delete.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I'll read that tonight. I haven't optimized the program for space and efficiency yet but one thing I did was to put the grey brush into the child view to be created once on construction, then used repeatedly, and deleted on deconstruction. I also have to figure out a better flow to my program but that's on my shoulders. I'm trying to optimize drawing because it's definitely the slowest part of my program.
|
|
|
|
|
I know how to do that in visual c++ NET but I have to use visual c++ 6.0 only. so how can I convert byte array to image(or binary) that will insert data to sql database.
STDMETHODIMP CModels::AddPicture(IUnknown* pIUnkConnection , byte* byteImage)
{
_ConnectionPtr spIConnection;
CConnection connection;
connection.GetConnectionToDB(pIUnkConnection, &spIConnection);
_bstr_t bstrCommand = "INSERT INTO MODEL VALUES ('" First Picture "', "', ?????(byteImage)how can I can convert byte array to image???)";
THROW_COM_ERROR(spIConnection->Execute(bstrCommand, NULL, adExecuteNoRecords));
bytes[] convert to image(binary)
Remember I cant use C++ .NET at all
use Visual c++ 6.0 only
|
|
|
|
|
Using Visual C++ 6, running some C++ code which allocates & frees some memory, usually if I've got any problems with unallocated/unfreed memory I'll get access violations, exceptions, but this time I'm getting a heap error I've never seen before:
HEAP : dedicated (0000) free list element 6fa9ae8 is marked busy
What's the difference between this and an access violation / exception?
I think it means I'm running of of heap space, as it can happens at any memory allocation in my code, but it doesn't look that way from the amount of memory my program is using?
Any tips of finding out the cause of this?
|
|
|
|
|
Tam987654321 wrote: Using Visual C++ 6, running some C++ code which allocates & frees some memory...
Are you using the new and delete operators?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks for trying to help, I managed to fix my code.
It was new & delete operators I was using, the problem was I was overrunning a buffer.
I discovered the cause by using _heapchk to check the status of the heap, I took the code from the following link and put it at different parts of my code to find out when the heap was getting corrupted.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__heapchk.asp
|
|
|
|
|
Hi,
I am getting boolean value from store procedure.When flag is set, it fill value 255 otherwise 0. It should be 1/0. When i tried to declared varaible type bool no data is coming and it is showing garbage.Can you please help me.
Thank
|
|
|
|
|
simple:
suppose c is what you get from the stored proc and b is the boolean you want.
just do this: b = c & 1;
cast (c & 1) to bool if needed
|
|
|
|
|
I believe this is the correct result as VARIANT_TRUE is defined as -1, VARIANT_FALSE is 0.
What database are you using?
John
|
|
|
|
|
Thank you for your reply. I think you are right, for interger it is showing -1 for set flag. I am using SQL server.
~Pankaj
|
|
|
|
|
When exactly is the file mapped into memory updated on the disk? I thought it will be updated as and when it is updated in the memory, but the documentation of UnMapViewOfFile says "If the function succeeds, the return value is nonzero, and all dirty pages within the specified range are written \"lazily\" to disk" which means the file will be written to the disk only when UnMapViewofFile is called.
Can someone clarify? Thanks.
thanks
/f
|
|
|
|
|
This is saying tht UnMapViewOfFile will trigger a lazy write, but the OS may write this data at any time. For performance reasons, however, it will tend to defer this. If you must write the data, just call FlushViewOfFile() .
Note, however, that by default this still does a lazy write as do all disk writes (by default.) In practice the data will be written within very few milliseconds. And before you panic, note that your hard disk has a cache and is essentially doing the same thing.
If you want more immediate writes, you must use the FILE_FLAG_WRITE_THROUGH flag when you open the file (and follow the guidelines of using that flag.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I posted something similar to this earlier, but I think I'm getting closer to the problem.
I wrote my own class, CFAFRecord, that is a derivative of CObject. When someone presses the button, I do something similar to
my_ObjectArray.SetSize(10);
CFAFRecord my_Record;
my_Record.name = m_Name;
my_Record.address = m_Address;
my_ObjectArray.SetAt(0, &my_Record);
my_ObjectArray in the example is a CObArray that is a member variable of my dialog. Later, when I try to access, I try
CFAFRecord * my_Record = *(CFAFRecord *)my_ObjectArray.GetAt(0);
m_Name = (*my_Record).GetName();
When I try that last line, I get an access violation, looks like a memory access error. I think I'm handling the memory wrong somewhere, maybe in the first functiion, when I use the SetAt, I pass the pointer to my_Record and my_Record is probably destoyed at the end of the function. If that's the case, how can I can I fix this?
Danny
The stupidity of others amazes me!
|
|
|
|
|
Thought so, you have now posted the offending code.
my_ObjectArray.SetSize(10);
CFAFRecord my_Record;
my_Record.name = m_Name;
my_Record.address = m_Address;
my_ObjectArray.SetAt(0, &my_Record); my_Record goes out of scope and is destroyed, so that the address that is stored in my_ObjectArray now points to useless memory, thus your access violations.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
bugDanny wrote: CFAFRecord my_Record;
Should be:
CFAFRecord *my_Record = new CFAFRecord;
...
my_ObjectArray.SetAt(0, my_Record);
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thank you.
Danny
The stupidity of others amazes me!
|
|
|
|
|
Is there any one know how make a circle push button and place a bitmap on it?
|
|
|
|
|
|
SHALOM
half an hour ago I posted a message to know how to send the size of one file that I want to send through a socket
,
ok now the problem is that I have sent characters through a scoket , but I dont know how to send a file,
I think that the first thing I need is to open the file in the side I want to send the file , right ?
and in the other side I need to open a new file where Im gonna put the file,,
but I dont know how to use fread and fwrite,
I mean I have read the msnd help, but I dont understand how to send the entire file
I need to do a while until all the data have been sent ??
can somebody help me,, Im tryin to test my connection, and the last thing I need to do is to send the file that I have capture a .Wav file from one computer to another.
thanx
GOD BLESS YOU
|
|
|
|
|
REU wrote: mean I have read the msnd help, but I dont understand how to send the entire file
I need to do a while until all the data have been sent ??
Here is Example :-
http://www.codeproject.com/internet/SocketFileTransfer.asp[^]
A Request:- don't target your post to peculiar person
"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
|
|
|
|
|
I've been messing with this application for a while now. I have an unmanaged dll that fires a few events I want to capture in my C# app.
I used a C++ managed app, found here at codeproject, that would act as an interface to my unmanaged C++ and my C# app.
I never could get it to work, so im deciding whether or not I can put the unmanaged code inside my managed code and still use my events in unmanaged code.
If this is possible I could then reference it in C# and create an event handler for those events.
My question is, what does this entail?
What about the includes in my unmanaged code?
Am I correct in thinking that include 'windows.h' can be replaced with using namespace System;?
Other includes I'm using are:
strhandle.h
string.h
stdio.h
stdlib.h
share.h
and iohandler.h
What are the .Net equivalents to these?
Also my unmanaged code uses __asm to loop through some data, is that transferable to .Net?
Sorry for the many questions, I appreciate any help one can give me.
Steve Welborn
"Science can purify religion from error and superstition.
Religion can purify science from idolatry and false absolutes"
- 1987 John Paul the Great
-- modified at 11:08 Tuesday 18th October, 2005
|
|
|
|
|
Disregard post. I figured it out.
Steve Welborn
"Science can purify religion from error and superstition.
Religion can purify science from idolatry and false absolutes"
- 1987 John Paul the Great
|
|
|
|
|
Hi every body!
First, thank for your help.
I want to build an engine to read HTML Help file (.chm).
It can return topic, content, ... in the .chm file.
I was tried do that with API function HtmlHelp(...) (I found this function in HTML WorkShop), but it only return me the Help View with the .chm file, not any topic, content!
I really need this, please help me
Thanks!
|
|
|
|
|
SHALOM
everybody
I have a big problem,
Im using sockets to communicate 2 aplicattions,
Im using the functions send() and recv()
and everythings is going well ,,
but now I need to send a file , is a .Wav file
so the first thing I need to know is the size of the file to transfer first the size of the file , then in the other side of the connection I will know how size to receive.
well the size I get using this
FILE* f;
f=fopen("file1.Wav","rb");
int size;
fseek(f,0,SEEK_END); //move the pointer to the final of the file
size=ftell(f); //to know where is the pointer
rewind(f); //to put the pointer in the begining of the file
so I have in size the size of the file.
but this is an int var
Im trying to send the data like this
send(socket, &size, sizeof(size), 0);
so when I try to send it by the sockets it say
error C2664 cannot convert parameter 2 from int * to const char *
the function send() takes 4 param
http://msdn.microsoft.com/library/en-us/winsock/winsock/send_2.asp[^]
so,, can somebody tell me how to send the size of the file ???
Thanx
GOD BLESS YA
REU
|
|
|
|
|
REU wrote: int size;
fseek(f,0,SEEK_END); //move the pointer to the final of the file
size=ftell(f); //to know where is the pointer
rewind(f); //to put the pointer in the begining of the file
so I have in size the size of the file.
but this is an int var
Im trying to send the data like this
send(socket, &size, sizeof(size), 0);
Hello Reu,
please modify your code something like this :-
On Sender End
char szSize[10];
itoa(size,szSize,10);
send(socket, szSize, strlen(szSize),0);
On Receiver End
int iSize;
recv(socket, szSize, strlen(szSize),0);
iSize=atoi(szSize);
"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
|
|
|
|
|