how to use TrackPopupMenu last parameter

Hi,

I need to make a menu that does not disappear.
(Odd, yes.  I need to let users edit menu resources at runtime and
would like to display the menus as how they would actually look.)

So I'm looking at CMenu's TrackPopupMenu function, whose last
parameter is LPCRECT lpRect.  I figure if I set this rectangle to be
(0, 0, screen width, screen height), then even if the user clicks
elsewhere on the screen, the menu won't disappear, right?

I tried the following code and the menu still disappears when I
randomly click elsewhere in the application.  What am I doing wrong?

void CMenuView::OnDraw(CDC* pDC)
{
	CWnd*  pMainWindow = AfxGetMainWnd();

	// Just testing with the File popup menu to see if works
	CMenu* pTopLevelMenu = pMainWindow->GetMenu();
	CMenu* pFileMenu = pTopLevelMenu->GetSubMenu(0);

	CRect rect(0, 0, 999, 999);	// I've tried both of these
//	RECT rect = {0, 0, 999,999};

    // Display the File popup menu as a floating popup menu in the
    // client area of the main application window.
    pFileMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
		0,
		0,
		this,
		rect);		// usually default to NULL
}

Thanks in advance!!!
0
floobles (5)
11/22/2004 9:38:02 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
960 Views

Similar Articles

[PageSpeed] 4

Boo...
Apparently, CMenu's TrackPopupMenu just uses the API ::TrackPopupMenu
which ignores the LPCRECT parameter...

Does anyone know how else to prevent the menu from being dismissed?

A friend suggested this way:

// We assume that the menu is dismissed as soon as it loses focus.
// Therefore, our idea is to steal focus to the main window as soon
// as the menu is created
// However, it doesn't work, is something wrong with the logic or
// am I doing anything wrong?

// In CMenuView
PostMessage(WM_USER) to main window;
TrackPopUpMenu(...);

// In CMainFrame
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_MESSAGE(WM_USER, OnUser)
END_MESSAGE_MAP()

LRESULT CMainFrame::OnUser(WPARAM wp, LPARAM lp)
{
   this->SetCapture();
   this->SetFocus();
   ReleaseCapture();
   return 0L;
}

