当前位置: 代码迷 >> 综合 >> MFC 基本控件使用
  详细解决方案

MFC 基本控件使用

热度:43   发布时间:2024-01-16 18:09:05.0

1.IDC_EDIT

赋值(修改)

CString   cFilePath = dlg->GetPathName();
m_test = cFilePath;
CWnd *wnd = GetDlgItem(IDC_EDIT1);
wnd->SetWindowText(m_test);

读取

m_edit.GetWindowTextA(m_test);

2.打开文件窗口

static char file_ex[] = "Image files|*.jpg;*.gif;*.png;*.bmp|All files(*.*)|*.*||";//图片格式
CFileDialog* dlg = new CFileDialog(TRUE, NULL, NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, file_ex, NULL);
if (IDOK == dlg->DoModal())
{
}

3.图片读取及显示

		CPaintDC dc(this);CImage image;if (m_test != ""){CWnd *p = GetDlgItem(IDC_STATIC1);CRect rect;p->GetWindowRect(rect);ScreenToClient(rect);image.Load(m_test);image.Draw(dc, rect);}



  相关解决方案