Please let me know how to learn GUI creation using MFC or any other method. I have made a chatting application using sockets on win32 console. I want it on GUI now. Please provide me with any link where I can learn the same.
Thanks for your response. I want to use MFC for GUI creation. I just want to create a edit box, a output box where chat can be seen, and a send button. Please tell me some one knows how to do it.
Well mate,
I have wressetled with the very same question for last few months. I dont think there is an simple anwer to it. You see you have got to get your head around generic programing and concencepts of callbacks. I got myself a book by Bjarne stroustrup Programming principles and practice using C++ The book is devided in to 4 parts and the second part teaches you about GUI using fltk.
It is probably not the best book in the world, but it certainly thougth me a lot. One of the exersizes is to read data into the inbox and draw a graf... I would suggest that you get a pdf of the book from somewhere see if you like it and the best thing would by to buy it. Also, be prepared to spend some time with it, it isnt going to happen over night.
Good luck mate
Actually, if he already has written a chat client I'd say that he is capable enough to learn in a short enough amount of time how to create a window and pass some text information to it.
And windows programming hasn't got anything to do with generic programming. In the first place, the Win32 API is written in C.
As words of encouragement to the OP, don't let yourself get confused by the weird syntax of the windows API - then again, if you already used winsock you probably already saw quite a bit of that.
Hey thanks guys for reply.
I am trying my hand with MFC. I am working since morning and its around 7 hours now. LOL
I have prepared a GUI for client. Connection with server is created using GUI. However, I am facing a little issue. Once the server send some thing, it is received in buffer at client. I am putting the data from buffer to output window (which is a EDIT BOX on GUI) of client using SetDlgItemText(). However, as the compiler reach SetDlgItemText() an error is flashed:
DEBUG ASSERTION FAILED!
FILE: winocc.cpp
Line 138
By debugging I came to know that error appears when SetDlgItemText() is called. I went to winocc.cpp at line 138 as well. There also the same function was pointed out.
1) Did you actually create a window for c?
2) Is the data you receive in buf a zero terminated string? You could be missing out the \0 at the end or something, did you already check that?
3) Is readthread an actual thread?
ok. Let me tell you brief about how the code is written.
I have created GUI using MFC application wizard.
below is the code for OK button on GUI:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void CGUI_chatDlg::OnOK()
{
// TODO: Add extra validation here
unsignedint connect, disconnect;
connect=IsDlgButtonChecked(IDC_RADIO1); //to connect to server. It is a radio button to connect to server. On GUI you need to click on this button and click OK.
disconnect=IsDlgButtonChecked(IDC_RADIO2);
if(connect==1)
{
client_program(); //Function where whole code to connect to server using winsock2 concepts.
}
// CDialog::OnOK();
}
Now code for client_program() is written below the above code:
Not listing the full code.
1 2 3 4 5 6 7 8 9 10
void client_program()
{
// all the code here
//connection to server
sd=connect(cd,(sockaddr*)&client,client_length);
_beginthread(Readthread,0,(void*)cd); //Thread to read data from server.
}