|
Hey,
Does anyone have any c++ code that will connect two computers and allow them to communicate? For instance, if I type "hello world" one of the computers, it will appear on the screen of the other computer. I need something simple and it I believe it uses WinSock. If you have any code, please email it to me at gary.grinev@uconn.edu
Thank you
|
|
|
|
|
|
Hi,
I think this is way to complicated. I need something very simple. Do you have any code that I can just paste in and work. That program had multiple header files and so on...
|
|
|
|
|
rct23333 wrote:
Do you have any code that I can just paste in and work.
Sorry, no. Building a chat server and client requires a fair amount of effort. The article I pointed you to contains a number of classes that will greatly simplify your work.
If the article seems more than what you were hoping to digest, I respectfully suggest you take on a simpler task or (better yet), spend some time understanding the basics of client server communication. There are several articles at CP that you are likely to find helpful. And if you have specific questions, feel free to post them. We're here to help. Good luck!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Good evening.
I am MFC/C++ beginner and I have a question:
I want to put ascending numbers into a bitmap window by clicking and subsequently save that to disk (e.g. click:"1", click:"2" etc).
I see two possibilities:
Use TextOut: works nicely, but I cant save that. Is there a trick to make the Text a part of the bitmap?
Use MaskBlt: Then I'd draw small "number" icons into the bitmap.
Using the Class Wizard, I can only generate OnLButtonDown, but that doesnt have "CDC* pDC" in the parameter list. Trying to fix it gives me a GPF.
Please would someone be so kind and put me on the right tracks?
Thanks for any help
Harald
|
|
|
|
|
VogelH wrote:
Using the Class Wizard, I can only generate OnLButtonDown, but that doesnt have "CDC* pDC" in the parameter list. Trying to fix it gives me a GPF.
You can't change those methods, they are overridden from the base class. You should never paint outside the OnPaint method anyhow. To force OnPAint to be called, just call Invalidate();
VogelH wrote:
Use TextOut: works nicely, but I cant save that. Is there a trick to make the Text a part of the bitmap?
Yes, draw it onto the bitmap, instead of onto the screen. Then draw the bitmap to the screen DC.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
>>Yes, draw it onto the bitmap, instead of onto the screen. Then draw the bitmap to the screen DC.
Thanks Christian for your reply. But how would I exactly do that? Could you please steer some lines of example code towards me? I always get confused by all those context things.
Ive gotten this far now:
void CView::OnLButtonUp(UINT nFlags, CPoint point) <br />
{<br />
CClientDC dc(this);
CString str;<br />
<br />
str.Format("%d",m_intNr);
dc.TextOut (point.x, point.y,str);<br />
<br />
CScrollView::OnLButtonUp(nFlags, point);<br />
m_intNr++;<br />
}
Harald
|
|
|
|
|
This is a disaster. DON'T use CClientDC, for starters the bitmap probably isn't there, it's probably being drawn there in OnPaint. do all drawing there. Store your mouse position in a variable and call Invalidate to force a paint message.
THEN you need to create a CDC and select the bitmap into it, then draw the text into the CDC. THEN when you draw the bitmap into the CDC passed into the paint handler, it will have the text drawn onto it, instead of both the bitmap and the text being seperately drawn onto the screen.
Just to mess you up even more - if you use a CBitmap, it will be the bit depth of the screen, you can't change that. You should get a DIBSection wrapper instead, then you can specify bit depth.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Many thanks Christian!
I start to get the picture slowly
Greetings,
Harald
|
|
|
|
|
How can I check if the pogram is exit with;
CTRL+ALT+DEL ?
I need to be enable to see if the program exit.
I can see if someone exit the program from ALT+F4 and ESC or from the program.
|
|
|
|
|
You need to handle the WM_QUERYENDSESSION message. Windows will send out this message whenever the user chooses to end the session or when an application calls the ExitWindows() function.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ALT+F4 - Process WM_SYSCOMMAND and watch for SC_CLOSE
ESC Key - Process/watch for WM_CLOSE
'X' in upper right corner of window - Process/watch for WM_CLOSE
|
|
|
|
|
How do you disable the 'X'?
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
- -Uknown.
|
|
|
|
|
I have not tried it but this should work
CMenu *pSysMenu = GetSystemMenu(FALSE);
ASSERT(pSysMenu != NULL);
VERIFY(pSysMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND));
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I am not sure. I think you have to change the window's style to get the 'X' to go away.
I usually don't disable it so much as I just catch the WM_CLOSE and do not let the WM_CLOSE go through. It is polite to display a message box explaining to the user why the window can not be closed 'at this time'. Like 'You can not close this window because it is busy scanning e-mail right now' or something like that.
Of course, you might be closing for a more legitimate reason, like the user is logging off or Windows is shutting down, so you need to catch those events as well if you completely disable closing for a window.
|
|
|
|
|
Hi everyone.
I have a question concerning a timeout value for connect() calls.
I tried to solve the problem by using non-blocking socket, but that causes winsock to return WSAEWOULDBLOCK (I already know the reason for that error!).
Are there better ways to handle this?
Don't try it, just do it!
|
|
|
|
|
The setsockopt can help you set the TimeOut value for Connect(...) Call.
Alexander M. wrote:
causes winsock to return WSAEWOULDBLOCK (I already know the reason for that error!).
I consider this error as warning only and never bother about it, till my socket is functioning
"I Think this Will Help"
[Vote One Here, Complete my Survey....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi all,
I have created multiple desktops in VC++ and I am able to switch between them. I can capture the active desktop but cannot find a way to capture inactice(other)desktops. By capturing I mean to store the desktop in memory or a buffer and access that storage area later. I tried by creating DC for inactive desktop but that returns with error If by ny chance capturing is not possible, is there ny way to access the inactive desktop's heap?? Can nyone help me with this?? Waiting....
|
|
|
|
|
I have not done this, but I would try this starting point:
Loop EnumWindowStations -> Loop EnumDesktops -> Loop EnumDesktopWindows
You can possibly get DC once you have a window handle.
Assuming you have enough security, you should be able to enumerate all windows in entire system.
|
|
|
|
|
Is it possible to draw a window within another window, for example if I had 3 dialog windows layed out how I wanted them and a parent window, I would like to have the dialog window displayed as part of the parent window.
|
|
|
|
|
yes it's possible ... create your dialogs as child or the parent window.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
How would I do that at runtime with existing windows? Is there a way to set a window to "child" and draw it within the parent at runtime?
|
|
|
|
|
See here and here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for the links but I'm not talking about keeping a window within an MDI window, I want the contents of the window (i.e. the controls etc) drawn in the parent window, not as a seprarate dialog on top of the window.
|
|
|
|