Solved

Stylus tap position

Posted on 2010-09-18
7
515 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cheap and best smart phone 19 90
iPhone Vibration Programming Question 2 76
block certain incoming call for cetain time 5 63
Droid 4 15 61
This article shows how to setup the internet connectivity on Windows Mobile Emulator.   I assume that you already have Microsoft Visual Studio, Microsoft Windows Mobile SDK's and the emulator installed. The emulator is available with Visual Studi…
A short article about problems I had with the new location API and permissions in Marshmallow
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now