?
Solved

Stylus tap position

Posted on 2010-09-18
7
Medium Priority
?
541 Views
Last Modified: 2013-12-27
I have made an application and the only GUI is an icon in tray. Im trying to popup a menu when the user click up to the icon but i can take the position of stylus tap. i dont want to make a tap and hold
Im trying the API GetCursorPos but its return an error that it tell that is unsupported for win mobile
According  the MSDN the LOWORD and HIWORD of event WM_LBUTTONDBLCLK  return the stylus position but the position tha return are wrong. Also im trying to use ClientToScreen API but still are wrong

Pleaze help!
0
Comment
Question by:Frog153
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33710125
That's the x and y from the click message:
x = LOWORD(lParam);
y = HIWORD(lParam);

It does work.

If you write an application for the system tray, you need Shell_NotifyIcon and you don't convert these coordinates.
CodeProject. Adding Icons to the System Tray
http://www.codeproject.com/kb/shell/systemtray.aspx
CodeProject. FindFirstChangeNotification & Shell_NotifyIcon together... again
http://www.codeproject.com/KB/system/FolderWatch.aspx
CodeProject.Basic use of Shell_NotifyIcon in Win32
http://www.codeproject.com/KB/shell/StealthDialog.aspx?msg=1632884
 
0
 

Author Comment

by:Frog153
ID: 33710809
here is my code that i use

the function OnTrayIcon from Message uCallbackMessage from NOTIFYICONDATA

LRESULT OnTrayIcon(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
      {
            // Is this the ID we want?
            if (wParam != m_nid.uID)
                  return 0;
            T* pT = static_cast<T*>(this);
            // Was the right-button clicked?
            
            if (LOWORD(lParam) == WM_LBUTTONUP)
            {
                  // Load the menu
                  CMenu oMenu;
                  if (!oMenu.LoadMenu(m_nid.uID))
                        return 0;
                  // Get the sub-menu
                  CMenuHandle oPopup(oMenu.GetSubMenu(0));
                  // Prepare
                  pT->PrepareMenu(oPopup);
                  // Get the menu position
                  CPoint pos;
                  DWORD messagepos = ::GetMessagePos(); /*Here is my problem i cant take the stylus tap postition.I have already use LOWORD(lParam) and HIWORD(lParam) */
                 
                  pos.x = GET_X_LPARAM(messagepos);
                  pos.y = GET_Y_LPARAM(messagepos);
               

                  
                  // Make app the foreground
                  SetForegroundWindow(pT->m_hWnd);
                  // Set the default menu item
                  /*if (m_nDefault == 0)
                        oPopup.SetMenuDefaultItem(0, TRUE);
                  else
                        oPopup.SetMenuDefaultItem(m_nDefault);*/
                  // Track
                  oPopup.TrackPopupMenu(TPM_LEFTALIGN, pos.x, pos.y, pT->m_hWnd);
                  // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly"
                  pT->PostMessage(WM_NULL);
                  // Done
                  oMenu.DestroyMenu();
            }
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33712066
 DWORD messagepos = ::GetMessagePos();
  WORD x = LOWORD(messagepos);
  WORD y = HIWORD(messagepos);

or, maybe:

pos = (CPoint(GetMessagePos()));

Use a trace/log utility to check the coordinates. They are correct and the problem can be somewhere in the menu. Check something simple like that:
::TrackPopupMenu(hMenu, 0, pos.x, pos.y, 0, hWnd, NULL);
::PostMessage(hWnd, WM_NULL, 0, 0);


Let's say that the problem is really in the coordinates. But this popup menu should jump in a more or less predefined position. At least for a test, use coordinates valid for your screen. If you will see the menu, so the reason was the coordinates as you suspected.
0
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
LVL 16

Expert Comment

by:hjgode
ID: 33759596
Hi

there is a great article at CodeProject about Notification Icons http://www.codeproject.com/KB/shell/StealthDialog.aspx 

Why do you need the tapped position, it is always within the Icon size. This notification icon is almost only 26x26 pixels. I dont see a need to track the clicked position for within the icon.

regards

Josef
0
 
LVL 16

Accepted Solution

by:
hjgode earned 500 total points
ID: 33761243
Hello

as far as we can assume, you are using a shell notification icon in the taskbar. The Shell_NotifyIcon API enables you to provide a callback, which is invoked, when the user clicks the notification icon in the taskbar:

   NOTIFYICONDATA notdata = new NOTIFYICONDATA();

   notdata.cbSize = 152;
   notdata.hIcon =  hIcon;
   notdata.hWnd = hwnd;
   notdata.uCallbackMessage = WM_NOTIFY_TRAY;
   notdata.uFlags = NIF_MESSAGE | NIF_ICON;
   notdata.uID = uID;

   Shell_NotifyIcon(dwMessage, ref notdata);

This notification message is generated by the OS and the message does NOT contain any click position data. The message sent to notify your main loop is WM_NOTIFY_TRAY and lParam has some additional information:

    switch(message)
    {
    case WM_NOTIFY_TRAY:
        switch(lParam)
        {
        case WM_LBUTTONDBLCLK:
            ShowWindow(hWnd, SW_RESTORE);
            break;
        case WM_RBUTTONDOWN:
        case WM_CONTEXTMENU:
            ShowContextMenu(hWnd);
        }
        break;
    case...

If you need a click position, you have to hook and get the position within the taskbar area. Here is an article on this advanced topic: http://knowledgepointer.wordpress.com/2008/12/13/programmatically-display-system-tray-icon-on-windows-mobile/

~josef
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34091378
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let me explain this picture a little bit.  First, in case you haven't already guessed, you are looking at my 2 phones, an Android Samsung Galaxy S5 on the left and an iPhone 5 on the right.  They are on their respective cradles on my desk.  But, you…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question