I am very anxious to get this working =(
Thanks for any help!!


floobles@gmail.com (floobles) wrote in message news:<d9632d0f.0411221338.100dd826@posting.google.com>...
> Hi,
> 
> I need to make a menu that does not disappear.
> (Odd, yes.  I need to let users edit menu resources at runtime and
> would like to display the menus as how they would actually look.)
> 
> So I'm looking at CMenu's TrackPopupMenu function, whose last
> parameter is LPCRECT lpRect.  I figure if I set this rectangle to be
> (0, 0, screen width, screen height), then even if the user clicks
> elsewhere on the screen, the menu won't disappear, right?
0
floobles (5)
11/24/2004 4:16:23 PM
Wouldn't it be easier to put the menu on a dialog box when it's being 
edited?

-- 
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


"floobles" <floobles@gmail.com> wrote in message 
news:d9632d0f.0411240816.173aed55@posting.google.com...
> Boo...
> Apparently, CMenu's TrackPopupMenu just uses the API ::TrackPopupMenu
> which ignores the LPCRECT parameter...
>
> Does anyone know how else to prevent the menu from being dismissed?
>
> A friend suggested this way:
>
> // We assume that the menu is dismissed as soon as it loses focus.
> // Therefore, our idea is to steal focus to the main window as soon
> // as the menu is created
> // However, it doesn't work, is something wrong with the logic or
> // am I doing anything wrong?
>
> // In CMenuView
> PostMessage(WM_USER) to main window;
> TrackPopUpMenu(...);
>
> // In CMainFrame
> BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
> ON_MESSAGE(WM_USER, OnUser)
> END_MESSAGE_MAP()
>
> LRESULT CMainFrame::OnUser(WPARAM wp, LPARAM lp)
> {
>   this->SetCapture();
>   this->SetFocus();
>   ReleaseCapture();
>   return 0L;
> }
>
> I am very anxious to get this working =(
> Thanks for any help!!
>
>
> floobles@gmail.com (floobles) wrote in message 
> news:<d9632d0f.0411221338.100dd826@posting.google.com>...
>> Hi,
>>
>> I need to make a menu that does not disappear.
>> (Odd, yes.  I need to let users edit menu resources at runtime and
>> would like to display the menus as how they would actually look.)
>>
>> So I'm looking at CMenu's TrackPopupMenu function, whose last
>> parameter is LPCRECT lpRect.  I figure if I set this rectangle to be
>> (0, 0, screen width, screen height), then even if the user clicks
>> elsewhere on the screen, the menu won't disappear, right? 


0
11/29/2004 3:33:07 PM
Reply:

Similar Artilces:

How can I use fill hand to copy the fomula in this case?
Here is my fomula: B1: =sheet2!A1 B2: =sheet2!A4 B3: =sheet2!A7 B4: =sheet2!A11 ......... Is it possible to use fill handle to copy the fomula automatically in my case?, If so, how? Thanks. Sabrina I assume that B4 should read = sheet2!A10 with a help column in sheet1 enter the first function in B1 and fill that down the column enter in C column a series of 1<><>2<><>3<><>and extend that down th column do a sort on C column delete the surplus rows Sabrina Wrote: > Here is my fomula: > B1: =sheet2!A1 > B2: =sheet2!A4 > B3: =sheet2!A...

>> Only Print Last Page of Report
Hi, using Access 2003 is there a method that I can use to print only the last page of a report? I can use the print range method to specify page 1; that is the first page. Is there a switch or setting to specify a print range of the last page without knowing the page number at run time? All ideas or suggestions appreciated :-) Many thanks, Jonathan Jonathan wrote: >Hi, using Access 2003 is there a method that I can use to print only the last >page of a report? > >I can use the print range method to specify page 1; that is the first page. >Is there a switch or setting t...

Nesting an If factor and using the range name
I am taking a course for advanced excel and I need help with a question> I am working on a spread sheet for real estate. I am supposed to set up a formula using NESector and CornerLot classifying them as shown below. 1, 2 or 3. Can any one help????? NESector CornerLot Classification Yes Yes 1 Yes No 2 No No 3 Assuming the NESector is in A1 and the first row of "Yes"s is A2 and B2; The formula needed in C1 is =IF(A2="Yes", IF(B2="Yes", 1, 2), 3) ...

Want to create a file open box using a dialog box
I would like to create a file open box using a dialog box, but am not familiar with VBA. Is there a simple solution which will allow me to change the box header and place notes within the box itself?? Sorry for the ignorance. Truely, Mindless Mike Hi Mike Header yes, notes no: Sub test() Dim V As Variant V = Application.GetOpenFilename(Title:="Go on pick one") If V = False Then Exit Sub 'cancelled MsgBox "You chose " & CStr(V) 'note that it doesn't open the file, VBA must open it if desired End Sub HTH. Best wishes Harald "...

Unable to delete the last blank page in MS word
We generate a word document using VB script. Dynamically populate values from DB using bookmarks. We also attach a pre defined document at the end, but a blank page comes after the attachement. How to avoid programatically? There is no empty spaces below the attachement section or the attachment. Pleae advice. See http://sbarnhill.mvps.org/WordFAQs/BlankPage.htm -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Vishnu" <Vishnu@discussions.microsoft.com> wrote in message news:B9DCEAA6-DBAF-4BD0-9E6C-8B33...

COUNTIF using multiple conditions?
Hello folks - would appreciate help with this, please! I'm setting up a summary sheet to help track housing for a conference. For each date I have a formula to track the number of rooms, i.e. for January 7: =COUNTIF('Housing List'!F:F,"1/07/2005")+B4-(COUNTIF('Housing List'!G:G,"1/07/2005")) This counts the number of people arriving on the 7th, plus the number people already arrived prior, minus anyone leaving on the 7th. So now I need to break it down further, and use that same formula but only count the single rooms, so the ones with "Single&qu...

Does anybody know how to use the WinAPI funcitons to proccess a message of MIDI Keyboard?
as the subject I've never used them myself, but I'd start by looking at "MIDI Functions" in the multimedia section of the SDK documentation - functions such as midiInOpen. Dave ...

Open password protected ppt file using excel vba
Dim pptfile As Object On Error Resume Next Application.DisplayAlerts = false Set pptfile = CreateObject("powerpoint.application") pptfile.Visible = True Set pshow = pptfile.Presentations.Open(FileItem, Password:="") With pshow .Password = "test" ' ppt password .SaveAs FileItem .Close End With pptfile.Quit Application.DisplayAlerts = True End If How can i pass password from the vba code. If the file does not have a password then it catches error. Any...

using word for e-mail
I have 4 computers in my house. 3 with windows 7 and one with XP. I had no idea when buying microsoft office word 2007 that i would have limited use with word and E-mail. How do i upgade the computers that this won't work with? Word is not an e-mail application. What is it that you are trying to achieve? You can attach Word documents to e-mail (though as you have Word 2007, it would make sense to attach them as PDF files and thus ensure that the user sees what you intend). messages, in just about any e-mail application I can think of. If you want a Word-like e-mail editor,...

How do you change the data type of a cell using VBA?
For instance, with VBA I am trying to place "February 2007" in a cell but it keeps showing up as Feb-07. I want it to show up as literal text. -- justme0010 Sub text_it() Range("A1").Value = Chr(39) & "February 2007" End Sub -- Gary''s Student - gsnu2007c You could keep the value a date and just format the cell the way you like: with activecell .numberformat = "mmmm yyyy" .value = dateserial(2007,2,1) end with You could also format the cell as text first: with activecell .numberformat = "@" 'text .value...

Can we use Ques as static variables??
Hi, Please can anyone tell me if I can use a static queue??(static std::queue<std::string>* cQ) I want to use the queue in my derived class. Please help me... Thanks, Nands Have you tried it? What was the result? joe On 4 Feb 2007 18:08:18 -0800, pnandita@gmail.com wrote: >Hi, >Please can anyone tell me if I can use a static queue??(static >std::queue<std::string>* cQ) >I want to use the queue in my derived class. Please help me... >Thanks, >Nands Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http://www.flounder.com MVP Tips: http://www.floun...

Automattically generate Microsoft Exchange Views....what to use?
I am using Outlook 2003 to bring down pop3 email and also synch with Hotmail. Should I have the "Automatically generate Microsoft Exchange Views" box ticked? Outlook seems better with it unticked. Iam beginning to wonder if that was the cause of my hangs. -- JohnPerry@redoak.co.ukNOSPAM (delete NOSPAM) www.redoak.co.uk www.eze-buy.co.uk No, that setting is relevant only if you're connecting to Exchange server. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlook...

Sort address list by using LDAP query
I am not sure if it is possible on Exchange 2003. Currently our address book is sorted alphabetically by its display name entries. I want to sort it so all distribution lists will become on top of the list and followed by user names. On Exchange System Manager, under 'All Address Lists', I have an Address List with the following LDAP query (using 'Custom Search'): (&(&(mailnickname=*)(|(&(objectCategory=user)(company=*))(&(objectCategory=group)(displayName=*))))) Is there any LDAP keyword that I can add here so it can be sorted as I want? Thank you in adv...

how to use try/catch inside a DLL
I can put "try/catch " in any MFC application and console application, when I make a DLL, #include "extcode.h" #include <ole2.h> #include <stdio.h> #include <conio.h> #include <winbase.h> _declspec(dllexport) char Go(.....) { try { } catch(...) { } } it says undeclared identifier if I put #include stdafx.h it also can't compile how can I get try/catch work inside my VC DLL ? thanks very much Does your DLL have the build settings set to allow C++ exceptions? no, could you tell me where I...

Trouble using macros to send mail in Outlook 2010
I'm doing the following Set objMail = Application.CreateItem(olMailItem) With objMail .To = "myemail@email.com" .subject = "subject" .body = "body." .Send End With This worked using Outlook 2007. Ever since I went to 2010 I see the email in my Sent Items, but it never actually gets sent. Anyone seen this recently in 2010? Thanks. ...

Outlook 2007 uses 50% of CPU even when it is not doing anything
I have been noticing the last few weeks that my hard disk has been spinning quite a bit even when I was not doing anything on my desktop machine. It turned out that Outlook 2007 is using 50% of my CPU (when looking with the Task Manager), even when I'm not doing anything, and I assume the disk access is due to Outlook ecause the disk stops spinning as soon as I exit Outlook, and the CPU usage goes down to 0%. Thsi is relatively new (the past few weeks) and I have not installed any new program or feature for the last several months. I do get Windows updates automatically, so I presum...

Using graphic files in Word
Hello - I'm struggling with determining the what the best graphic file type is to use in Word. In particular, I'm starting with a vector .eps file. I've tried inserting jpegs, tifs, gifs, pngs and the original .eps file into a word document. They all range in quality - but the png file looks the best and is transparent - which is a requirement for me. The trouble is, when I either print the file to a pdf, or save as a pdf, the png file loses quality and looks worse. Are there any resources to help me figure out what the recommended practices are for using gr...

Formula to find last used cell
I want to populate a cell in sheet1 by going to sheet 2 column F and finding the value of the last filled cell that is not a zero I'm assuming all values in column F are numbers. =LOOKUP(2,1/(Sheet2!F1:F65535<>0),Sheet2!F1:F65535) You can't use entire column references in this portion: 1/(Sheet2!F1:F65535<>0). I would use a more reasonable range size. Biff "Yogi_Bear_79" <nospam@spamsux.com> wrote in message news:PYadnelLcYpqAo3YnZ2dnUVZ_u2dnZ2d@comcast.com... >I want to populate a cell in sheet1 by going to sheet 2 column F and >finding t...

Using php code in files from publisher
Hi, I designed a page with Publisher, and now I want to add some PHP code. What I was trying to do was to import the Publisher html file into a php editor, add the code, and then save it with a .php extension. Unfotunately this doesn't work... I think it has to do with the .files folder... tried renaming it a few times, to no avail :( anybody? Thanks. Try this: In Publisher, assuming you have it set as a Web page, use Insert HTML code fragment from the tool bar. Use the Web preview to test. P. -- Overcome Sales Barriers http://salesbarriers.typepad.com/ "audiogram@gmail.com&...

auto send email weekly or monthly using an appointment?
I'd like to send an email weekly at a certain time. I've been searching around on the web and found a post with the following text/code. Can someone expound a bit for me? is the "ThisOutlookSession" the name of a macro? What about the "public / private"? Question: How can you get VBA in outlook to send a message on a daily or weekly basis? Thanks To andrzej and www.outlookvba.com for this answer! Set up a folder in your inbox called News Put your email in here Set a recuring appointment in the calender with the subject new, to recur when you want the email se...

File transfer using FTP
HI all, I want to write a program for transfering my "CSV" file into a server.Can any one help me to solve this using FTP . It will be highly appreciated, if you provide code samples. Thanks and Regards Rinu Check out the CFtpConnection class... joe On Tue, 1 May 2007 09:56:02 -0700, Rinu Gopalakrishna Pillai <RinuGopalakrishnaPillai@discussions.microsoft.com> wrote: >HI all, > > I want to write a program for transfering my "CSV" file into a server.Can >any one help me to solve this using FTP . > >It will be highly appreciated, if yo...

Using Worksheet Name as a variable in formula
Hi guys, I am taking a value from sheets using formula =INDEX(Danemark!E2:E49,N10,1) Where Danemark is the name of worksheet. I have different worksheets with country names. Can I use a variable (lets say column E2) instead of the name Danemark and can choose an worksheet_name which I write in that particular column E2. I have tried using INDIRECT but I am not sure how to use it, kindly help. Thanking you in anticipation. Best Regards, Nano Put "Danemark" (without the quotes) in E2, then you could use this: =3DINDEX(INDIRECT("'"&E2&"'!E2:E49&qu...

GP 8.0 E-Mailing using Non-Acrobat PDF Writer
We are using GP 8.0 and would like to send e-mails as a PDF instead of Plain Text. We are using deskPDF which works will all other MS applications without any problems – however when we try to use GP the PDF e-mail option it remains grayed out. How dose GP know that a PDFWriter of some type is installed? Is there a registry hack or some ini file we can modify to get GP to recognize deskPDF’s printer. Also we are using GP on a Citrix Terminal Server and I just checked the price for Acrobat Elements – the smallest amount you can order is 100 units at $37.00 or rather $3700 – deskPDF is...

Use of date/time
I am using MS Office 2007. I have a query using Now() for the date/time. When I generate the run-time version on my machine, it worked fine. However, when the same application is generated on another machine with Office 2003, the application failed with a run-time error when the query is executed. Am I missing certain library which I need to include when generating the run-time package? -- Anthony On Mon, 28 Dec 2009 18:07:01 -0800, Anthony Ching <AnthonyChing@discussions.microsoft.com> wrote: >I am using MS Office 2007. I have a query using Now() for the date/tim...

Use bullets in a comments box
In Excel 2007, is it possible to use a bulleted or numbered list inside a comments box? Thanks in advance. Arlene Hi, Well you not in Word, so there is no command for automatic numbering or bulleting in any part of Excel. However, you can manually number inside a comment and you can add bullets bu choosing the Insert, Symbol command, to only active command on the Insert ribbon when you are in a comment. If this helps, please click the Yes button Cheers, Shane "Arlene" wrote: > In Excel 2007, is it possible to use a bulleted or numbered list inside a > comments box?...