network connection sometimes prevents updating of edit boxes??

Started by
3 comments, last by Yanroy 20 years, 8 months ago
About 50% of the time, when my program is connected to the server, I cannot get the values in my edit boxes to update in software. They''re supposed to change when you slide a slider control, and they work just fine offline, but as soon as the connection starts up, they stop updating (but not all the time!!) It''s maddening as heck I figured it was because it''s sending stuff to the server at the same time it''s updating the edit boxes, but I can''t see why that would affect it... here''s some relevant code:

void CRobotClientDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	CSliderCtrl *Slide = dynamic_cast<CSliderCtrl *>(pScrollBar);
	CString CmdStr;

	if (!Slide)
	{
		//MessageBox("Slider didn''t cast");

		CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
		return;
	}

	if (nSBCode != TB_THUMBTRACK)
	{
		CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
		return;
	}

	int i = Slide->GetDlgCtrlID() - 1100;
	if (i >= 0 && i <= 7) // it''s a PWM control

	{
		UpdateData();

		m_PWM_Edit[i] = (float)m_PWM[i].GetPos() / (float)10;
		
		// PWM1 needs to be made to agree with PWM0

		if (i == 0 && m_Lash)
		{
			m_PWM_Edit[1] = m_PWM_Edit[0];
			m_PWM[1].SetPos(m_PWM[0].GetPos());
		}

		UpdateData(FALSE);

		SendPWMValue(i);
	}
	
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

bool CRobotClientDlg::SendPWMValue(int PWM, bool Force)
{
	CString CmdStr;

	// don''t send anything if the timeout hasn''t expired, the send isn''t forced, and the send isn''t a stop command

	if (!ReadyToSendPWM && !Force && m_PWM_Edit[PWM] != 0)
		return true;

	if (theApp.Socket)
	{
		ReadyToSendPWM = false;
		CmdStr.Format("Ctrl.PWM%d:%.1f\r\n", PWM, m_PWM_Edit[PWM]);
		if (!theApp.Socket->Send(&CmdStr))
			return false;
		// TODO send if lashed

	}
	else
		return false;

	return true;
}
--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Advertisement
This is why MFC can be dangerous.

You''re probably using blocking sockets, which tie up the GUI thread while waiting for socket events. Although MFC''s implementation of blocking sockets is actually run in a separate thread just so this sort of thing doesn''t happen.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Several viruses monitor your typings when online.
I just removed W32.Bugbear.B from friends computer, and it stopped lagging in edit boxes

Just a warning...

Niko Suni

Heh... I''m using a department of defense computer for my dev work, and it''s virus protected out the wazoo... I doubt that''s the problem. From a little more digging, I''ve found that it seems to update the dialog with the wrong data, or maybe just at the wrong point in the code. Its not due to one of my calls to UpdateData()... it''s like something else is calling it.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

quote:Original post by Yanroy
Its not due to one of my calls to UpdateData()... it''s like something else is calling it.


That''s exactly what Bugbear seems to do...

However, i don''t think viruses are your problem then, what with your work environment and such...

Niko Suni

This topic is closed to new replies.

Advertisement