Click here to Skip to main content
15,891,629 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWinApp DLL communication Pin
Tim Craig3-Apr-10 16:07
Tim Craig3-Apr-10 16:07 
GeneralRe: CWinApp DLL communication Pin
hxhl953-Apr-10 16:10
hxhl953-Apr-10 16:10 
QuestionIE8 and ShellExecute weirdness Pin
Monty23-Apr-10 9:41
Monty23-Apr-10 9:41 
AnswerRe: IE8 and ShellExecute weirdness Pin
LunaticFringe3-Apr-10 12:37
LunaticFringe3-Apr-10 12:37 
GeneralRe: IE8 and ShellExecute weirdness Pin
Luc Pattyn3-Apr-10 13:41
sitebuilderLuc Pattyn3-Apr-10 13:41 
GeneralRe: IE8 and ShellExecute weirdness Pin
LunaticFringe3-Apr-10 16:08
LunaticFringe3-Apr-10 16:08 
QuestionIP information class/function Pin
includeh103-Apr-10 8:25
includeh103-Apr-10 8:25 
AnswerRe: IP information class/function Pin
Moak3-Apr-10 8:38
Moak3-Apr-10 8:38 
QuestionKey press detection and while loop problem Pin
User 68017803-Apr-10 8:21
User 68017803-Apr-10 8:21 
Questiona simple VC++ scrolling display Pin
Alan Kurlansky3-Apr-10 3:17
Alan Kurlansky3-Apr-10 3:17 
AnswerRe: a simple VC++ scrolling display Pin
Maximilien3-Apr-10 3:43
Maximilien3-Apr-10 3:43 
GeneralRe: a simple VC++ scrolling display Pin
Alan Kurlansky3-Apr-10 3:57
Alan Kurlansky3-Apr-10 3:57 
AnswerRe: a simple VC++ scrolling display Pin
Richard MacCutchan3-Apr-10 4:35
mveRichard MacCutchan3-Apr-10 4:35 
AnswerRe: a simple VC++ scrolling display Pin
Moak3-Apr-10 4:37
Moak3-Apr-10 4:37 
Alan Kurlansky wrote:
To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window.


Hi Alan! I suggest an alternative approach without multi threading to get up and running quickly:

1) create a new MFC project and add a CListBox control: Using the CListBox control[^], this comes with a working example dialog project.
2) Add a TCP client socket such as CAsyncSocket to your dialog: Socket Programming with MFC (Part 1)[^], this will also explain which initialisation is needed in your application.
3) Add a button to your dialog so you can connect/disconnect to a server.

The client will tell you in its OnReceive()[^] handler when more data is available, you can add this to the listbox with AddString()[^] and scroll listbox with SendMessage(WM_VSCROLL, SB_BOTTOM, NULL). There are many ways to communicate between socket and GUI, for starters you could give the socket object a pointer to your dialog. For example with a method OnReceiveText() that you call from your socket whenever a full text line is available:

// Add text to end of listbox and remove old text
void CMyDlg::OnReceiveText(const char* szText)
{
	m_listbox.AddString(szText); 
	m_output.SendMessage(WM_VSCROLL, SB_BOTTOM, NULL);
	while(m_output.GetCount() > 10000) m_output.DeleteString(0);
}


Hope this helps Smile | :)
/Moak

Webchat in Europe Java | [Coffee] Now with 26% more Twitter


QuestionMessage Removed Pin
2-Apr-10 22:47
ozmrdn2-Apr-10 22:47 
AnswerRe: 8 puzzle game C,C++ source code Pin
Richard MacCutchan2-Apr-10 22:49
mveRichard MacCutchan2-Apr-10 22:49 
GeneralRe: 8 puzzle game C,C++ source code Pin
ozmrdn2-Apr-10 22:59
ozmrdn2-Apr-10 22:59 
GeneralRe: 8 puzzle game C,C++ source code Pin
Richard MacCutchan2-Apr-10 23:10
mveRichard MacCutchan2-Apr-10 23:10 
GeneralRe: 8 puzzle game C,C++ source code Pin
ozmrdn2-Apr-10 23:14
ozmrdn2-Apr-10 23:14 
GeneralRe: 8 puzzle game C,C++ source code Pin
Richard MacCutchan2-Apr-10 23:23
mveRichard MacCutchan2-Apr-10 23:23 
GeneralRe: 8 puzzle game C,C++ source code Pin
ozmrdn2-Apr-10 23:36
ozmrdn2-Apr-10 23:36 
GeneralRe: 8 puzzle game C,C++ source code Pin
Graham Breach3-Apr-10 3:38
Graham Breach3-Apr-10 3:38 
GeneralRe: 8 puzzle game C,C++ source code Pin
LunaticFringe3-Apr-10 0:30
LunaticFringe3-Apr-10 0:30 
GeneralRe: 8 puzzle game C,C++ source code Pin
Tim Craig3-Apr-10 8:52
Tim Craig3-Apr-10 8:52 
GeneralRe: 8 puzzle game C,C++ source code Pin
Richard MacCutchan3-Apr-10 9:46
mveRichard MacCutchan3-Apr-10 9:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.