请教: 怎样在在Button上分行显示?

hbhuyang 2005-11-24 10:47:58
各位: 谢谢了!
...全文
80 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
JasonHeung 2005-11-24
  • 打赏
  • 举报
回复
button1.Text = "Test\r\nCode";
不行就自己重载Button和重载OnPaint方法。
True1024 2005-11-24
  • 打赏
  • 举报
回复
查阅一下GDI+
再次简化代码,取消串口,直接显示结果,仍然有问题!!

疑问代码如下:
struct _USB_DATA_STRUCT
{
/*
unsigned char command_data[40];//release结果正确
int command_index;
int command_size;
int numofnod;
*/
int command_index;
int command_size;
int numofnod;
unsigned char command_data[40];//release结果错误

void SetData(unsigned char* pdata,int size)
{
if(size>40)
{
AfxMessageBox("数据太大,超范围!");
return;
}
memcpy(command_data,pdata,size);
}
};

void CTestprjDlg::OnButton1()
{
// TODO: Add your control notification handler code here
unsigned char ctem[32];//错误:32,103,104; 正确:105,110

USB_DATA_STRUCT CommandData;//需要填写要发送的数据

ctem[0]=0xee;
ctem[1]=0x01;
memset(ctem+2,0x00,30);

CommandData.SetData(ctem,32);

ShowTest(CommandData.command_data,32);
}

void CTestprjDlg::ShowTest(unsigned char* p,int nlen)
{
CString str = _T("");
for(int i=0;i <32;i++)
{
CString tmp_str;
tmp_str.Format("0x%02X ", p[i]);
str += tmp_str;
}
m_textctrl.SetWindowText(str);
}

//VC6

Debug版本没有问题,输出如:
EE 01 00 00 00...后面全0
Release版本(按Maximize speed优化)有问题,输出如:
EE 01 00 00 00 00 00 00 00 00 00 00 EE 01 00 00 00 00 00 00 00 00 00 00 EE 01 00 00 00 00 00 00

Release版本下,按以下修改没有问题。
1.调整ctem的大小。小于等于104有问题,大于等于105没有问题。
2.将ctem改为char* ctem;
ctem=new char[32];
没有问题。

3.优化方式由Maximize speed修改为Minimize code也没问题。

请教可能是什么原因?

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