Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need help Opencv with MFC (Solved)

need help Opencv with MFC (Solved)

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++visual-studiodebuggingquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jawadali477
    wrote on last edited by
    #1

    hi, i am developing code using Opencv and MFC in vs 2008. i am getting error:

    error C2660: 'SetDlgItemTextW' : function does not take 2 arguments

    the complete code is:

    //headers files included

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif

    void mouseEvent( int evt, int x, int y, int flags, void* param );

    class CAboutDlg : public CDialog
    {
    public:
    CAboutDlg();
    .......
    .......
    protected:
    .......
    }:
    ........
    ........
    ........

    BEGIN_MESSAGE_MAP(Copencv01Dlg, CDialog)
    .......
    .......
    END_MESSAGE_MAP()

    // Copencv01Dlg message handlers

    BOOL Copencv01Dlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

           ........
           ........
    
    MoveWindow(0, 0, 500, 500, 1);
    AfxBeginThread(MyThreadProc, this);
    return TRUE;  
    

    }

    UINT Copencv01Dlg::MyThreadProc(LPVOID pParam)
    {
    Copencv01Dlg * me = (Copencv01Dlg *)pParam;
    me->MyThreadProc();
    return TRUE;
    }

    void Copencv01Dlg::MyThreadProc()
    {

    cvNamedWindow("MyWindow");
    
        //assigning the callback function for mouse events
        cvSetMouseCallback("MyWindow", mouseEvent, 0);
        IplImage\* img = cvLoadImage("box.png");
        cvShowImage("MyWindow", img);
        cvWaitKey(0);
        cvDestroyWindow("MyWindow");
        cvReleaseImage(&img);
    

    }

    void Copencv01Dlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    ........
    ........
    }

    void Copencv01Dlg::OnPaint()
    {
    .........
    .........
    }

    HCURSOR Copencv01Dlg::OnQueryDragIcon()
    {
    return static_cast(m_hIcon);
    }
    void mouseEvent(int evt, int x, int y, int flags, void* param)
    {
    if(evt==CV_EVENT_LBUTTONDOWN){
    CString cx, cy;
    cx.Format(_T("%d"), x);
    cy.Format(_T("%d"), y);
    SetDlgItemTextW(IDC_Blue, cx); //error generating line
    SetDlgItemTextW(IDC_Green, cy); //error generating line
    }
    }

    can anyone help me with this errors? Regards Jawad

    C J 2 Replies Last reply
    0
    • J jawadali477

      hi, i am developing code using Opencv and MFC in vs 2008. i am getting error:

      error C2660: 'SetDlgItemTextW' : function does not take 2 arguments

      the complete code is:

      //headers files included

      #ifdef _DEBUG
      #define new DEBUG_NEW
      #endif

      void mouseEvent( int evt, int x, int y, int flags, void* param );

      class CAboutDlg : public CDialog
      {
      public:
      CAboutDlg();
      .......
      .......
      protected:
      .......
      }:
      ........
      ........
      ........

      BEGIN_MESSAGE_MAP(Copencv01Dlg, CDialog)
      .......
      .......
      END_MESSAGE_MAP()

      // Copencv01Dlg message handlers

      BOOL Copencv01Dlg::OnInitDialog()
      {
      CDialog::OnInitDialog();

             ........
             ........
      
      MoveWindow(0, 0, 500, 500, 1);
      AfxBeginThread(MyThreadProc, this);
      return TRUE;  
      

      }

      UINT Copencv01Dlg::MyThreadProc(LPVOID pParam)
      {
      Copencv01Dlg * me = (Copencv01Dlg *)pParam;
      me->MyThreadProc();
      return TRUE;
      }

      void Copencv01Dlg::MyThreadProc()
      {

      cvNamedWindow("MyWindow");
      
          //assigning the callback function for mouse events
          cvSetMouseCallback("MyWindow", mouseEvent, 0);
          IplImage\* img = cvLoadImage("box.png");
          cvShowImage("MyWindow", img);
          cvWaitKey(0);
          cvDestroyWindow("MyWindow");
          cvReleaseImage(&img);
      

      }

      void Copencv01Dlg::OnSysCommand(UINT nID, LPARAM lParam)
      {
      ........
      ........
      }

      void Copencv01Dlg::OnPaint()
      {
      .........
      .........
      }

      HCURSOR Copencv01Dlg::OnQueryDragIcon()
      {
      return static_cast(m_hIcon);
      }
      void mouseEvent(int evt, int x, int y, int flags, void* param)
      {
      if(evt==CV_EVENT_LBUTTONDOWN){
      CString cx, cy;
      cx.Format(_T("%d"), x);
      cy.Format(_T("%d"), y);
      SetDlgItemTextW(IDC_Blue, cx); //error generating line
      SetDlgItemTextW(IDC_Green, cy); //error generating line
      }
      }

      can anyone help me with this errors? Regards Jawad

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      You didn't pass the handle of the dialog window as first argument to the function (see SetDlgItem[^]).

      Veni, vidi, vici.

      J 1 Reply Last reply
      0
      • J jawadali477

        hi, i am developing code using Opencv and MFC in vs 2008. i am getting error:

        error C2660: 'SetDlgItemTextW' : function does not take 2 arguments

        the complete code is:

        //headers files included

        #ifdef _DEBUG
        #define new DEBUG_NEW
        #endif

        void mouseEvent( int evt, int x, int y, int flags, void* param );

        class CAboutDlg : public CDialog
        {
        public:
        CAboutDlg();
        .......
        .......
        protected:
        .......
        }:
        ........
        ........
        ........

        BEGIN_MESSAGE_MAP(Copencv01Dlg, CDialog)
        .......
        .......
        END_MESSAGE_MAP()

        // Copencv01Dlg message handlers

        BOOL Copencv01Dlg::OnInitDialog()
        {
        CDialog::OnInitDialog();

               ........
               ........
        
        MoveWindow(0, 0, 500, 500, 1);
        AfxBeginThread(MyThreadProc, this);
        return TRUE;  
        

        }

        UINT Copencv01Dlg::MyThreadProc(LPVOID pParam)
        {
        Copencv01Dlg * me = (Copencv01Dlg *)pParam;
        me->MyThreadProc();
        return TRUE;
        }

        void Copencv01Dlg::MyThreadProc()
        {

        cvNamedWindow("MyWindow");
        
            //assigning the callback function for mouse events
            cvSetMouseCallback("MyWindow", mouseEvent, 0);
            IplImage\* img = cvLoadImage("box.png");
            cvShowImage("MyWindow", img);
            cvWaitKey(0);
            cvDestroyWindow("MyWindow");
            cvReleaseImage(&img);
        

        }

        void Copencv01Dlg::OnSysCommand(UINT nID, LPARAM lParam)
        {
        ........
        ........
        }

        void Copencv01Dlg::OnPaint()
        {
        .........
        .........
        }

        HCURSOR Copencv01Dlg::OnQueryDragIcon()
        {
        return static_cast(m_hIcon);
        }
        void mouseEvent(int evt, int x, int y, int flags, void* param)
        {
        if(evt==CV_EVENT_LBUTTONDOWN){
        CString cx, cy;
        cx.Format(_T("%d"), x);
        cy.Format(_T("%d"), y);
        SetDlgItemTextW(IDC_Blue, cx); //error generating line
        SetDlgItemTextW(IDC_Green, cy); //error generating line
        }
        }

        can anyone help me with this errors? Regards Jawad

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        There are multiple versions of SetDlgItemText(): The Windows API version that requires three parameters (first is the handle of the dialog window) and the MFC versions. Because your mouseEvent() function is not a member of any class, the first version is used. The error will disappear when correcting your function to:

        void Copencv01Dlg::mouseEvent(int evt, int x, int y, int flags, void* param)

        1 Reply Last reply
        0
        • C CPallini

          You didn't pass the handle of the dialog window as first argument to the function (see SetDlgItem[^]).

          Veni, vidi, vici.

          J Offline
          J Offline
          jawadali477
          wrote on last edited by
          #4

          i'm new in programming, specially in MFC. my understanding of handle is weak. so can you please help me in this regard. means how to pass the handle of dialog window to SetDlgItemText()? any example please. Regards Jawad

          L 1 Reply Last reply
          0
          • J jawadali477

            i'm new in programming, specially in MFC. my understanding of handle is weak. so can you please help me in this regard. means how to pass the handle of dialog window to SetDlgItemText()? any example please. Regards Jawad

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I already explained this to you in this answer[^]. If you do not understand how to use the Win32 API then you should go to MSDN[^] and spend some time studying the basics. Alternatively get a copy of a book on Windows Programming (Charles Petzold[^] has written some of the best). Trying to learn Windows programming by trial and error, and posting questions in this forum is likely to take you a long time.

            speaking as ...

            J 1 Reply Last reply
            0
            • L Lost User

              I already explained this to you in this answer[^]. If you do not understand how to use the Win32 API then you should go to MSDN[^] and spend some time studying the basics. Alternatively get a copy of a book on Windows Programming (Charles Petzold[^] has written some of the best). Trying to learn Windows programming by trial and error, and posting questions in this forum is likely to take you a long time.

              speaking as ...

              J Offline
              J Offline
              jawadali477
              wrote on last edited by
              #6

              thanks you Richard MacCutchan for your replies. that was really helpful.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups