20号开始学习vc++,学会了:
列表框加项目和调整行高:
void CListboxDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CListBox * plist=(CListBox*)GetDlgItem(IDC_LIST1);
char ch[1];
for(int i=1;i<=10;i++)
{
_itoa(i,ch,10);
plist->AddString(ch);
}
plist->SendMessage(416,0,50);
}
编辑框读写文本:
void CListboxDlg::OnButton2()
{
char str[255];
// TODO: Add your control notification handler code here
CEdit * pedit=(CEdit*)GetDlgItem(IDC_EDIT1);
pedit->SetWindowText("ytytytyty/r/nrytytdytdytdty");
pedit->GetWindowText(str,100);
MessageBox(str);
}
标签读写标题:
void CListboxDlg::OnButton5()
{
// TODO: Add your control notification handler code here
CStatic * pStatic=(CStatic*)GetDlgItem(IDC_STATIC3);
pStatic->SetWindowText("33434");
}
void CListboxDlg::OnButton3()
{
char str[255];
// TODO: Add your control notification handler code here
CStatic * pStatic=(CStatic*)GetDlgItem(IDC_STATIC1);
pStatic->GetWindowText(str,100);
MessageBox(str);
}
按钮读写标题:
void CListboxDlg::OnButton6()
{
// TODO: Add your control notification handler code here
CButton * pbutton =(CButton *)GetDlgItem(IDC_BUTTON6);
pbutton->SetWindowText("33434");
}
文本文件写出:
void CMainFrame::OnFileWrite()
{
// TODO: Add your command handler code here
int i;
FILE * pfile=fopen("c://1.txt","a");
for (i=0;i<=10;i++)
{
fwrite("werwetwetwetwetewtewtew/n",1,strlen("werwetwetwetwetewtewtew/n"),pfile);
};
fclose(pfile);
}
当然还有信息框使用。