|
hi,
i have a SDI application in which i want to add some text on the menus. for example the way we have the Add to Favourites in the Internet Explorer menu. so how do i implement that in my application. but in this case i want the data in a text box to be added (functionality is same as that of the Add to Favourites) . can anyone help.
thanks
aditya
|
|
|
|
|
To insert a new item:
CMenu* m;<br />
m = AfxGetApp()->GetMainWnd()->GetMenu();<br />
m = m->GetSubMenu(2);
m->AppendMenu(MF_ENABLED,253,"new item");
When the menu item is clicked, you need a menu-command-range hander in the message-map macro in the .cpp file:
ON_COMMAND_RANGE(200,400,OnMyMenu)//change the first and second parameter to the range you will provide in the second param to AppendMenu()
The implementation will be:
void CMySdiView::OnMyMenu(UINT nItem)<br />
{<br />
}
Now nItem contains the second parameter you gave in AppendMenu(). So you know which one was clicked.
One thing to note is that you must have at least a sub-item in the menu in the resource. Let it be a separator. When no sub-items are present, it gives a headache.
this is this.
|
|
|
|
|
first u have to get a handle to the menu or create ur own
HMENU hMenu = CreateMenu();
HMENU hPMenu = CreatePopupMenu();
AppendMenu(hMenu,MF_STRING|MF_POPUP,(UINT_PTR)hPMenu,favmenuTxt);
AppendMenu(hPMenu,MF_STRING,favID,favTxt);
also in ur message process u need to handle for the WM_COMMAND message with (i think) wParam being the command ID
|
|
|
|
|
Can any one send me an example project on User Defined Threads implementation
Thanks
EMRangaNathan
914055220443
|
|
|
|
|
|
Hello
am new to VC++,
I have to application, Now I want to store the debug information. i.e., whenever am debugging the application, the complete infomration like, variable values strings all should get saved in a file
how to do this, let me know as soon as possible
Thanks
EMRangaNathan
914055220443
|
|
|
|
|
It sounds like you expect this to be simple; in other words, like the IDE is going to provide it for you (Wrong!). You have two choices: (1) write a simple little piece of code that opens a file (for append/write) writes to it, then closes it, for each piece of your code (slow, but worth it), (2) If you are using MFC, then you can use trace statements, they will dump into the debug output window, which you can copy and paste to a text file.
Signed: John R. Shaw
|
|
|
|
|
how can I change alignment of columns of header control? (not text of columns)
I want the fist column be shown in the right of list box.
|
|
|
|
|
I am a newbie to MFC and want to do the following:
I have a button added to a toolbar. I have also added the following in my code for the function to be executed once the Button is clicked: ON_COMMAND(ID_BUTTONRUN, OnRunTests)What I want is when the button is clicked I want the button state to be disabled and the cursor to look like a Hourglass untill the OnRunTests() is completed.
I tried the :ON_UPDATE_COMMAND_UI(ID_BUTTONRUN, OnToolbarRunUpdate)
but this got executed only after the OnRunTests() completed which is not what I want.
Is there a way for me to change the cursor and the button state as soon as the OnRunTests() is entered and change it back when it is done. Any help and guidance will be appreciated.
|
|
|
|
|
In resource.h:
#define WM_DOSOMETHING 12345//or whatever
In mainfrm.h, add a custom-message handler:
afx_msg LRESULT OnDoSomething(WPARAM,LPARAM);
In the BEGIN_MESSAGE_MAP macro in mainfrm.cpp:
ON_MESSAGE(WM_DOSOMETHING,OnDoSomething)
In the implementation for OnDoSomething:
LRESULT CMainFrame::OnDoSomething(WPARAM,LPARAM)<br />
{<br />
m_wndToolBar.GetToolBarCtrl().EnableButton(ID_EDIT_COPY,FALSE);<br />
m_wndToolBar.RedrawWindow();<br />
return 0;<br />
}
In your view class:
void CWhateverView::OnUpdateEditCopy(CCmdUI* pCmdUI) <br />
{<br />
if (m_bDisable)<br />
pCmdUI->Enable(FALSE);<br />
else<br />
pCmdUI->Enable(TRUE);<br />
}
In your function for long operation:
void CWhateverView::OnEditCopy() <br />
{<br />
m_bDisable = TRUE;<br />
BeginWaitCursor();<br />
AfxGetApp()->GetMainWnd()->SendMessage(WM_DOSOMETHING);<br />
int i, j,k;<br />
for (i = 0; i < 10000; i++)<br />
for (j = 0; j < 10000; j++)<br />
for (k = 0; k < 5; k++)<br />
{<br />
}<br />
m_bDisable = FALSE;<br />
}
And don't forget to declare m_bDisable in CWhateverView.h and initialize it as m_bDisable = FALSE; in the class constructor.
this is this.
|
|
|
|
|
Thanks so much for your explaination and sample. It reall helped me.
One question is : when I do BeginWaitCursor() it shows the hourglass for a fleeting second and again changes back to the arrow cursor. It does not stay as hourglass for the entire lengthy operation. Any help how to fix that?
|
|
|
|
|
Could i plot signal in the dialog box? Or it's more difficult to do it?
I wan to choose mfc AppWizard(exe).i wan to display button and boxes on the gui.What type of application is suitable to create ? sdi, mdi or dialog ?
Thx a lot for ur help. take care all.
|
|
|
|
|
every type of application can be content what you want,but more important is that you should write a derived class from CButton(for example),and override some virtual methods and message-functions.
reference to articles here meybe give you a hand
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
when writting about "plot signal" do you mean drawing a graph of a signal, like an analogic signal ?
if so, have a look hhere[^] , there are examples on how to create graphs and plot.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
meiyueh wrote:
Could i plot signal in the dialog box?
Yes!
meiyueh wrote:
Or it's more difficult to do it?
No!
OK, that was simple, but you lost me. You need to rethink your question. It looks like you need a dialog based application.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hi,
i want to create an ISAPI extension which would enable me send a page with an image to a browser. there would be options for the user to select a particular image give on a web page and when the user clicks the get button the image should be displayed. i found a sample project here on codeproject given by Jorge Lodos. but i am not able to display the images. i changed the location of the files as specified in the tutorial but only the text is being displayed. can anyone help. also in the html page supplied with the sample code contains a %s in the image src field. can anyone explain what is that. the html code is as follows.
<head>
</head>
<body>
Test Image
<img align=left src="%s">
A car
</body>
and the link for the sample project is : http://www.codeproject.com/isapi/image.asp
thanks
aditya
|
|
|
|
|
I have a Fortran program related to figure plotting. Right now, I created a interface by Visual C++. Is there anyone who knows how to access Fortran program through the interface programmed by Visual C++?
|
|
|
|
|
Their is probably someone who can answer this question, but it is not me.
Rethink the question and give a little bit more imformation.
1) What Fortran compiler (or version) are you using (very improtant).
Blast! I could only think of one. But that one is important!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
DawnLee wrote:
Is there anyone who knows how to access Fortran program through the interface programmed by Visual C++?
Define "access." Does Fortran support COM?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi
I need to display a dialog showing a message to the user and distroy it after a specific timeout.
How can i do this?
I'm familiar with threads but in other languages so just a piece of code would be very helpful...
Thanks a lot
Mamtz
|
|
|
|
|
try this :
SetTimer(..) and
OnTimer(..)
{
if(timeout)
close dialog
KillTimer(..)
}
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
Use EndDialog(TRUE) when timeout
|
|
|
|
|
|
Hi, all
I was trying to run an application cross network, and got this message "runtime error, program g:\...\cd.exe abnormal program termination" from c++ runtime library. but I was able to run it from another 2000 machine cross network on the same data. and could run the other exe on the same folder from my machine, too.
it just doesn't make sense why only this one won't work........anybody has idea?
thanks and have a good weekend!
|
|
|
|
|
that means the application has some bugs which are exposed in one machine and not the other.
remmeber the famous quote - "it works in my machine".
Saurabh
|
|
|
|