|
|
|
I'm trying to implement a dynamic menu system to my program. Currently, i can add and remove the items from the menu, and make the menu items run code that i've premade.
for example i can add "section 1" to a section menu, while associating ID_SECTION_1 to the command in the menu. This will call my OnSection1() code when this command is executed.
I want this to be boundless (i.e. i dont want to have to make code for OnSection2, OnSection3, OnSection4... , or the strings in the string table, and so on.) I can currently bind each new menu item to the same id, for example section 1, section 2, and section 3 all run the OnSection() command which is bound to ID_SECTION. What i cannot do, is figure out how to determine which of the 3 i called. I would like to basically get the location of the last menu choice i picked, so if section 2 is in the second spot on the menu, i want to know this when i call OnSection().
Any ideas?
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|
|
why dont u store the currently displayed option on the menu as a numeric index somewhere and use a switch staement in the code to determine what to do?
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
How can i get the currently displayed option?
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|
|
well ur setting the menu text right?
so save a value somewhere else when u change the menu text that lets u know which option is showing
?
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
Many options will be showing, and i basically need to record the actual text that shows up in the menu. I cannot save the index value when i set the menu text, because i do not know which item will be chosen. I want the menu text simply to help me figure out which one i actually chose.
For example
File Edit Sections
->Section 1
I do something and create 3 more sections at runtime modifying the menu.
Now the menu looks like this
Sections
->Section 1
->Section 2
->Section 3
->Section 4
Each Menu choice is bound to ID_SECTION.
ID_SECTION corresponds to OnSection()
In my code:
void OnSection()
{
int section;
// I need to fill the section variable with
// the index of the item i picked from the menu
// since all of them have the same ID.
If(section==1)
handle section 1
If(section==2)
handle section 2
If(section==3)
handle section 3
If(section==4)
handle section 4
}
Hopefully this helps.
Thanks.
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|
|
You should be able to use GetCurrentMessage() and interrogate the wParam/lParam values to get the actual command ID of the menu option selecetd.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Hello,
I need to be able to get the Serial Nº of my hard disk in order to be able to make my programs to run only in the hard disk that I want them to.
I'm using this code:
DWORD dwNumSerie = 0;
UpdateData();
GetVolumeInformation((LPCTSTR)this->m_vedPath,NULL,0,&dwNumSerie,NULL,NULL,NULL,0);
this->m_vedNumSerie.Format("%d",dwNumSerie);
UpdateData(FALSE); How do I can be sure that the code works?
As a parameter I've written down a "\" (backslash only) in an editcontrol (m_vedPath variable is a CString linked to that EditCtrl).
Is that parameter right in order to get info. of the local HDD?
Thank you in advance.
NOTE:
I've received a - number in my laptop and a positive one in other PC.
|
|
|
|
|
Hi Joan,
The disk s/n is a DWORD. For the path I use GetWindowsDirectory() and if that is a UNC I use "C:\". I also test whether GetVolumeInformation() succeeds, which you should always do when calling functions that return status information.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
i am programming in Visual C++.Net and i am working on a SDI project. i creat a Modeless Dialog box beside my document Window. and i have some button on this dialog box. i want to trap these Buttons events. So am using Event Handler and i creat a Function for one of the buttons in one of my Class to handle the Events of buttons (for example a function for BN_CLICKED on CMainFrame) but when i click on one of those Button nothing happend then(i set some Line BreakPoints on those Functions that created by Event handler, but they never Executed). i don't know why !
what is the reason ?
|
|
|
|
|
Add the event handlers in the appropriate class. In this case, it is the dialog box.
Kuphryn
|
|
|
|
|
my project name is Test.
i have to Trap Messages of that Button in CTestView.
do u mean that i can't do that ?
|
|
|
|
|
If you button is in a dialog, trap the button in your dialog class. If you want to trap the message in your main window, I am sure you can modify the command routing to deliver the message to your main window. How to do that? I don't know. I haven't use MFC in 4+ years.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks for your answers. but how can i make a Connection between my Dialog button and my main Windows (CTestView). ? what can i do if i want to Trap BN_CLICKED of a butoon on a Dialog in my CTestView ?
|
|
|
|
|
when the button gets clicked in the dialog send a message to the main app and process it there ... use some custom message id's and u'll be fine
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
void CMyDialog::OnBnClickedButton1() {
CTestView *e=new CTestView();
e->SendMessage(WM_MBUTTONUP, 0, 0);
}
it's not work what can i do ?
|
|
|
|
|
no no no
define some custom message id's (see msn) and send a custom message to ur app class and add a handler there for the message
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
What event (or message or function call) does my MFC application/dialog will get when user presses WINDOWS-KEY + M ( the one that we use to minimize all windows ).
My Dialog based application does not get any notification and doesn't get minimized when I press WINDOWS-KEY+M
however I am able to minimize all windows (including my app) by pressing the "Show Desktop" quick link (which generally resides next to Start menu in the taskbar)
I want to rectify this problem with my app.
Please help me.
|
|
|
|
|
ummmmm isnt it the WM_SHOWWINDOW message?
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
Wizard window says
WM_SHOWWINDOW: Indicates a window is about to be hidden or shown
So WM_SHOWWINDOW is when we call ShowWindow(nShowCmd) or any other similar things.
I am asking about window minimize.
I have done a weird thing for the window not to get minimized by default (ie without adding any code).
I removed the minimize button & title bar of the dialog.
Since I am doing all that title bar stuff on my own, I want to add this functionality too.
Please help me.
|
|
|
|
|
afaik all window stuff to do with min and max and whatnot gets done thru the SW_SHOWWINDOW message
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
For message related issues, the best tool to use is Spy++, which comes with Visual C++. I just tried it and I got a message number 0x0127 (unknown) for Windows+M. You may wanna look into it further.
One thing to note however, is that Windows+M works fine with a dialog-based app I have here. Is there something special about yours?
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
hello @all,
i need an instruction which waits until MATLAB will finish it's job.
earlier forum question:
hello @all,
i try to explain what i want / must do :
i have something like this:
i=0;<br />
while(i<5)<br />
{<br />
i++;<br />
}<br />
the only problem is the while loop. without these, the program part runs perfectly. however i need a while loop or something like that.
i think, the problem lie in the fact that the program sends the data to matlab and then directly in the code continues to go. possibly different processes run off parallel.
i think i must have something that waits so long, till matlab is ready with the diagram (i tried Sleep(1000) but it do not work).
maybe somebody know, if matlab has got a 'instruction' or if i can make something like a 'queue'.
thank you very much
happy
|
|
|
|
|
Donno how ure doing it but take a look at the code on
http://www.codeproject.com/com/matlabengine.asp
and http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/apiext.pdf
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|