Sign in to follow this  
Quan Chi2

Displaying server messages in text box?

Recommended Posts

I'm making an IRC bot GUI and I want to display server messages I receive in a text box. How do I do this? I've already made a bot that recv()'d the messages and printed them in a console window(this was the console-based bot), but now I want to make those same messages display in the text box. Please help. I don't know Win32API well.
        do
        {
            recv(connection,buf,512,0);
            if (strncmp("PING", buf, 4) == 0)
            {
                printf("[-]Received PING... Sending PONG\n"); //This is what I want to be displayed in the text box...
                buf[1] = 'O';
                send(connection, buf, strlen(buf), 0);
            }
            if (strncmp("End of /MOTD command.", buf, sizeof(buf)))
            {
                send(connection,channel,strlen(channel),0);
                Sleep(1000);
            }
            printf("\n%s \n\n", buf, connection);  //This is what I want to be displayed in the text box...
        }while(1);
Thanks for the help.

Share this post


Link to post
Share on other sites
SetWindowText() (Or SetDlgItemText() if you're using dialogs) will set the text for a window - I.e. your text box child window.

EDIT:
If you want to append text, that's a little more involved - you can either buffer what you're sending, or insert text at the end of the control, by setting the selection to the end of the text with EM_SETSEL, then replacing it with your new text with EM_REPLACESEL

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
SetWindowText() (Or SetDlgItemText() if you're using dialogs) will set the text for a window - I.e. your text box child window.

EDIT:
If you want to append text, that's a little more involved - you can either buffer what you're sending, or insert text at the end of the control, by setting the selection to the end of the text with EM_SETSEL, then replacing it with your new text with EM_REPLACESEL


Thanks for the help, Steve. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this