error C2660 :,, opencv with mfc (Solved)
-
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
-
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
You need to pass in the dialog handle as the first parameter to
SetDlgItemText
function because it is not being called from inside aCWnd
derived class. So theSetDlgItemText
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.
-
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
-
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
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.
-
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
thank you everyone..that was really helpful. thanks again. :)