Click here to Skip to main content
15,889,462 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Are MFC Timer(s) bad for performance in large projects (Vc++) Pin
Heng Xiangzhong8-Apr-14 2:04
Heng Xiangzhong8-Apr-14 2:04 
QuestionAdd MFC support to ATL COM DLL project Pin
john56322-Apr-14 23:53
john56322-Apr-14 23:53 
AnswerRe: Add MFC support to ATL COM DLL project Pin
Richard MacCutchan3-Apr-14 0:01
mveRichard MacCutchan3-Apr-14 0:01 
GeneralRe: Add MFC support to ATL COM DLL project Pin
john56323-Apr-14 1:18
john56323-Apr-14 1:18 
GeneralRe: Add MFC support to ATL COM DLL project Pin
Richard MacCutchan3-Apr-14 1:29
mveRichard MacCutchan3-Apr-14 1:29 
GeneralRe: Add MFC support to ATL COM DLL project Pin
john56323-Apr-14 1:54
john56323-Apr-14 1:54 
GeneralRe: Add MFC support to ATL COM DLL project Pin
Richard MacCutchan3-Apr-14 2:51
mveRichard MacCutchan3-Apr-14 2:51 
QuestionHow to know no message in WindowProc callback function? Pin
cedricvictor2-Apr-14 16:34
cedricvictor2-Apr-14 16:34 
Dear all:

I use two global variables UINT g_PreUsedSize and g_CurUsedSize in WindowProc callback function.

When I touch on my device, I will get WM_INPUT message continuous in WindowProc callback function,

and get a result->active_touch_count, and set it to g_CurUsedSize.


When I did not touch on my device, I wanna set 0 to g_CurUsedSize.

C++
LRESULT CALLBACK WindowProc (HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param)
{
   LRESULT result (0);

   switch (message)
   {
      case WM_DESTROY:
         PostQuitMessage (0); 
         break;

      case WM_SIZE:
         {
            switch (w_param)
            {
               case SIZE_MAXIMIZED:
               case SIZE_RESTORED:
               {
                   window_width = (float)(LOWORD (l_param));
                   window_height = (float)(HIWORD (l_param));
               }
               break;
            }
         }
         break;

        case WM_INPUT:
        {		
            UINT data_size (0);
            GetRawInputData ((HRAWINPUT)l_param, RID_INPUT,NULL, &data_size, sizeof (RAWINPUTHEADER));
            
            vector<BYTE> data;
            data.resize (data_size);

            if (GetRawInputData ((HRAWINPUT)l_param, RID_INPUT, &data [0], &data_size, sizeof(RAWINPUTHEADER)) != data_size)
            {
                OutputDebugString(TEXT("GetRawInputData does not return correct size !\n")); 
                break;
            }
              
            RAWINPUT* raw = (RAWINPUT*)(&data [0]);
           
            if (raw->header.dwType == RIM_TYPEHID) 
            {
                RID_DEVICE_INFO device_info;
	       UINT info_size = sizeof(RIDI_DEVICEINFO);
	       GetRawInputDeviceInfo ( raw->header.hDevice, RIDI_DEVICEINFO, (LPVOID)&device_info, &info_size);
				   
	       if(device_info.hid.dwVendorId = 0x0457)
	       {
     	           DigitizerData* result = (DigitizerData*)(raw->data.hid.bRawData);
					
                    g_CurUsedSize = result->active_touch_count;	
				
         	           BOOL bGot = FALSE;

		  if(g_CurUsedSize <= 5)
		  {
		      if(g_PreUsedSize <  g_CurUsedSize)
		      {
		        PlaySound(TEXT("C:\\default.wav"),NULL, SND_FILENAME|SND_ASYNC );
	              }
	          }
		  bGot = TRUE;
	       }
	   }

	   if(bGot)
	   {
              g_PreUsedSize =  g_CurUsedSize;
	   }
         }				 
     }
     result = DefWindowProc (window_handle, message, w_param, l_param);
 }
         break;

      default: 
         result = DefWindowProc (window_handle, message, w_param, l_param);
         break;
   }
   return result;
}



My question is:

1. How do I know my device send no data in WindowProc, if I did not touch?

Thank for your help, Victor
AnswerRe: How to know no message in WindowProc callback function? Pin
Richard MacCutchan2-Apr-14 21:32
mveRichard MacCutchan2-Apr-14 21:32 
QuestionImage processing discussion forum? Pin
Vaclav_31-Mar-14 8:49
Vaclav_31-Mar-14 8:49 
AnswerRe: Image processing discussion forum? Pin
SoMad31-Mar-14 9:55
professionalSoMad31-Mar-14 9:55 
AnswerRe: Image processing discussion forum? Pin
Chris Losinger31-Mar-14 10:37
professionalChris Losinger31-Mar-14 10:37 
AnswerRe: Image processing discussion forum? Pin
leon de boer1-Apr-14 5:21
leon de boer1-Apr-14 5:21 
GeneralRe: Image processing discussion forum? Pin
Vaclav_4-Apr-14 3:50
Vaclav_4-Apr-14 3:50 
GeneralRe: Image processing discussion forum - CCL "trace" issue ?? Pin
Vaclav_4-Apr-14 4:50
Vaclav_4-Apr-14 4:50 
GeneralRe: Image processing discussion forum - CCL "trace" issue ?? Pin
leon de boer13-Apr-14 3:17
leon de boer13-Apr-14 3:17 
QuestionBitwise operation for mod operation Pin
econy31-Mar-14 4:23
econy31-Mar-14 4:23 
AnswerRe: Bitwise operation for mod operation Pin
Richard MacCutchan31-Mar-14 21:38
mveRichard MacCutchan31-Mar-14 21:38 
AnswerRe: Bitwise operation for mod operation Pin
CPallini31-Mar-14 23:37
mveCPallini31-Mar-14 23:37 
QuestionDATABASE PROBLEM Pin
Fawaz Ajani31-Mar-14 1:01
Fawaz Ajani31-Mar-14 1:01 
AnswerRe: DATABASE PROBLEM Pin
Freak3031-Mar-14 4:42
Freak3031-Mar-14 4:42 
AnswerRe: DATABASE PROBLEM Pin
SujayG2-Apr-14 0:21
SujayG2-Apr-14 0:21 
QuestionRe: DATABASE PROBLEM Pin
David Crow2-Apr-14 17:27
David Crow2-Apr-14 17:27 
QuestionHow to use ReadFile API Read HID Device synchronous Pin
cedricvictor30-Mar-14 6:32
cedricvictor30-Mar-14 6:32 
AnswerRe: How to use ReadFile API Read HID Device synchronous Pin
Richard Andrew x6431-Mar-14 10:13
professionalRichard Andrew x6431-Mar-14 10:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.