在使用MFC将图像显示到另一个对话框中发现问题 [英] Find problem in displaying an image to another dialog using MFC
问题描述
我在对话(图像分析仪)上做了一个按钮(彩色滤光片).当我单击此按钮时,将打开一个新对话框(滤色器).它具有三个单选按钮和确定按钮.当我选择一个单选按钮并单击确定时,它在同一对话框中显示图像,但是我希望当我单击确定按钮时,该对话框将关闭并且该图像将显示在dialog(image analyser)上.那我该怎么办呢?
图像分析器n滤色镜r名称.
这是我的确定按钮代码
i have made a button(color filter) on a dialogue(image analyser). when i click on this a new dialog(color filter) opens. it has three radio buttons and ok button. when i select one of the radio buttons and click on ok, it displays the image on the same dialog but i want that when i click on ok button the dialog will close and the image will display on dialog(image analyser). so wht should i do for this?
image analyser n color filter r names.
this my ok button code
void CColourDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CBitmap img;
CDC dc;
BITMAP bmp;
img.LoadBitmapW(IDB_BITMAP1);
img.GetBitmap(&bmp);
CDC* pDC = this->GetDC();
dc.CreateCompatibleDC(pDC);
CBitmap* pOld = dc.SelectObject(&img);
for(int y = 0; y BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc, 0, 0, SRCCOPY);
dc.SelectObject(pOld);
}
等待您的回复...........
waiting for ur reply...........
推荐答案
在滤色器按钮上单击处理程序,添加代码以将滤色器对话框显示为模态;然后在滤色器对话框调用EndDialog(IDOK)
的确定"按钮上单击处理程序,然后在滤色器按钮上单击处理程序,显示修改后的位图:
On the color filter button click handler, add code to show the color filter dialog as modal; then on the OK button click handler of your color filter dialog callEndDialog(IDOK)
, and back on the filter button click handler show the modiied bitmap:
// On your color filter dialog
class CFilterDialog
{
public:
int m_iSelection; // Ths will get the selected radio button index (0, 1, ...)
protected:
void DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
// Replace IDC_FIRST_RADIO_IN_TAB_ORDER with the ID of your first radio button
DDX_Radio(pDX, IDC_FIRST_RADIO_IN_TAB_ORDER, m_iSelection);
}
virtual void OnOK()
{
UpdateData(TRUE); // This will update m_iSelection basing on the UI state
// If no radio button is selected m_iSelected is -1 then avoid closing the dialog
if (m_iSelection >= 0) EndDialog(IDOK); // This will close the dialog
}
};
// On your image analyser class
void CColorAnalyser::OnColorFilterButtonClick()
{
CFilterDialog dlg(this);
// If you want to select one of the radio boxes as default add the following line:
dlg.m_iSelection = 0; // 0 for the first radio button, 1 for the second and so on...
if (dlg.DoModal() == IDOK)
{
switch (dlg.m_iSelection)
{
case 0:
// The first radio button has been choosen
break;
case 1:
// The second radio button has been choosen
break;
...
}
}
}
如果要在单击确定"按钮时关闭对话框,只需更改
此OK按钮的ID为IDOK.(不要忘记在按钮单击代码上调用CDialog :: OnOk().)
if you want to close dialog when clicking ok button just change
ID of this OK button to IDOK.( don''t forget to call CDialog::OnOk() on button click code).
这篇关于在使用MFC将图像显示到另一个对话框中发现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!