Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Freinds, I have made a dialog based Piano application in which i am handling Multitouch messages . I have two classes One is CMIDIKeyboard in which i am handling touch down messages as follows
LRESULT CMIDIKeyboard::OnTouchMessage( WPARAM wParam, LPARAM lParam ){
    //Insert handler code here to do something with the message 
   //or uncomment the following line to test
  //-------------------saurabh code-----------------------------------
             // Number of actual per-contact messages
	     UINT  cInputs  = (int) wParam;    
            
            // Allocate the storage for the parameters of the per-contact messages
            TOUCHINPUT* pInputs = new TOUCHINPUT[cInputs]; 
            if (pInputs == NULL)
            {   
		  return 0;
            }
            // Unpack message parameters into the array of TOUCHINPUT structures, each
            // representing a message for one single contact.
            if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT)))
            {
                // For each contact, dispatch the message to the appropriate message
                // handler.
                for (unsigned int i = 0; i < cInputs; i++)
                {
					 if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN)
					 {
						 CPoint point;
						 CRect rect;
						 GetClientRect(&rect);
						 point=CPoint(pInputs[i].x-     rect.left,pInputs[i].y-rect.top);
						m_CurrKey= CPianoCtrl::FindKey(point); 
						m_Keys[m_CurrKey]-    >NoteOn(m_NoteOnColor,rect);
						NotifyNoteOn(m_LowNote+m_CurrKey);  
                                        	   findchords(m_LowNote+m_CurrKey);
	  

                                                InvalidateRect(&rect);
		                                CWnd::OnTouchMessage(wParam,lParam);
						 			
                                 					
                     }
                    else if (pInputs[i].dwFlags & TOUCHEVENTF_UP)
                    {
				     

		    //MessageBox("touchup!", "touchup!", MB_OK);
		 // g_pIManipProc->ProcessUp(pInputs[i].dwID, (FLOAT)pInputs[i].x, (FLOAT)pInputs[i].y);
                    } 

                     else if (pInputs[i].dwFlags & TOUCHEVENTF_MOVE)
                    {
		    //MessageBox("touchmove!", "touchmove!", MB_OK);
                        //g_pIManipProc->ProcessMove(pInputs[i].dwID, (FLOAT)pInputs[i].x, (FLOAT)pInputs[i].y);
                    }
					                    
                }
            }
            else
            {
                // error handling, presumably out of memory
                ASSERT(FALSE && L"Error: failed to execute GetTouchInputInfo");
                delete [] pInputs;
		return 0;
                //break;
            }
            if (!CloseTouchInputHandle((HTOUCHINPUT)lParam))
            {
                // error handling, presumably out of memory
                ASSERT(FALSE && L"Error: failed to execute CloseTouchInputHandle");
                delete [] pInputs;
		return 0;
                //break;
            }
            delete [] pInputs; 
  //--------------------------------------------------------saurabh code ends-----------------
	//MessageBox("touch!", "touch!", MB_OK);
    return 0;
  }


But on playing the piano keys first touch is playing proper ,but more than 1 touch is playing on piano keys enabling the last key on the right side irrespective of the touch position.
//                  ----------------------
//                  | | || | | | || || | |
//                  | |_||_| | |_||_||_| |
//                  |  |  |  |  |  |  |  |
//                  ----------------------
//                          ^           ^
                            |           |
                        one point    More than
                          touch      one touch


Can anybody please guide me or correct me please.
Posted
Updated 30-Sep-13 9:54am
v2
Comments
pasztorpisti 30-Sep-13 9:22am    
Does you device support multitouch?
SaurabSaini 30-Sep-13 23:02pm    
Yes i am using acer tab which supports Multitouch

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