|
kilowatt wrote:
bool CDlg::EnableMinimizeButton(bool bEnable){LONG lStyle = GetWindowLong(GWL_STYLE);if (bEnable) SetWindowLong(GWL_STYLE, lStyle | WS_MINIMIZEBOX);else SetWindowLong(GWL_STYLE, lStyle & ~WS_MINIMIZEBOX);return true;}
this code works fine, thanx
Afterwards, you still need to refresh the window with CWnd::DrawMenuBar();
|
|
|
|
|
When you double-click and select a text, it stores in memory. How can I get this?
kozlu
|
|
|
|
|
Where are you double-clicking the text, and how is it getting into memory. I am unclear of this, If you give a little more detail maybe I can help.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Any application which has an edit view, edit control etc. And getting in memory is my opinion... I searched messages with Spy++ tool when I double-click and selected the text but I couldn't find any...
kozlu
|
|
|
|
|
You can get the text from an edit control with the GetWindowText() function. You can also use the EM_ style messages if you look them up in MSDN or at MSDN.microsoft.com.
I think the message that you will be interested in is EM_GETSEL.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I am making server socket with CAsyncSocket. But I don't
get how to unlimited buffer for receive messages.
I don't know data length before I get it, and I
don't want to create constant Huge buffer, but just
buffer sized data length. This migth be simple
question, but i don't know how to do it.
|
|
|
|
|
Hi,,,
i have been writing a chat program both server side and client side by using MFC CAsyncSocket Class and i had succeded to implement and chat on our LAN at job.
It is really a good experience for me in both learning C++ and Visual C6.0 media. i have just wanted to consult ur precious knowledge about something i could not implement in my server side App.
Let me talk about a little bit about how Apps work:
İn My Server App, i create a Server Socket and make it listen for connection requests from clients. Clients ("these are my job friends. ..") make connections using my client App to my server App. so, i really know what happens at both side. When people connect to server, all they can talk to the same room and everybody sees what others said and they can whisper special messages to special users if they want like ordinary chat programs as well. Server handles every user information ( user name, IP_Address, OnOff time, Incoming Messages...etc,) in a structure that is a linked list created dynamically when each user connects and disconnects. Server adds and deletes all users to a dynamically created Socket Linked List. i also thought to try to create individual threads for each user connecting but since Linked list worked i gave up.
What is my problem is that. When someone writes a message while in room chat, Server takes this message from that user and sends it back to all users that are online ONE BY ONE. By this way everybody sees the written message in their Client App. It is not efficient for Server Processing time to distribute one message to all users one by one. It would be efficient for Server App to SEND BROADCAST messages to all users at one time. But since i don't use Windows Sockets but MFC i could not find my way.
Is it possible to send BROADCAST message while my server Socket and Client sockets are STREAM_SOCKET type ( i created my sockets from that type)
or is BROADCASTING a subject of only DATAGRAM_SOCKET type.
i don't know what will i do. Should i change my Application structure or is there another way that solves my problem.
i really think the future when lots of people connects and sends messages simultaneously. Server also handles a database that keeps special user information ( name, age, gender, height, weight, email adds...etc) and adds deletes and updates and sends them back whenever a user wants to see his/her user details like on ICQ.
So for my server App, dealing with all these tasks takes time and i want to use my Server Processing as efficient as possbile.
Thanks for ur helps...
Yours respectfully,
Atilla Selem
Electronics Engineer,
Aselsan A.Ş
www.aselsan.com.tr
|
|
|
|
|
If you work like this:-
BYTE buff[4096];
int nRead;
nRead = Receive(buff, 4096);
you will read up to 4096 bytes. Then process those 4096 bytes, and try to read again...
eg:
BYTE buff[4096];
int nRead=0;
do {
nRead = Receive(buff, 4096);
f.Write(buff,nRead);
} while (nRead == 4096);
that will get all data waiting on the socket and write it to a file.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
|
What about a simple way like that: Check for the size of the buffer return, if it is as big as your buffer, read the socket again and append it at the end of the buffer, keep doing that until the size returned is smaller than your buffer. That's the end of the packet!
Take a look at the code below:
unsigned char *BigBuff = NULL;
unsigned char buf[4096];
ULONG size = 4096;
ULONG rc = 0;
BOOL bMoreData = false;
ULONG TotalSize = 0;
do
{
bMoreData = true;
memset(&buf[0], 0, 4096);
rc = TcpRecv(SocAccepted, buf, size);
if ( rc == 0 )
{
goto end;
}
if ( rc == (ULONG)SOCKET_ERROR )
goto end;
TotalSize = TotalSize + rc;
if ( BigBuff == NULL )
{
BigBuff = (unsigned char *) malloc (rc+10);
if ( !BigBuff )
return NULL;
memcpy(BigBuff, buf, rc);
}
else
{
unsigned char *p = NULL;
p = (unsigned char *)realloc(BigBuff, TotalSize);
if ( !p )
{
free( BigBuff );
return NULL;
}
BigBuff = p;
memcpy(&BigBuff[TotalSize-rc], buf, rc);
}
if ( rc == size )
bMoreData = true;
}while(bMoreData);
end:
return (&BigBuff[0]);
|
|
|
|
|
Hi,
I am reading some books on C++ and MFC. It seems to me that without a solid understanding of C/C++ compiler, mastering C++ and MFC is a mission imposible. For example, CRuntimeClass, Message Map and RTTI etc. Any information on how and where to get materials on C/C++ compiler is greatly appreciated.
Thank you in advance.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
NicholasCougar wrote:
Any information on how and where to get materials on C/C++ compiler
Your best bet is a good text on compiler theory. I used the Dragon Book in college in 1984, but the same principles still apply today.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
NicholasCougar wrote:
For example, CRuntimeClass, Message Map and RTTI etc.
Heck, I must be in trouble - I've been programming C++ since late 92 and I've never needed to know how CRuntimeClass and RTTI work.
You can learn more about MFC in the book MFC Internals.
Michael
|
|
|
|
|
I try to measure the dimension for a text say "Hello".
I set mapping mode to MM_LOENGLISH.
CFont font;
font.CreatePointFont(360,"Verdana");
pDC->SelectObject(&font);
CSize sz = pDC->GetTextExtent("Hello");
the width sz.cx (1.19 inch) seems ok in real printing. But sz.cy (0.57inch) is greater than the actual (0.344inch) in printout. Can anyone tell me how to calculate the real height???
|
|
|
|
|
I believe that when windows calculates the height of characters it includes the height of the ascending and descending line of the font, not just the height of the character that you see. I am not 100% certain of this, but one way that you could test this is by calling getTextExtent on 5 different characters, and I believe the same height should come back for all of the characters.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
look up the font metrics stuff in msdn
there are all sorts of bits and pieces added together to get the bounding 'box' of text ... leading, ascenders, descenders, etc
all fun stuff if you have nothing else to do
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
Hello all -
I don't know if this is a limitation of the library or if it's just my computer. I can make 16 sucessfull calls to this function, and i get back a valid timer id, and the callback function i specify is called. After the 16th, it fails.
I should be clearer...i can Queue up 16 of them. if i try to call this 17 times before the 1st callback is fired, the 17th call fails. Anyone know if this is a limitation of the library - or just my computer?
Marcus Spitzmiller
"Ha ha, Stupid bloropope.." - Homer
|
|
|
|
|
This has been spammed here before, and the general consensus was that not only was this not a terribly compelling app, but it's offensive that you post your ads in the forums when there is a facility provided for people to buy advertising on the site if they want it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
CRichEditCtrl wants me to set the fontsize in twips, whatever that is. How can I set the font to something like Verdana 9.
Sprudling
|
|
|
|
|
|
Thanks, this was exactly what I wanted
Sprudling
|
|
|
|
|
CFont font;
font.CreatePointFont(90,"Verdana");
richctrl.SetFont(&font);
|
|
|
|
|
1440 twips = 1 inch
hmmmm ... wonder why guys don't use the twip measuring system more often?
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
I want the text in a CRichEditCtrl to appear as in a console, with the "latest" line at the bottom and all text bottomaligned, so that if there is just one line it'll be alone at the bottom. Is there a way of implementing this...?
Sprudling
|
|
|
|
|
You can use CRichEditCtrl::SetRect(). Apply the number of lines, the font height and some math.
|
|
|
|