Member Avatar for mjv89

Hi,

I was wondering how I can add a button to my program to allow me to send a message. For example, if the user clicks a button called "Hello", it will send "Hello" to the receive part of my program.

To send an ordinary message, I am using the following code.

void CSimpleSendDialog::OnBnClickedSendButton()
{
	m_pSendText->GetWindowText(m_szSendBuf, SEND_BUFFER_SIZE);
	
	m_iSendLen = (int) strlen(m_szSendBuf);

	
	int iBytesSent = sendto(m_SendSOCKET, (char FAR *)m_szSendBuf, m_iSendLen, 0,
			(const struct sockaddr FAR *)&m_SendSockAddr, sizeof(m_SendSockAddr));


}

Thanks for reading and thanks in advance for any response.

Recommended Answers

All 3 Replies

Do you want the above function to be called when button "Hello" is clicked?

Member Avatar for mjv89

Yes please.

From the convention you have used to name the function, I believe you are using MFC.
Here is a tutorial on how to use Buttons.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.