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. error C2660 :,, opencv with mfc (Solved)

error C2660 :,, opencv with mfc (Solved)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
5 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'm developing dialog based GUI code for my project using opencv with mfc. i'm getting following error for the MouseCallback function which i don't understand why

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

    following is the code that causes this error

    void leftclick( int event, int x, int y, int flags, void* param )
    {
    if( event == CV_EVENT_LBUTTONDBLCLK )
    {
    CvScalar s;
    CString Blue, Green, Red;
    zoomed = (IplImage*) param;

    	s=cvGet2D(zoomed,x,y);		// get the (x,y) pixel value 
    	Blue.Format(\_T("%0.2f"), s.val\[0\]);
    	Green.Format(\_T("%0.2f"), s.val\[1\]);
    	Red.Format(\_T("%0.2f"), s.val\[2\]);
    	SetDlgItemText(IDC\_Blue, Blue);   /error C2660
    	SetDlgItemText(IDC\_Green, Green);   /error C2660
    	SetDlgItemText(IDC\_Red, Red);   //error C2660
    }
    

    }

    this mouse event is being called in a thread as

    cvSetMouseCallback( "box.png", &leftclick, 0 );

    any idea what i'm missing. do i have to define the mouse event in the dialog class?? Regards Jawad

    _ S L J 4 Replies Last reply
    0
    • J jawadali477

      hi, i'm developing dialog based GUI code for my project using opencv with mfc. i'm getting following error for the MouseCallback function which i don't understand why

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

      following is the code that causes this error

      void leftclick( int event, int x, int y, int flags, void* param )
      {
      if( event == CV_EVENT_LBUTTONDBLCLK )
      {
      CvScalar s;
      CString Blue, Green, Red;
      zoomed = (IplImage*) param;

      	s=cvGet2D(zoomed,x,y);		// get the (x,y) pixel value 
      	Blue.Format(\_T("%0.2f"), s.val\[0\]);
      	Green.Format(\_T("%0.2f"), s.val\[1\]);
      	Red.Format(\_T("%0.2f"), s.val\[2\]);
      	SetDlgItemText(IDC\_Blue, Blue);   /error C2660
      	SetDlgItemText(IDC\_Green, Green);   /error C2660
      	SetDlgItemText(IDC\_Red, Red);   //error C2660
      }
      

      }

      this mouse event is being called in a thread as

      cvSetMouseCallback( "box.png", &leftclick, 0 );

      any idea what i'm missing. do i have to define the mouse event in the dialog class?? Regards Jawad

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You need to pass in the dialog handle as the first parameter to SetDlgItemText function because it is not being called from inside a CWnd derived class. So the SetDlgItemText function that you're calling is actually the Windows API - http://msdn.microsoft.com/en-us/library/windows/desktop/ms645521(v=vs.85).aspx[^]

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++)

      Polymorphism in C

      1 Reply Last reply
      0
      • J jawadali477

        hi, i'm developing dialog based GUI code for my project using opencv with mfc. i'm getting following error for the MouseCallback function which i don't understand why

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

        following is the code that causes this error

        void leftclick( int event, int x, int y, int flags, void* param )
        {
        if( event == CV_EVENT_LBUTTONDBLCLK )
        {
        CvScalar s;
        CString Blue, Green, Red;
        zoomed = (IplImage*) param;

        	s=cvGet2D(zoomed,x,y);		// get the (x,y) pixel value 
        	Blue.Format(\_T("%0.2f"), s.val\[0\]);
        	Green.Format(\_T("%0.2f"), s.val\[1\]);
        	Red.Format(\_T("%0.2f"), s.val\[2\]);
        	SetDlgItemText(IDC\_Blue, Blue);   /error C2660
        	SetDlgItemText(IDC\_Green, Green);   /error C2660
        	SetDlgItemText(IDC\_Red, Red);   //error C2660
        }
        

        }

        this mouse event is being called in a thread as

        cvSetMouseCallback( "box.png", &leftclick, 0 );

        any idea what i'm missing. do i have to define the mouse event in the dialog class?? Regards Jawad

        S Offline
        S Offline
        SoMad
        wrote on last edited by
        #3

        Since you are calling this from a thread and not from inside the dialog class, you have to pass the hWnd of the dialog as the first parameter to SetDlgItemText()[^]. You should know that doing this from another thread is a risky way. Soren Madsen

        1 Reply Last reply
        0
        • J jawadali477

          hi, i'm developing dialog based GUI code for my project using opencv with mfc. i'm getting following error for the MouseCallback function which i don't understand why

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

          following is the code that causes this error

          void leftclick( int event, int x, int y, int flags, void* param )
          {
          if( event == CV_EVENT_LBUTTONDBLCLK )
          {
          CvScalar s;
          CString Blue, Green, Red;
          zoomed = (IplImage*) param;

          	s=cvGet2D(zoomed,x,y);		// get the (x,y) pixel value 
          	Blue.Format(\_T("%0.2f"), s.val\[0\]);
          	Green.Format(\_T("%0.2f"), s.val\[1\]);
          	Red.Format(\_T("%0.2f"), s.val\[2\]);
          	SetDlgItemText(IDC\_Blue, Blue);   /error C2660
          	SetDlgItemText(IDC\_Green, Green);   /error C2660
          	SetDlgItemText(IDC\_Red, Red);   //error C2660
          }
          

          }

          this mouse event is being called in a thread as

          cvSetMouseCallback( "box.png", &leftclick, 0 );

          any idea what i'm missing. do i have to define the mouse event in the dialog class?? Regards Jawad

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

          You need to send the handle of the dialog to the thread because all thes window funcs come in two forms: The global: ::SetDlgItemText(HWND, IDC_Blue, Blue); And the Class Specific: myDlgItem->SetDlgItemText(IDC_Blue, Blue); or this->SetDlgItemText(IDC_Blue, Blue); 'this' is of course given for free if you are inside the actually controls class so you can write: SetDlgItemText(IDC_Blue, Blue); So, you are in a thread, NOT in the MFC class instance, so you need to pass the window handle to the thread in order to manipulate it there. Or even better create your own messaging system so you can send a message to the main window thread from your thread so the main window thread can do all the detailed work rathert than having to code it in your worker thread.

          1 Reply Last reply
          0
          • J jawadali477

            hi, i'm developing dialog based GUI code for my project using opencv with mfc. i'm getting following error for the MouseCallback function which i don't understand why

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

            following is the code that causes this error

            void leftclick( int event, int x, int y, int flags, void* param )
            {
            if( event == CV_EVENT_LBUTTONDBLCLK )
            {
            CvScalar s;
            CString Blue, Green, Red;
            zoomed = (IplImage*) param;

            	s=cvGet2D(zoomed,x,y);		// get the (x,y) pixel value 
            	Blue.Format(\_T("%0.2f"), s.val\[0\]);
            	Green.Format(\_T("%0.2f"), s.val\[1\]);
            	Red.Format(\_T("%0.2f"), s.val\[2\]);
            	SetDlgItemText(IDC\_Blue, Blue);   /error C2660
            	SetDlgItemText(IDC\_Green, Green);   /error C2660
            	SetDlgItemText(IDC\_Red, Red);   //error C2660
            }
            

            }

            this mouse event is being called in a thread as

            cvSetMouseCallback( "box.png", &leftclick, 0 );

            any idea what i'm missing. do i have to define the mouse event in the dialog class?? Regards Jawad

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

            thank you everyone..that was really helpful. thanks again. :)

            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