|
My hint: read the documentation [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I am having a requirement to set a different Color for Different Colmn for a CListCtrl. For Example.
//Insert the Columns
ptr->InsertColumn(0,L"Name",LVCFMT_LEFT,100);
ptr->InsertColumn(1,L"Age",LVCFMT_LEFT,100);
ptr->InsertColumn(2,L"Address",LVCFMT_LEFT,100);
The First Colum must be Entire Blue,
Second Column must be Red,
Thrid Column must be Green.
How can we achieve this.
please help me out.
Uday.
|
|
|
|
|
|
I want to add a splitter bar to divide the dockable pane window into 2 parts. Any idea on how to achieve this?
Actually somewhat similar to VS2008 style class view.
|
|
|
|
|
With the help of "Superman", I was able to prevent all but one memory leak generated by the 'new' operator:
{164} client block at 0x00187CA0, subtype c0, 28 bytes long. a CObject object at $00187CA0, 28 bytes long
Questions: 1. I understand most of what the Visual Studio 2008 teaches. Am I doing something incorrectly
to generate this leak?
2. Do I have to do something with this, or will the memory be released upon exiting Visual Studio.
There are several 'normal block' memory leaks also indicated. They take the form of:
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {166} normal block at 0x00187D68, 28 bytes long.
Data: <, e > 2C FB 16 65 05 00 00 00 05 00 00 00 01 00 00 00
Questions: 1. This appears to be generated inside an executable supplied by Visual Studio. Is this a Microsoft "bug"?
If so, what am I doing to cause this and others of similar form?
2. Same question as #2 above.
3. FWIW, my System Disk Management dialog shows "f:\" as one of my DVD reader/writers. Does Visual Studion
"count noses" differently than Vista 64 does?
Thanks again,
Barry
|
|
|
|
|
BarryPearlman wrote: {164} client block at 0x00187CA0, subtype c0, 28 bytes long. a CObject object at $00187CA0, 28 bytes long
You could add the following to the beginning of your source files (after inclusion of all header files) so that the debugger will be able to pinpoint the memory which is leaking (line number and source file name).
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
Of course you should build in debug mode in order for this to work.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Worked like a charm; all leaks stopped to date. I haven't touched C++ & MFC in years and I forgot the basic rule of "when you are done with your crayons, put them away!"
Thanks for your reply.
Barry
|
|
|
|
|
BarryPearlman wrote: Worked like a charm; all leaks stopped to date. I haven't touched C++ & MFC in years and I forgot the basic rule of "when you are done with your crayons, put them away!"
Thanks for your reply
I'm glad to be of help. It would be great if you could mark the helpful answers (by clicking "Good Answer") and close your thread.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
BarryPearlman wrote: Am I doing something incorrectly to generate this leak?
Probably.
BarryPearlman wrote: will the memory be released upon exiting Visual Studio
Yes, but if the object holds system resources they may not (won't) be cleaned up properly.
BarryPearlman wrote: Is this a Microsoft "bug"?
No, that's just where the actual alloc was called, but higher in the call stack you asked it to do something that resulted in the alloc.
Chances are you have either allocated (or done something that resulted in an alloc) that you haven't cleaned up, or you have a global object that is being constructed after you set the 1st crt mem checkpoint, but being destroyed after the 2nd crt mem checkpoint e.g. a function level static object.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi,
I want to ask something about socket programming in XP. I am using multiple send() and recv() command in a single function in server and client both but its not wroking properly.Actually i am sending a string and it should recv by server and then send back to client in a single function. Simply-
client :
{
printf("\nEnter the string.");
gets(sent_to_client);
send(sock,sent_to_client,sizeof(sent_to_client),0);//it will be sent to server
Sleep(1000);
printf("String is %s\n",sent_to_client);
Sleep(500);
recv(sock,output_from_client,sizeof(output_from_client),0);//here it is received from server
Sleep(1000);
printf("\nreceived sucessfully:\n");
}
server:
{
recv(theclient,input_from_client,sizeof(input_from_client),0);//here it is received from client
here it will be executed on server and the output should be sent to client
send(theclient_to_client,output,sizeof(output_to_client),0);//send to client
}
I was thinking that firstly i will give input string in client then it will be sent to server.In server it will be executed(it can be anything which i want) and then send back to client.In client it will be received sucessfully.But somewhere i am wrong. I don't know where?Please help me.
|
|
|
|
|
ravi 12 wrote: but its not wroking properly.
Could you explain what is not working?
Assuming that you are getting no response from the server you would probably need to repeat the recv() call until some data is returned.
|
|
|
|
|
Hi Richard MacCutchan,
Actually this code is inside on a long code.Only in that section there is no response from server.
client :
{
printf("\nEnter the string.");
gets(sent_to_client);
send(sock,sent_to_client,sizeof(sent_to_client),0);//it will be sent to server
Sleep(1000);
printf("String is %s\n",sent_to_client);
Sleep(500);
recv(sock,output_from_client,sizeof(output_from_client),0);//here it is received from server
Sleep(1000);
printf("\nreceived sucessfully:\n");
}
the output in client window is:Enter the string...
String is:
received sucessfully:
I think that is it the right way to call these functions in single function means should i use this type if(sent()== SOCKET_ERROR) or it is not necessary?
|
|
|
|
|
ravi 12 wrote: I think that is it the right way to call these functions in single function means should i use this type if(sent()== SOCKET_ERROR) or it is not necessary?
Yes, it is very necessary; you must always check the status of every command that can succeed or fail.
From your ouptut information it looks like you have not entered any text to send. Also in your code you print the message "received sucessfully:", but you do not know that you have received anything. Maybe you should spend time studying some of the socket samples on MSDN or Code Project - Google search should find them.
|
|
|
|
|
Hi Richard MacCutchan ,
Thanks for suggestion.For input i am using gets() but it is not taking any string.When Enter the string comes i tries to type string but suddenly it will shows me String is: .and nothing happans.
|
|
|
|
|
ravi 12 wrote: When Enter the string comes i tries to type string but suddenly it will shows me String is: .and nothing happans.
I cannot see what is wrong with your code on this, gets() should wait until you have entered some information before the program can proceed. Perhaps there is something else in your code that is not shown in your original message. Can you post the complete code that is failing (if it's not too long), and please remember to surround it with <pre></pre> tags to keep it formatted.
|
|
|
|
|
I think you should cut off the sleep() function
|
|
|
|
|
send/recv need the length of data, your are sending the size of the char pointer.
So, one way would be for your client to first send the length of the string it is going to send, then send the string.
The server would recv the length, alloc a buffer large enough to hold the incoming string, then recv the string.
... then reverse to send back to client.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: your are sending the size of the char pointer.
It was not shown how sent_to_client was declared, so why assume it is a pointer?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You're right, sent_to_client, output_from_client, input_from_client, and output_to_client could all be char[] in the same scope as the send/recv calls that use them.
However, if it they were char[] then i would expect the code to work (assuming no buffer overflow from gets, ...), whereas char* wouldn't.
In lieu of more information it seems like a logical assumption.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
|
Hi,
I think I am using "ANSI_CHARSET". (I used "GetTextMetrics" to find out that "tmCharSet = 0".
If I select "SimSun" Font, the char will shift a little bit below the baseline. It is weird.
How I can correct it or find out how much it was shifted?
Thank you very much,
|
|
|
|
|
This could be the way the font is designed.
Try changing the font to "SimSun" in MS-Word and check if the same thing happens.
|
|
|
|
|
Thank you.
I tried to use "WORD" to repeat this. I found out:
If I type some chars using other font and then change to "SimSun" Font. All preceding chars were shifted a little down after a char using "SimSun" Font was input.
How can I find out how much I need to shift and what kind of font I need to shift?
Thank you very much,
|
|
|
|
|
That is the way that font is designed.
It is not a shift as you say.
So I guess you will have to do some trials to see how much you want to shift it.
|
|
|
|
|
The problem is how to find out which font need to be "shift".
I find out that there are a lot of font using WORD doing like this. The WORD can handle this. I think there is a way to find out what kind of font that need special handling.
The Font design like this is really weird. Why Microsoft doing this?????
|
|
|
|