vc问题,高手进。
我编了一个对话框程序,其中想用组合框代替代码m_ctrlComm.SetSettings("9600,n,8,1");中的数据。但是我给组合框加了变量后运行程序就没有任何...
我编了一个对话框程序,其中想用组合框代替代码m_ctrlComm.SetSettings("9600,n,8,1");中的数据。 但是我给组合框加了变量后运行程序就没有任何反应了,程序也不报错。就是点击运行后没有任何反应,连对话框都不弹出来。具体SCommTestDlg.cpp文件如下:
#include "stdafx.h"
#include "SCommTest.h"
#include "SCommTestDlg.h"
#include "mscomm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
.........
...........
BOOL CSCommTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
/*****************************************************初始组合框取值:
m_combo1.AddString("4800");
m_combo1.AddString("9600");
m_combo1.AddString("19200");
m_combo1.AddString("38400");
m_combo1.SetCurSel(1);
m_combo4.AddString("NONE");
m_combo4.AddString("ODD");
m_combo4.AddString("EVE");
m_combo4.SetCurSel(-1);
m_combo5.AddString("8");
m_combo5.AddString("7");
m_combo5.AddString("6");
m_combo5.AddString("5");
m_combo5.SetCurSel(0);
m_combo6.AddString("1");
m_combo6.AddString("2");
m_combo6.SetCurSel(0);
UpdateData(FALSE);
//*****************************************************/
m_ctrlComm.SetCommPort(1);
m_ctrlComm.SetInputMode(1);
m_ctrlComm.SetInBufferSize(1024);
m_ctrlComm.SetOutBufferSize(512);
//**************************************************设置波特率、校验位、数据位、停止位:
// m_ctrlComm.SetSettings("9600,n,8,1");
// m_ctrlComm.SetSettings("m_combo1.SetCurSel(1),n,m_combo5.SetCurSel(0),m_combo6.SetCurSel(0)");
m_ctrlComm.SetSettings("a,b,c,d");
UpdateData(FALSE);
if(!m_ctrlComm.GetPortOpen())
m_ctrlComm.SetPortOpen(TRUE);
m_ctrlComm.SetRThreshold(1);
m_ctrlComm.SetInputLen(0);
m_ctrlComm.GetInput();
// m_ctrlComm.SetOutBufferCount(0);
return TRUE; // return TRUE unless you set the focus to a control
}
...................
.................. 展开
#include "stdafx.h"
#include "SCommTest.h"
#include "SCommTestDlg.h"
#include "mscomm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
.........
...........
BOOL CSCommTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
/*****************************************************初始组合框取值:
m_combo1.AddString("4800");
m_combo1.AddString("9600");
m_combo1.AddString("19200");
m_combo1.AddString("38400");
m_combo1.SetCurSel(1);
m_combo4.AddString("NONE");
m_combo4.AddString("ODD");
m_combo4.AddString("EVE");
m_combo4.SetCurSel(-1);
m_combo5.AddString("8");
m_combo5.AddString("7");
m_combo5.AddString("6");
m_combo5.AddString("5");
m_combo5.SetCurSel(0);
m_combo6.AddString("1");
m_combo6.AddString("2");
m_combo6.SetCurSel(0);
UpdateData(FALSE);
//*****************************************************/
m_ctrlComm.SetCommPort(1);
m_ctrlComm.SetInputMode(1);
m_ctrlComm.SetInBufferSize(1024);
m_ctrlComm.SetOutBufferSize(512);
//**************************************************设置波特率、校验位、数据位、停止位:
// m_ctrlComm.SetSettings("9600,n,8,1");
// m_ctrlComm.SetSettings("m_combo1.SetCurSel(1),n,m_combo5.SetCurSel(0),m_combo6.SetCurSel(0)");
m_ctrlComm.SetSettings("a,b,c,d");
UpdateData(FALSE);
if(!m_ctrlComm.GetPortOpen())
m_ctrlComm.SetPortOpen(TRUE);
m_ctrlComm.SetRThreshold(1);
m_ctrlComm.SetInputLen(0);
m_ctrlComm.GetInput();
// m_ctrlComm.SetOutBufferCount(0);
return TRUE; // return TRUE unless you set the focus to a control
}
...................
.................. 展开
3个回答
展开全部
这个可能不是combox的问题,从你的程序看,你使用了vc的通信控件搞的串口程序,就时那个控件比较恶心,我之前也遇到这样的问题,你把工程目录下的:.ncb,.opt,.aps,.clw及debug文件夹等等能删除的。重新启动dsw文件,应该会ok;是在不行,把这个控件也删掉,重新加(之前还是把:.ncb,.opt,.aps,.clw及debug文件夹等等能删除的),你试一下,我就时这么搞好的~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-09-14
展开全部
接上面代码:
void CSCommTestDlg::OnOnComm()
{
// TODO: Add your control notification handler code here
VARIANT variant_inp;
COleSafeArray safearray_inp;
LONG len,k;
BYTE rxdata[2048];
CString strtemp;
if(m_ctrlComm.GetCommEvent()==2)
{
variant_inp=m_ctrlComm.GetInput();
safearray_inp=variant_inp;
len=safearray_inp.GetOneDimSize();
for(k=0;k<len;k++)
safearray_inp.GetElement(&k,rxdata+k);
for(k=0;k<len;k++)
{
BYTE bt=*(char*)(rxdata+k);
strtemp.Format("%c",bt);
m_strEditRXData+=strtemp;
}
}
UpdateData(FALSE);
}
.............
............
void CSCommTestDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
a=m_combo1.GetCurSel();
/* CString str1;
m_combo1.GetLBText(a,str1);
AfxMessageBox(str1);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo4()
{
// TODO: Add your control notification handler code here
b=m_combo4.GetCurSel();
/* CString str4;
m_combo4.GetLBText(b,str4);
AfxMessageBox(str4);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo5()
{
// TODO: Add your control notification handler code here
c=m_combo5.GetCurSel();
/* CString str5;
m_combo5.GetLBText(c,str5);
AfxMessageBox(str5);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo6()
{
// TODO: Add your control notification handler code here
d=m_combo6.GetCurSel();
/* CString str6;
m_combo6.GetLBText(d,str6);
AfxMessageBox(str6);
*/
UpdateData(FALSE);
}
组合框定义的变量是m_combo1---m_combo6.
void CSCommTestDlg::OnOnComm()
{
// TODO: Add your control notification handler code here
VARIANT variant_inp;
COleSafeArray safearray_inp;
LONG len,k;
BYTE rxdata[2048];
CString strtemp;
if(m_ctrlComm.GetCommEvent()==2)
{
variant_inp=m_ctrlComm.GetInput();
safearray_inp=variant_inp;
len=safearray_inp.GetOneDimSize();
for(k=0;k<len;k++)
safearray_inp.GetElement(&k,rxdata+k);
for(k=0;k<len;k++)
{
BYTE bt=*(char*)(rxdata+k);
strtemp.Format("%c",bt);
m_strEditRXData+=strtemp;
}
}
UpdateData(FALSE);
}
.............
............
void CSCommTestDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
a=m_combo1.GetCurSel();
/* CString str1;
m_combo1.GetLBText(a,str1);
AfxMessageBox(str1);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo4()
{
// TODO: Add your control notification handler code here
b=m_combo4.GetCurSel();
/* CString str4;
m_combo4.GetLBText(b,str4);
AfxMessageBox(str4);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo5()
{
// TODO: Add your control notification handler code here
c=m_combo5.GetCurSel();
/* CString str5;
m_combo5.GetLBText(c,str5);
AfxMessageBox(str5);
*/
UpdateData(FALSE);
}
void CSCommTestDlg::OnSelchangeCombo6()
{
// TODO: Add your control notification handler code here
d=m_combo6.GetCurSel();
/* CString str6;
m_combo6.GetLBText(d,str6);
AfxMessageBox(str6);
*/
UpdateData(FALSE);
}
组合框定义的变量是m_combo1---m_combo6.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
hi我一下
m_ctrlComm.SetSettings("m_combo1.SetCurSel(1),n,m_combo5.SetCurSel(0),m_combo6.SetCurSel(0)");
你这里用引号括起来,就是简单的字符串了,而不是你想要的组合框里的值
m_ctrlComm.SetSettings("m_combo1.SetCurSel(1),n,m_combo5.SetCurSel(0),m_combo6.SetCurSel(0)");
你这里用引号括起来,就是简单的字符串了,而不是你想要的组合框里的值
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询