473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

centering context menu

131 128KB
I'm trying to position a context menu within a listview control (report style) so that when an item is right clicked, the menu pops up just below the selected item.

Here's what I'm trying, but the menu is displayed well outside my application border.
Expand|Select|Wrap|Line Numbers
  1. int index = SendMessage(hndLV, LVM_GETNEXTITEM, -1, (LPARAM)LVNI_SELECTED);
  2.  
  3. if(index != -1) {
  4.  
  5.    ZeroMemory(&cRect, sizeof(RECT));
  6.    cRect.left = LVIR_BOUNDS;
  7.  
  8.    SendMessage(hndLV, LVM_GETITEMRECT, (WPARAM)index, (LPARAM)&cRect);
  9.  
  10.    // create menu bits
  11.  
  12.    SetForegroundWindow(hwnd);
  13.    TrackPopupMenu(hMenu, TPM_VCENTERALIGN, cRect.right / 2, cRect.bottom / 2, 0, hwnd, NULL);
  14.  
  15.    // bits of code
  16. }
  17.  
I've tried various styles for the TrackPopupMenu function, but none seem to affect the position where I'd like it to be.

The index and item rect *appear* to be right when their values were printed out; however, the placement of the menu is way off. It seems more relative to the screen than the application.

How would I accomplish getting the menu within the bounds of the control?
Aug 26 '12 #1
0 24888

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
2
by: Michel | last post by:
I like to show a inbetween selfmade menu when rightclicking the page. So on the first line I want to add "Default right-click menu". So first I need to capture it, then I need to stop the...
1
by: VF | last post by:
I am using several menu items from my main menu in my context menu. For some reason, all the menu items that I use in the context menu no longer show up in my main menu! I thought that maybe the...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
19
by: BibhuAshish | last post by:
Hello, I have created a context menu in mozilla by using following code: function nrc(e) { var contextMenu; document.oncontextmenu = function (evt) { var srcElement; if (evt &&...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.