|
Hello guys,
I have a question in reagrds to MDIs. I have a MDI application that has 2 different CMDIChildWnd classes. I need both of these classes to be able to access the same variables in the MyDoc or MyView class.
This is what I do know.
I know that if I want to access a variable from the Doc or View class from the default MDI application CMDIChildWnd class (ChildFrm.cpp), then to access these variables I can use GetActiveDocument or GetActiveView.
Here is my problem.
When I open a new window from the CMDIChildWnd class that I added into my project (MyCMDIChildWnd), then it becomes the current Doc/View. So if I use GetActiveDocument on this, I get a return value of NULL.
What I want to do then is to access the variables that the 1st CMDIChildWnd class (ChildFrm) with the second CMDIChildWnd class (MyCMDICHildWnd). How can I do this?
I was thinking that maybe if I assigned a number to each of the windows, then I could always say, "Access the information in ChildFrm, which is window number 1"
Is there a way to enumerate the open windows? Or to access information that the first window opened?
Thanks a whole lot,
NickOne
p.s. If I wrote this all wordy or too confusing, just yell at me and I'll try to rephrase. I am really stuck with this and I want to solve my problem, so any driection or advice could help.
|
|
|
|
|
I'm not sure I understand your question. Do you want the two MDI child windows to use the same document? If so, then put a pointer to the current document into the CCreateContext structure when creating the second MDI child.
This is quite a large subject, so I'd like to know your exact requirement and problem before getting to deep into it.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
1. How do I update a status bar 'field' outside of MainFrame.cpp (where I declared the status bar window)? More specifically, I'm invoking a function in View.cpp and would like that function to update the status bar 'field'.
2. When using the Wizard, you end up with the MFC appln icon. How do I change that? In my resource.rc, I have the following [IDR_MAINFRAME ICON DISCARDABLE "res\\SEI.ico"], which specifies the small icon I want for my appln. The icon, however, does not show. What else do I need to do toward that effect? Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
1. Write public function in CMainFrame which updates status bar by the way you want. You can call this function from any place of your project:
((CMainFrame*)AfxGetMainWnd())->SomeFunction(...);
2. When you edit the icon, don't forget to change both 32x32 and 16x6 versions.
|
|
|
|
|
You can handle messages ON_UPDATE_COMMAND_UI in any window that is child to MainFrame, particularly in your View. Just do not create similar handler in MainFrame, otherwise it will have more priority and your handler will be never called
I disagree with "Alex F" about public method in MainFrame, it breaks the law, that is called "Incapsulation". Plus it increases inflexibility of modules' links
|
|
|
|
|
Hi,
I've noticed that when a double is >= 1e15 and <= 1e-5 it is automatically output in scientific notation. I wish to output in fixed notation. I have managed to control the smaller values by using a CString with multiple values after the point:
x.Format(_T("%.20f"), double);
and messing about with the CString created, but I am having trouble controlling large values. I have tried using the Format method, as with small values, to create a CString and then manipulate it using:
x.Format(_T("%.20d"), double);
but it just outputs ridiculous values which do not resemble the original double. Is there a way of using Format to achieve this?
Thanks in advance,
Graham
|
|
|
|
|
'%d' doesn't work with doubles. You may try with %e or %g.
You may also consider using std::ostringstream.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Just learning about STL and I am having a problem compiling this, what part am I missing?
#include <iostream.h>
void main()
{
vector<int> vList;
for(int i = 0;i < 20;i++)
{
vList.push_back(i);
cout << i << " added to vector." << endl;
}
}
I get a whole slew of errors with this.
Nick Parker
|
|
|
|
|
Add #include <vector> , and either add using namespace std; somewhere, or prefix vector with std (i.e. std::vector<int> vList; ).
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
|
You need to have:
#include <vector>
and then include vector in the namespace or use
#include <vector>
#include <iostream>
using std::cout;
using std::vector;
Regards,
Brian Dela
|
|
|
|
|
|
It should be 'using std::vector', without 'namespace'
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Tomasz Sowinski wrote:
It should be 'using std::vector', without 'namespace'
Yep. I know... Just made a silly mistake.
Regards,
Brian Dela
|
|
|
|
|
Does the path string returned by CFileDialog look like C:\dir\abc.txt or C:\\dir\\abc.txt . THrowing a messagebox with this pathstring displays it as the former but that doesnt necessarily mean its the way its returned. I plan to be using splitpath on the returned string and so need to know.
Thnaks,
ns
|
|
|
|
|
|
I wanted commas to replace the backslashes, so I tried
CString m_szlstfile = fileDlg.GetPathName();
m_szlstfile.Replace('\\', ',');
AfxMessageBox(m_szlstfile);
which worked, whereas if I did
Replace('\', ',');<br /> it complained that there was a newline in the sequence. So apparentlt there is a \\ somewhere in the process ??
ns
|
|
|
|
|
|
no, there is no \\ the sequence. the first \ escapes the second ' , changing it from a special C/C++ metacharacter to a literal string character. so, your statement ends up meaning roughly the same as this:
Replace('x, ',');
and that can't be parsed
bottom line: if you want a \ in a string, you have to use \\.
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
I'm TRYING to catch database exception and output that to an error file. Here's the CATCH code :
catch (CdbException)
{
FILE* errorfile;
errorfile=fopen("c:\\cristi\\error.err","a");
fprintf(errorfile,"v,dmlkvmdsv");
for (long ct = 0; ct < dben.Errors.GetCount(); ct++)
{
fprintf(errorfile,_T("\t Error #%ld: #%ld -- %s\n"),
ct,
DBERR(dben.Errors[ct].GetNumber()),
dben.Errors[ct].GetDescription());
}
fclose(errorfile);
return;
}
This code just won't work. I get nothing in the file. Nothing. It's not even accessed.
This other code below that prints the error data to the screen works.
catch (CdbException)
{
for (long ct = 0; ct < dben.Errors.GetCount(); ct++)
{
printf(_T("\t Error #%ld: #%ld -- %s\n"),
ct,
DBERR(dben.Errors[ct].GetNumber()),
dben.Errors[ct].GetDescription());
}
return;
}
Now. ---> In both cases I get this error message:
Debug Assertion Failed!
Program: ...program
File:dbgheap.c
Line:1044
Expression: _CrtIsValidHeapPointer(pUserData)
I belive the second code works because of the printf lack of buffering so that the error message that I display at the console displays faster than the debug assertion failed error. Anyway, this isn't the problem. The problem is why do I get that error message. What happend over there. Anyone encountered this problem before ?
Thank you!
|
|
|
|
|
Are you sure dben.Errors[ct].GetDescription() is returning a char* and not some other kind of string like CString or wchar_t* ? That's the only thing I can see by just looking at your code.
|
|
|
|
|
I have been trying to execute a console application (32 bit), and get it's output from a Win32 (MFC) application. I have tried the CSpawn article on www.codeproject.com, but it does not work fur Windows98, and does not wait until the program exits they way I need it to.
I have also tried the MSDN articles. They mention that 16-bit console apps need an extra CreateProcess, but I don't think I need that since the console app is a 32-bit app? I do not ever create console apps, so am I wrong about this? Are all console apps considered 16-bit?
I'd rather not re-invent something if someone has already solved this one.
Any ideas on where to look?
Thanks,
Dave
|
|
|
|
|
Check KB article Q190351 "HOWTO: Spawn Console Processes with Redirected Standard Handles".
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Thanks, I have tried this, and had problems. Have you ever tried to implement code from this article?
|
|
|
|
|
No. What is the problem?
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|