locked
trapping key event and touch events RRS feed

  • Question

  • Hi,
    I am a newbie to windows mobile,but have worked on other mobile platform.But windows mobile seems quite different for me,as i am trying to detect an event in touch screen like touch event on particuler button or keyboard,how can i detect those events?Please someone help me.....and i am working on windows mobile SDK 6.0 using VC++ ....how to detect events in that though theres a method called WindProc but how can i detect keyboard event?.... anu suggestion ,advice,guidance is welcome....

     

    Thanks

    Wednesday, April 8, 2009 8:29 AM

Answers

  • Hi Deep Prash,

    Base on my understanding, you want to detect key press and mouse click event, if I have misunderstood you, please let me know.

    Yes, like you said, we can capture it via WindProc, but have to subclass the control first. like the code below:

    LRESULT CCursorTestButton1::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    
    
    
    {
    
    
    
    
    
    
    
    	 switch(message)
    
    
    
    	 {
    
    
    
    	 case WM_MBUTTONDOWN:
    
    
    
    		 AfxMessageBox(L"capture mouse press",0,0);
    
    
    
    		 break;
    
    
    
    	 case WM_KEYDOWN:
    
    
    
    		 AfxMessageBox(L"capture key press",0,0);
    
    
    
    		 break;
    
    
    
    	
    
    
    
    	 }
    
    
    
    
    
    
    
    	return CDialog::WindowProc(message, wParam, lParam);
    
    
    
    }
    
    
    
    

    For how to subclass control, you can find lots of sample on the web.
    I don't try the code, please try it and let me know the result.

    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, April 10, 2009 7:23 AM
  • Hi Deep,

    Yes, like you said, we can ShowWindow to hide current application. For how to set it foreground, we can use SetForegroundWindow to activate the application again. If you want to activate it by pressing some key, we have to do a hook, you can find a sample in following thread:

    http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/0b309ad6-1089-464e-8957-c7945f4d7234/



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by Deep Prash Monday, April 13, 2009 11:34 AM
    Monday, April 13, 2009 6:51 AM
  • Hi Deep,

    If you are using c#, you have to install Compact framework to device, not .net framework. There is no alternative way, we have to install CF to device.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by Deep Prash Tuesday, April 14, 2009 4:19 AM
    Tuesday, April 14, 2009 2:44 AM

All replies

  • Hi

    look here


    http://www.codeproject.com/KB/mobile/IPhoneUI.aspx

    thank you
    RRave
    Wednesday, April 8, 2009 3:55 PM
  • Hi Deep Prakash,


    In C#.Net in CF for catch the keyboard event then you have to you form KeyDown Event and catching the mouse touch event you can use mouse down event.


    Cheer

    Hope that this may be help.
    Pavan Pareta | If you find my post is helpful for you then mark as a answer.
    • Proposed as answer by WmDev Wednesday, April 8, 2009 8:38 PM
    Wednesday, April 8, 2009 8:37 PM
  • Thanks a lot guys for help...but my question is i am developing application in native code using VC++ ,so can you guide in that how to detect a touch event on particular button?or can you just tell me how any event is detected?... i am totally new to windows mobile so donno how to handle can you provide any sample code which illustrates events like hello world...
    Thanks
    Thursday, April 9, 2009 6:20 AM
  • Hi Deep Prash,

    Base on my understanding, you want to detect key press and mouse click event, if I have misunderstood you, please let me know.

    Yes, like you said, we can capture it via WindProc, but have to subclass the control first. like the code below:

    LRESULT CCursorTestButton1::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    
    
    
    {
    
    
    
    
    
    
    
    	 switch(message)
    
    
    
    	 {
    
    
    
    	 case WM_MBUTTONDOWN:
    
    
    
    		 AfxMessageBox(L"capture mouse press",0,0);
    
    
    
    		 break;
    
    
    
    	 case WM_KEYDOWN:
    
    
    
    		 AfxMessageBox(L"capture key press",0,0);
    
    
    
    		 break;
    
    
    
    	
    
    
    
    	 }
    
    
    
    
    
    
    
    	return CDialog::WindowProc(message, wParam, lParam);
    
    
    
    }
    
    
    
    

    For how to subclass control, you can find lots of sample on the web.
    I don't try the code, please try it and let me know the result.

    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, April 10, 2009 7:23 AM
  • Hi Guang-Ming Bian ,Thanks a lot for your reply...but right now i am lookin for those event which my application can detect.As i have kept my application in WS_HIDE state,but i want that my application should be visible on any key event or any notification like if i press call button only it should be visible...is it possible... code to hide is

    ShowWindow(hWnd, SW_HIDE);

    UpdateWindow(hWnd);

    i have used a dummy project to check if i cab put my application in background like this and activate on call button click,is it the right way to do so?can you tell me how can i put my app in background and put in foreground on any event?

    Thanks for your help.

    Friday, April 10, 2009 10:38 AM
  • Hi Deep,

    Yes, like you said, we can ShowWindow to hide current application. For how to set it foreground, we can use SetForegroundWindow to activate the application again. If you want to activate it by pressing some key, we have to do a hook, you can find a sample in following thread:

    http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/0b309ad6-1089-464e-8957-c7945f4d7234/



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by Deep Prash Monday, April 13, 2009 11:34 AM
    Monday, April 13, 2009 6:51 AM
  • Hi,
    Thanks a looooooooooooot  Guang-Ming Bian ,but as i realized that there are very less help on VC++,i have started using C# but i want to know if i develop application using .net framework do i need to install same framework on device too to run my application?And what alternative is there to this...?
    Monday, April 13, 2009 11:36 AM
  • Hi Deep,

    If you are using c#, you have to install Compact framework to device, not .net framework. There is no alternative way, we have to install CF to device.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by Deep Prash Tuesday, April 14, 2009 4:19 AM
    Tuesday, April 14, 2009 2:44 AM
  • Oh :( but then you mean if i am trying to deploy my app through link or sms then do i need to provide link for compact framework also.I was using VC++ for this sake only as i don't need to install anything on device.What other languages can be used so i don't need to do this can you please guide me about this.Though i have read about languges and their drawbacks but little confuse...

    Thanks a lot for replying and guiding me.
    Tuesday, April 14, 2009 4:18 AM
  • Hi Deep,

    Now, we can use C++, c#, vb.net to develop smart device application via Visual Studio 2005/2008.

    c++: don't need to install anything

    VB.net and c#:  need to install CF


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Tuesday, April 14, 2009 9:25 AM