Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C++
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...........
Posted
Updated 16-Jun-10 2:36am
v4
Comments
Moak 16-Jun-10 7:55am    
Removed unnecessary code... can you please spell check your question?
Sweety Khan 16-Jun-10 7:59am    
oh i always try to write perfect but you always find mistake :(
Moak 16-Jun-10 8:33am    
My apologies, I reverted back to your version.
Richard MacCutchan 16-Jun-10 8:37am    
Your code is displaying the image in the OnBnClickedButton1 event; perhaps if you move that code to the other dialog it will work. Or have I misunderstood your question?
Sweety Khan 16-Jun-10 8:49am    
yes. actually there are two dialog boxes. one is main and one is for choosing the colour filter. when the user choose the colour and click on ok, this dialog should close and in the main dialog the image should display in the specified colour.

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 call EndDialog(IDOK), and back on the filter button click handler show the modiied bitmap:

C++
// 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;

      ...
      }
   }
}
 
Share this answer
 
v2
Comments
buyong 13-Jul-10 23:30pm    
Reason for my vote of 5
I think this is just solved the problem
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).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900