|
Hi all,
I have solved the issue and posting here for benefit of other persons. The problem was in the CString name member of struct info. I simply changed it with a char array n it worked correctly.
Regards
Cyber Friend
|
|
|
|
|
Hi.
I'm writing a server and client application using sockets. And I have a bug that I can't fix.
The server side software, start a thread that create a socket and when a client connect it calls a function to enumerate the folders and files of the PC where the server runs and it sends the names of files and folders to the client:
BOOL EnumerateFolders ()<br />
{<br />
WIN32_FIND_DATA fd;<br />
<br />
HANDLE hFind = ::FindFirstFile (_T ("*.*"), &fd);<br />
<br />
<br />
<br />
if (hFind != INVALID_HANDLE_VALUE) <br />
{<br />
do <br />
{<br />
CString data = fd.cFileName;<br />
<br />
<br />
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) <br />
{<br />
<br />
if (data != _T (".") && data != _T ("..")) <br />
{<br />
TRACE (_T ("%s\n"), fd.cFileName);<br />
<br />
::SetCurrentDirectory (fd.cFileName);<br />
<br />
if(send(client, data, data.GetLength() , 0) == SOCKET_ERROR)<br />
{<br />
return FALSE;<br />
}<br />
<br />
EnumerateFolders ();<br />
<br />
::SetCurrentDirectory (_T (".."));<br />
}<br />
<br />
}<br />
else<br />
{<br />
TRACE (_T ("%s\n"), fd.cFileName);<br />
<br />
if(send(client, data, data.GetLength() , 0) == SOCKET_ERROR)<br />
{<br />
return FALSE;<br />
}<br />
}<br />
<br />
} while (::FindNextFile (hFind, &fd));<br />
<br />
::FindClose (hFind);<br />
}<br />
<br />
return TRUE;<br />
}
At the client side, after the connection, it starts to receive the strings from server, inside a loop that it ends with a particular string.
Inside the loop, (a do-while), I wrote:
if ((numbytes = recv(client, buf, MAXDATASIZE-1, 0)) == -1) <br />
{<br />
TRACE("recv: %i bytes", numbytes);<br />
<br />
return 1;<br />
}<br />
<br />
temp.Format("%s", buf);<br />
temp.TrimRight ();<br />
So, the CString object "temp", holds the string sent by the server, it works, I can see the data, but instead of see the name of a single folder or file, I see a very long string with a lot of name of folders and files. It looks like the server send faster than client can receive the items, so the data is being concatenate.
Beside this, I'm trying to write the temp object into a text file using a CStdioFile object, but it assert, maybe because of the large of the string.
Where is the problem here?
How could I perform a receive routine at client side to get the strings for every folder and file sent by server?
Or the problem is in the server routine post above??
I will really appreciate any advice.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Before sending the data use the delimiters for each file/folder
for e.g.
CString data = fd.cFileName + "|";
and Tokenize the data on client side with "|"
Hope this helps you.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thankx LAX.
I will do that.
Anyway, I don't know if my routines are "well thinking", because, as I said, the server sends faster than the client can receive, and I could lost data in the process, or not?
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Demian wrote: Anyway, I don't know if my routines are "well thinking", because, as I said, the server sends faster than the client can receive, and I could lost data in the process, or not?
I think you are not loosing any data but you are loosing organisation of data.
So,As it is server it sends data fast due to that before sending organise data and then send so that client can understand it.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi,
i have three views in my application .The first view Name is GroupView..and the remaining to 2 views names are SplitViewOne and SplitViewTwo.i have tree contol in the GroupView.Intially application is loaded with Groupview in one pane and SplitViewOne in other pane .I have toe items in the treecontol one is "SplitViewOne" and "SplitViewTwo" when i click the TreeItem`s in GroupView..the view in the pane will be delted and respective is replaced up to here its fine.I want to hadle same under the button click of toolbar item...have should i handle the toolbar item OnCommand...i have handled it ChildFrame..but the application is crahsing .any idea pls ?
Thank`s in before
James
-- modified at 9:02 Saturday 20th May, 2006
|
|
|
|
|
When you want help with a crash there is a bare minimum of information most people will need:
1. The type of exception.
2. The source code where the crash occured.
3. A stack trace.
Steve
|
|
|
|
|
Hi all.
Is there a way to discover the containing object or class of a MethodInfo?
(i mean the object which the method is its member...)
-- modified at 8:55 Saturday 20th May, 2006
|
|
|
|
|
ey_cat wrote: Hi all.
Is there a way to discover the containing object or class of a MethodInfo?
(i mean the object which the method is its member...)
Are you trying to get the type of the current instance..??
if so see the following
Method - GetType()
Property - ReflectedType
Hope i understood your question.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I have a MethodInfo which is a member in a class.
i would like to discover the class type as an input to CreateInstance.
(the MethodInfo is the only info i have!)
Thanks...
|
|
|
|
|
What is CRuntimeClass,RUNTIME_CLASS?How can we use these?Where do we use these?
E-Ramu
|
|
|
|
|
|
Ramu.e wrote: What is CRuntimeClass,RUNTIME_CLASS?How can we use these?Where do we use these?
CRuntimeClass is a structure
RUNTIME_CLASS is a MACRO which gets the run-time class structure from the name of a C++ class.
RUNTIME_CLASS returns a pointer to a CRuntimeClass structure for the class specified by class_name. Only CObject-derived classes declared with DECLARE_DYNAMIC, DECLARE_DYNCREATE, or DECLARE_SERIAL will return pointers to a CRuntimeClass structure.
As per my knowledge
-one use of the RUNTIME_CLASS is for Creation of the User Interface Threads
-other use of RUNTIME_CLASS is for Creation of the SpliterWindows.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thank you Lakshman
E-Ramu
|
|
|
|
|
Welcome
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I'm a newbie to VC++. I'm working on Graphics and wants to know how to make use of CDC class' alphablend method. I scrolled thru the MSDN but didnt find it much useful as there was no example describing it.
I heard that by using alphablend method we can achieve high quality graphics as it enables transperancy.
I wud be more happy if i can get an example.
Please somebody help me! ...
raghu
|
|
|
|
|
Help[^] is on the way
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
|
|
|
|
|
Thanks for the reply pal ...........but that didnt help me to know how BLENDFUNCTION structure works. Moreover the project is a DIALOG BASED....
I'm doing my work in SDI.
Can't i get a simple example that uses alphablend function and displays a simple rectangle?
ne how thanks once again ...for the reply....
raghu
|
|
|
|
|
You are lazy
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
|
|
|
|
|
See
<br />
BLENDFUNCTION bend;<br />
bend.BlendOp=AC_SRC_OVER;<br />
bend.BlendFlags=0;<br />
bend.AlphaFormat=AC_SRC_OVER;<br />
bend.SourceConstantAlpha=50;<br />
AlphaBlend(GetDC()->m_hDC,0,0,400,400,m_pDC.m_hDC,0,0,0,0,bend);<br />
maybe it is some helpful to you of course you need to insert bitmap to dc
whitesky
|
|
|
|
|
in my code i am displaying a bmp image
Now i want to display a moving straight line from top to bottom on my image
The problem i am facing is the previous line i am displaying using
for(int i = 0 ; i < 10 ; i++)
{
dc.SelectStockObject(WHITE_PEN);
dc.MoveTo(pStart);
dc.LineTo(pEnd);
pStart.y = pStart . y + ldlist;
pEnd . y = pStart . y ;
}
remains but i want everytime only a single line should be shown
where ldlist is the distance my line shud move
-- modified at 6:12 Saturday 20th May, 2006
|
|
|
|
|
Check SetROP2() and draw twice to show the effect that only a single line is moving you have to redraw the previous line with back color.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi All
I have a property sheet wizard i am using, which has three pages
on the second page, when the user clicks next to go to the final page
depending on which option they have chosen on page 2 (i,e A or B)
a different property page will be displayed,
So if option A is selected on page 2 when next is clicked property page X is displayed
but if option B is selected on page 2 next is clicked property page Y is displayed
hope that makes sense?
I take it i would need to override the OnNext in page2 but im not sure
what to put to display the property page that i want
Can any one help
Simon
|
|
|
|
|
Hi Simon,
U can set the dialog into the ur property page 3 dynamically. when ever user click the Next on Page 2 based on option us et the appropriate dialog on 3 rd property page .
|
|
|
|
|
Thanks for the reply kiran
when you say
Kiran Kumar Singani wrote: U can set the dialog into the ur property page 3 dynamically
could you give me an example??
thanks
si
|
|
|
|