Frog153
asked on
Stylus tap position
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!
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!
ASKER
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();
}
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_
// Set the default menu item
/*if (m_nDefault == 0)
oPopup.SetMenuDefaultItem(
else
oPopup.SetMenuDefaultItem(
// Track
oPopup.TrackPopupMenu(TPM_
// BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly"
pT->PostMessage(WM_NULL);
// Done
oMenu.DestroyMenu();
}
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.
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.
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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. FindFirstChangeNotificatio
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