|
So you added a close button ON the dialog in addition to the standard close button?
If I'm correct, try the following:
the declaration in CMyStupidDialogName
afx_msg void OnYourButtonPressed();
the implementation
void CMyStupidDialogName::OnYourButtonPressed()
{
PostQuitMessage(-1);
}
map that function to the button this way:
DECLARE_MESSAGE_MAP(CMyStupidDialogName, CDialog)
ON_BN_CLICKED(YOUR_BUTTON_ID, CMyStupidDialogName::OnYourButtonPressed)
END_MESSAGE_MAP()
this should work if it doesn't, slap me
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hello
Your problem is that you forgot to call the default handler for OnCancel().
void CMyStupidDialogName::OnCancel()<br />
{<br />
::AfxMessageBox("ONCANCEL");<br />
CDialog::OnCancel();<br />
}
Isaac Inyang
Ansyl Technologies
|
|
|
|
|
Can someone explain what the vc++ compiler does in these two
particular instances:
Scenario #1:
I have an inline function, let's call it InlineFunction(). It will
return type int and accesses a private member variable of a particular
class. It is a public member function of the same class, MyClass...
Now consider the following lines of code:
void main()
{
MyClass ThisClass;
cout << ThisClass.InlineFunction() << endl;
return 0;
}
Scenario #2
Same as above, only we assign the value of
InlineFunction to a variable:
void main()
{
MyClass ThisClass;
int temp;
temp = ThisClass.InlineFunction();
cout << temp << endl;
return 0;
}
Can anyone tell me how the compiler handles the inline function
in the two different scenarios? I realize that it expands the function
in the code, buy how is scenario #2 different from #1 in terms of how the
compiler handles the situation??
|
|
|
|
|
John Theal wrote:
how is scenario #2 different from #1 in terms of how the
compiler handles the situation??
No difference at all. The compiler simply replaces a function call with the actual code for the function. Where the function appears is irrelevant, unless it is a recursive call to an inline function.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
i dont think so that there is any change i mean in the 1st case the return value by the function is directly place from where it is called. i mean the cout<< "here is the returned value"
while that in the 2nd senario the retuen value is being assiged to the var and that particular var is used to display the value with the cout object.
i dont think so there is much difference in the 2 senrio.
if any one can tell more its good isnt it..
Thanx
TAKE CARE
|
|
|
|
|
Have you looked at the assembly output of the two? That'll tell you what the compiler is doing to each.
|
|
|
|
|
In scenario #1, the compiler will insert the code for the function inline with the expression evaluation for the << operator arguments. It will place the return value of <nobr>InlineFunction() on the stack, passing it to the << operator.
In scenario #2, it's handled inline, except as an argument for the int assignment operator for the variable temp . It then picks up the variable out of temp and places it on the stack, passing it to the << operator.
Scenario #1 is a trifle faster, in that the compiler is free to evaluate the inline function and place it's result directly on the stack. Scenario #2 requires that the function be evaluated and the result placed in a temporary variable.
In either case, the compiler inserts the code for the inline function into the expression evaluation for the argument to the appropriate function. In scenario #1, it's the << operator. In scenario #2, it's the assignment operator.
Software Zen: delete this;
|
|
|
|
|
|
Can anyone give me some advice on coping a whole dialog with all its resources (like the menu bar, ClassView, and ClassWizard info) from one project into another?
It must be something that people do all the time, yet I couldn't find anything usefull by googling it.
Paul
|
|
|
|
|
You'll either need to copy the entire .RC file, or copy/paste the relevant pieces from one .RC file to the other.
|
|
|
|
|
there's an article here on CP that talks about that, but I don't know what to search for.
one way (I think) could be to copy-n-paste the dialog between 2 instances of VC and copy-n-paste the dialog files and insert them into you new project.
but you have to be carefull of the resource ID numbers.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
If you are really lazy like me - create intermediate empty solution and add old project and new project to it. In resource view just drug the resource from one project to another, holding Ctrl key.
|
|
|
|
|
The most reliable way I've found of doing this is by hand, using the text editor.
Copy/paste the resources out of the .RC file and into the destination. Don't forget to copy/paste the DESIGNINFO section if there is one. You mentioned menus; you'll have to copy the menu as well.
Copy the resource ID's from the original resource.h into the destination. You may need to renumber the resource ID's so that they don't conflict.
The IDE (VC6, VS.NET 2002, and VS.NET 2003) will let you cut/paste controls, but it's not terribly smart about whole dialogs.
Software Zen: delete this;
|
|
|
|
|
Hi all,
I posted yesterday morning to try and get my menu item to be checked and unchecked as one of my dialogs is displayed via the menu item. I kinda need this to be accomplished soon, so i figured i could post it again because the original post is 5 or 6 pages into the message board.
Beer26 was kind enough to help me with this solution.
in the new dialog class add this function. Now the new dialogs will control that menu item in it's parent.
void MyClass::checkmymenuitem(int checked)
{
CMenu* pMainMenu = GetParent()->GetMenu();
CMenu *submenu = pMainMenu->GetSubMenu(1); // replace 1 by the horizontal menu position
UINT g = submenu->GetMenuItemID(3); // replace 3 by the actual vertical item position
CString mnustr;
submenu->GetMenuString(3, mnustr, MF_BYPOSITION); // replace 3 by the actual vertical item position
// you can optionally change mnustr to a text here
if (checked) submenu->ModifyMenu(3, MF_BYPOSITION | MF_STRING | MF_CHECKED, g, mnustr);
else submenu->ModifyMenu(3, MF_BYPOSITION | MF_STRING | MF_UNCHECKED, g, mnustr);
}
in initdialog
checkmymenuitem(true);
then in onclose
checkmymenuitem(false);
It works fine the first time the app is started(menu item unchecked), when the menu item is selected the first time (checked), and when the dialog is closed the first time(unchecked). BUT it doesn't update the menu at all after the first time it is selected and the dialog is closed.
Can anyone help me figure this out PLEASE. I was originally trying to use a pointer to the dialog being displayed, but that led to the same result.
|
|
|
|
|
(haven't looked at the original question)
can't you simply add a ON_UPDATE_COMMAND_UI command handler for the menu item ?
and use :
void MyClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
{
pCmdUI ->SetCheck( IsYourDialogVisible() );
}
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
I think he said his main app was dialog based, and as we all know the VC++6 generator has that bug that makes updating UI on menu items not work on dialog based apps.
I forgot what the fix was for that but you can look it up on codeguru.com
|
|
|
|
|
Thank you for your help. I figured it out, and with your code it works great.
The problem was that I just had to destroy the window when closing the window.
|
|
|
|
|
Hi
I urgently need a class for READING a CSV file.
Has anyone writen a simple class to do that job? (any links are always welcome)
greets
Jens
|
|
|
|
|
It's a Comma Separated Value (i.e., comma delimited) file. What part are you having trouble with?
|
|
|
|
|
There is a whole section on parsing waiting to be looked at at:
C++/MFC , Parsing[^]
Iain.
|
|
|
|
|
It's a Comma Separated Value (i.e., comma delimited) file. What part are you having trouble with?
---
I was searching for a class which parses the CSV file and returns a pointer to a user-defined class (or something that will fix the problem) for every line.
Like for example:
The class contains a dynamic number of elements X.
Each element X is one field.
This element X should contain the value of the field(of course) and alsoo the type of value. (text, number, date)
of course the class must have a .next() function to read the next line etc
i thought of fixing the problem like this, i don't know if it's a good solution or not. Thats why the post.
greetings
jens
|
|
|
|
|
Hi every body,
I'm looking for documentation about the WMF file format.
I would like to create WMF file by myself, but not from existing bitmap pictures.
This file will contains commands to create lines, rectangle, circle, to draw text... But for now, i have some trouble to draw text, select font...
does anybody knows where i can get doc about this, or where i can get some sample code to understand how WMF files work.
I would like to use standard C++ code, to make it works under Windows or/and UNIX.
thanks for your help
Jauss
|
|
|
|
|
|
thanks a lot
this will help me to understand how works WMF files
Jauss
|
|
|
|
|
I have some problem with creating a new class...
Here is what i encountered..
I inserted a new Dialog in my MFC application and when i clicked on it , I got the "Add a Class" Dialog box and i clicked ok for create new class.. i gave a name for the new class ..Starting with a 'C' (like Cmyone, I also tried CmyoneDlg) but i got a message saying "Unable to open files E:.......myone.h and... myone.cpp for class Cmyone..
I dont know why this problem occurs..
Can anyone explain me why?
Thanks
Deepak Samuel
|
|
|
|