Solved

Stylus tap position

Posted on 2010-09-18
7
525 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
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 125 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android Permissions 2 197
smartphone app to record mileage, text info and text to speech 1 60
clear wireless internet to my laptop 5 65
Jailbreak and Rooting on mobile devices 10 144
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

785 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