|
If you are dealing with MDI application in MFC using CMultiDocTemplate class, then I think you should use its members in this manner:
CMutiDocTemplate * t = ...;
int total_documents = 0;
POSITION pos = t->GetFirstDocPosition();
while(pos != NULL)
{
++total_documents;
pos = t->GetNextDoc(pos);
}
I hope this helps.
|
|
|
|
|
Hey All
I am wondering how to add new menu to other application, meaning I want to add a menu to another application that is not mine
let's say I want to add menu to Windows Live Messenger or Yahoo!
any idea how?
thanks in advance!
|
|
|
|
|
When you run this code you have two "test" in File last option and another after help
<br />
PROCESS_INFORMATION l_ProcessInfo;<br />
STARTUPINFO l_StartupInfo;<br />
<br />
ZeroMemory(&l_StartupInfo, sizeof(STARTUPINFO));<br />
<br />
l_StartupInfo.cb = sizeof(STARTUPINFO);<br />
l_StartupInfo.dwFlags = STARTF_USESHOWWINDOW;<br />
l_StartupInfo.wShowWindow = SW_SHOWMAXIMIZED;<br />
<br />
CreateProcess(NULL, <br />
"Notepad.exe", <br />
NULL, <br />
NULL, <br />
FALSE,<br />
DETACHED_PROCESS,<br />
NULL,<br />
NULL,<br />
&l_StartupInfo,<br />
&l_ProcessInfo);<br />
<br />
MessageBox("Wait");<br />
HWND hWnd = ::FindWindow("Notepad", NULL);
HMENU h=::GetMenu(hWnd);<br />
HMENU h2=GetSubMenu(h,0);<br />
<br />
AppendMenu(h2,MF_STRING,22,"test");<br />
AppendMenu(h,MF_STRING,22,"test");<br />
|
|
|
|
|
thanks alot
I didn't think it was easy like that to do what I am trying to, I thought I needed to hook the application first
I have one more question, how I can I add the WM_COMMAND ability to this code so when I click on "test" a MessaBox will pop up?
thanks in advance!
|
|
|
|
|
You can see an article from Mr David Crow about "resource" maybe it is some helpful to you
|
|
|
|
|
I tried to find the article and searched after the arthur name but no result
are you sure it is the right name?
thanks!
|
|
|
|
|
|
I am havin problems doing this c++ project.Its in regards to whether i can use one main class (e.g.main.cpp) or have to use a few classes.I am also a bit weak when it comes to c++ as java is my main language so any hints on the code or how to go about doing this would be great.The basic idea is :
Create a class called DataSet that stores a vector of floating-point values. Give this vector an initial size of zero, and use the push_back operation to add new elements.
The DataSet class should have a public member function for each of the operations described above, as well as a member function that adds an element to the vector.
I have to get the MEAN,MEDIAN and Standard Deviation.
I would very much appreciate if you could help me asap as I am desperately stuck.
PLEASE HELP ASAP IF U CAN
Thanks in advance,
klck2000
|
|
|
|
|
So what part is troubling you?
Creating a class
Adding a vector member
Initializing member variables
Adding to a vector
Creating other methods
Reading from a file
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
tell you the truth,im having a problem with everything,i dont know where to start.i just dont know how to do it,iv tried but get nothing but errors.can you help??heres my main class:
#include <iostream>
//#include "main.h"
using namespace std;
#include "main.h"
int main(){
Calcs calcs("input.dat");
cout << "Mean is " << calcs.findMeanHeight() << "\n";
cout << "Standard deviation in height is " << calcs.findStandardDeviation() << "\n";
heres my calcs class to get the mean etc:
#include <fstream>
#include <cmath>
using namespace std;
#include "calcs.h"
Calcs:: Calcs(string filename){
ifstream ifile("input.dat");
/*ifile >> _dimension;
for (int i=0; i<_dimension; i++){
for (int j=0; j<_dimension; j++)
ifile >> _heights[i][j];
}
}
void Calcs::print(ostream& s) const {
for (int i=0; i<_dimension; i++){
for (int j=0; j<_dimension; j++)
s << _heights[i][j] << " ";
s << "\n";
}
*/
}
double Calcs::findMeanHeight() const {
double runningMean=0;
for (int i=0; i<_dimension; i++)
for (int j=0; j<_dimension; j++)
runningMean+=_heights[i][j]/(pow(_dimension,2.0));
return runningMean;
}
double Calcs::findStandardDeviation() const{
// return standard deviation of heights
double squareOfMeans = pow(findMeanHeight(),2.0);
return sqrt(meanOfSquares()-squareOfMeans);
}
}
}
}
double Calcs::meanOfSquares() const{
double runningMean=0;
for (int i=0; i<_dimension; i++)
for (int j=0; j<_dimension; j++)
runningMean+=pow(_heights[i][j],2.0)/pow(_dimension,2.0);
return runningMean;
}
PLEASE HELP!!
klck2000
|
|
|
|
|
klck2000 wrote: ,i dont know where to start.
It looks as though you have indeed started, and are well on your way.
klck2000 wrote: iv tried but get nothing but errors.
What errors?
On a side note, you might want to update your post so that it is more readable (you'll get tons more help if folks don't have to squint their eyes and turn their head sideways to make sense of it all). Use the <pre> tags to surround the code and make sure the angle brackets are formatted correctly. The Preview button helps in this capacity.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ok sorry, im only fairly new at this.the project seems pretty basic but I just cannot do this at all.Could you give me the code or an idea on how to do this even,which would be a huge help:
Create a class called DataSet that stores a vector of floating-point values. Give this vector an initial size of zero, and use the push_back operation to add new elements
I just cannot get my head around this.From the input file I have to get the Mean,Median and standard deviation.The code I have used which I took from another c++ project I have done,is incorrect i think
thanks,
klck2000
|
|
|
|
|
|
Thanks,
I just pasted that from my project overview.By any chance would you be able to help me as I am desperate at this stage.I dont know where to start in regards to the code or what code to use??
klck2000
|
|
|
|
|
klck2000 wrote: Could you give me...an idea on how to do this even...
Here is one idea:
class DataSet
{
public:
DataSet() { }
void Add( const double dHeight )
{
m_vecHeights.push_back(dHeight);
}
double Mean( void ) const { }
double Median( void ) const { }
double StdDev( void ) const { }
private:
vector<double> m_vecHeights;
};
void main( void )
{
DataSet ds;
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks very much,i tried something like that lastnight though id to use floating point values so used
class DataSet
{
private:
float Vector[200]; //Holds the floating values
int Number_of_Elements; //Holds the number of elemets -1
void Sort_Vector(); //Sorts the vector to calculate the median value
public:
DataSet(); //Constructor of the class
~DataSet(); //Destructor of the class
void Add_Element(float float_value); //Add an element into the vector
float Calculate_Mean();
float Calculate_Median();
float Calculate_Standard_Deviation();
};
how do you think that looks??
thanks,
karl
klck2000
|
|
|
|
|
klck2000 wrote: float Vector[200]; //Holds the floating values
One of your requirements was to use the push_back() method to add items to the vector. What you have does not satisfy that requirement.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i cannot use the push_back method,i was having problems with understanding it.Any simple code suggestions??
klck2000
|
|
|
|
|
klck2000 wrote: Any simple code suggestions??
See here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
How's it going with this project?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
We have 3 variables defined at file scope. The project is for a DLL that's loaded by other modules. The globals are objects that are dynamically allocated within a C++ class method using 'new'. Within the objects, more tables (arrays) are dynamically allocated using 'new'.
We're experiencing 'memory access' crashes when somehow the globals are corrupted. Its weird because the app will work fine for awhile, then get a crash. It can happen at startup, in the middle of using the app, or right before closin the app. These variables must be global and cannot be member variables of the main class. (Long story)
If the DLL is not loaded, no crash occurs. So we're confident its the DLL.
My question, is there a way to ensure that the global pointers remain intact? Or ideas on monitoring the pointers? I thought about using static in the global definition, but wasnt sure about the effect. I also thought about making the globals variables of the main looping function, but figured since I'm calling new, I wouldnt be protected by function scope memory management.
There's something at the DLL level that's screwing us up. We're desperate for a solution to ensure global pointers are not corrupt. Ideas??
TIA,
C
|
|
|
|
|
Did you try to use your debugger ?
I know, these kind of bugs are probably hard to reproduce but if they happen quite rapidly, then using your debugger will give a lot of information.
|
|
|
|
|
When a user selects the "Preferences" menu item in my application, it triggers the method CMainFrame::OnEditPreferences() in MainFrm.cpp. At that point I create a dialog and receive input from the user. Now, I need to pass that information on the document (*Doc.cpp).
I have tried GetActiveDocument() but it does not seem to contain my custom data members; do I need to cast it to another type? And if so, what headers do I need to include? Thanks for any help.
EDIT: I solved the problem by moving the OnEditPreferences() method to the document file with the Class Wizard. Sorry for any inconvenience.
|
|
|
|
|
titaniumdecoy wrote: I have tried GetActiveDocument()
This function returns ur active documents pointer as CDocument*. So u have to cast it to CYourDocument*.
titaniumdecoy wrote: it does not seem to contain my custom data members
Then u can see it containing ur custom data members.
KIRAN PINJARLA
|
|
|
|