|
Hi this is ramu
I got a problem in transwering the image buffer. Actually the problem is at receiving side. The receive statement not receiving the whole data sent.
Some body advised to send the length as a heder first and get it at the client side and make a loop untill the whole length is received.
But i dont know how to make the length as heade in serverside to send and
how to put the receive statement in loop.
So please some body help me out in this problem.
Thank you.
Ramu
|
|
|
|
|
There are several ways. An easy way could be by sending i.e. an unsigned long (if has the capacity needed) as the first data.
Kind of like this:
Sending side
<br />
unsigned long datalength = imageLength;<br />
Send(&datalength, sizeof(unsigned long));<br />
while(moreDataToSend) {<br />
send(data);<br />
}<br />
At the receiving side (assuming that the Read function returns the number of bytes read from the socket):
<br />
unsigned long receivedDataLength;<br />
Read(&receivedDataLength, sizeof(unsigned long));<br />
<br />
unsigned long receivedBytes = 0L;<br />
<br />
while(receivedBytes < receivedDataLength) {<br />
receivedBytes += (unsigned long) Read(buffer, sizeof(buffer);<br />
}<br />
If an unsigned long isn't enough, the use some other variable type. Just make sure it's the same on both sides.
|
|
|
|
|
Hi,
Can we tell me as to create ActiveX control from MutiDocument/View project????
Because I have project which is create on MultiDocument/View architecture and I need reconstruct on ActiveX...
Thanks
|
|
|
|
|
Have the document class support automation.
Create a new SDI or MDI application with AppWizard and check the "support automation" for the document class.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Hi,
In View I get DC
as
CDC *dc = GetDC();
I do whatever..
and function exits..
Is there need to release this dc or it will be done automatically as function exits.. If I release will there be harm to views DC.
What is the right way. SHould I always use CClientDC in views rather than CDC
regards
ppatel
|
|
|
|
|
From the docs:Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
How can I know if the device context belongs to windows?
Which function/syntax shows that dc belongs to windows?
ppatel
|
|
|
|
|
The simple answer is don't bother. Here's a quote from MSDN on the ReleaseDC function:
"The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs."
So always call ReleaseDC and let the system worry about the details.
Steve
|
|
|
|
|
Hi Stephen Hewitt
and use DeleteDC()
if use CreateCompatibleDC or CreateDC
WhiteSky
|
|
|
|
|
From doco on DeleteDC
"An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC."
If you use CreateCompatibleDC of CreateDC you need to delete it when done by calling DeleteDC .
Calling ReleaseDC doesn't actually delete a DC. To quote again from MSDN:
"The ReleaseDC function releases a device context (DC), freeing it for use by other applications."
Steve
|
|
|
|
|
hi,
I have a recordset which contains the results of a query, and I want to get the number of records in the recordset.
I tried to use the GetRecordCount function, but I understood that I have to go through the whole recordset in order to get the number of records. So I have this loop in my code which is very inefficient:
while (!pSet->IsEOF()) //pSet is a pointer to the recordset
pSet->MoveNext();
I thouhgt to do an SQL query using COUNT, but it requires a simple query (something like: SELECT COUNT (*) FROM Table1 ) and my query is not a simple one. It contains selection of a number of records, and Inner joins of tables and an ORDER BY clause.
Is there another way to get the number of records in a recordset? Any suggestions?
|
|
|
|
|
Been a long time since i programmed in ADO but IIRC you don't need to
while (!pSet->IsEOF())
pSet->MoveNext();
pSet->MoveLast();
pSet->GetRecordCount();
Hope it helps
The statement below is true. The statement above is false.
|
|
|
|
|
Nope - I tried that and it doesn't work
It gives 1 record as the result...
|
|
|
|
|
U just move to the first record and now loop until the end of records take a variable and increment it inside the loop with MOVENEST() function.
the variable holds the total records count
|
|
|
|
|
I don't understand what you mean...
can you write some code maybe?
and by the way, I would rather not use a loop - it's not very efficient...
I need an efficient solution
|
|
|
|
|
Monty2 wrote: pSet->GetRecordCount();//something like this
This will simply give you the “high water mark” — the highest-numbered record yet seen as the user moves through the records.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Yeah - I know. That's why I need another solution...
Is there another way to get the number of records in a recordset other than going through the recordset with a loop or using COUNT?
-- modified at 9:23 Tuesday 16th May, 2006
|
|
|
|
|
SWDevil wrote: Is there another way to get the number of records in a recordset other than going through the recordset with a loop or using COUNT?
Have you considered/tried a stored procedure?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Ummmm - no. don't really know what that is...
|
|
|
|
|
|
Thanks - I'll look at the links
|
|
|
|
|
SWDevil wrote: Is there another way to get the number of records in a recordset?
You can use JOINs with the COUNT() clause. Simply put COUNT() around the columns that you are querying.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I tried doing that (in SQL server) and it doesn't work...
|
|
|
|
|
Ok, so just use COUNT(*), leaving the JOIN and WHERE clauses intact.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi All,
I know that the compile options \Gh gets you the _penter and _pexit, which can be used to get function level timings.
However, now the trick is how does one get to the level of saying: Line 121 took 13ms, Line 122 took 14ms, etc...?
Has anyone got any ideas or documentation to read?
thanks,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|