|
Did you include the header file of your CChannel class in the cpp file in which you are using it ?
For your other problem (making the function static), you'll have to show some code where you call the function so that we can help you.
|
|
|
|
|
soongez wrote:
error C2352: 'CUCPView::UpdateOutputs' : illegal call of non-static member function
The most common reason for getting this error is when you're trying to call a member function without a valid object to operate on. You should have e.g. a pointer to your view object and make the call like
pTheView->UpdateOutputs(); but it seems like you're trying to call it like
CUCPView::UpdateOutputs(); which would require the function to be static since there's no object to operate on.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
in something I have called SetOutputDlg.cpp I include CUCPView.h, then call the function by typing
CUCPView::UpdateOutputs();
void CUCPView::UpdateOutputs()
{
for(int i = 0;i<=;=3599;i++)
m_pChans->arr[1][i]=1;
}
but then I get the error
SetOutputDlg.cpp(70) : error C2352: 'CUCPView::UpdateOutputs' : illegal call of non-static member function, so declaring UpdateOutputs function static will fix that error msg, but then have the struct error stated before.
Roger Stoltz wrote: pTheView->UpdateOutputs();
that looks like something I need to do, but since the View object is the View class created by the MFC SDI pre generated code using visual studio. how do I make a pointer to the view object? sorry I'm still very new to this.
Thanks for fast replies tho.
|
|
|
|
|
By the looks of the filename "SetOutputDlg.cpp" it seems like it contains the definition for a class called CSetOutputDlg .
You've got to have some kind of reference to the CUCPView object you're trying to operate on in the CSetOutputDlg class. A member variable would do nicely. Implement a function e.g CSetOutputDlg::RegisterView that takes a CUCPView* as argument and call it from where you create your CSetOutputDlg object and have access to the view object.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I think I've solved the issue by using the code suggested in the Visual Studio help, and what Roger has said is right.
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->GetMainWnd();
CMDIChildWnd *pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();
CUCPView *pView = (CUCPView*)pChild->GetActiveView();
then,
pView->UpdateOutputs();
but I had all these strange issues when I tried to add in the first set of code to different parts of the program, saying can't find GetActiveFrame and GetActiveView, even tho I could right click and go to definition. So I added that code all within the same function as where "pView->UpdateOutputs();" was located. Also I couldn't add a declaration "CUCPView *pView" to the SetOutputDlg.h file because when I tried to #include "CUCPView.h" it would come up with lots of errors.
doesn't sound very neat, but works. I came from java and now learning C++ and pointers and such are still giving me troubles.
|
|
|
|
|
Some things to consider in your chosen solution...
You're using a lot of ...GetActive... which suggests that there may be more than one, don't you think? Then you're type casting the returned pointer into a type you assume it is, but it may in fact be something else if you have more than one view.
Your code will probably work, but it is based on a lot of assumptions that you need to be aware of.
soongez wrote: when I tried to #include "CUCPView.h" it would come up with lots of errors.
What kind of errors? When building which file?
You should be able to include the header file, but depending on your errors you may need to include "stdafx.h" at the top of your SetOutputDlg.cpp file if that's not done already.
This would be the "right" way to do it.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
The code with GetActive was just copied from the Visual studio help... I am working on understanding it all and making it more "right"
when I include UCPView.h the errors start with,
1>Compiling...
1>UCPView.cpp
1>c:\users\soong\desktop\project\project program\ucp\UCPView.h(48) : error C2143: syntax error : missing ';' before '*'
that line reads,
CSetOutputDlg *dlg;
so the error is in the include, because it doesn't appear when I don't include it.
|
|
|
|
|
Hi,
May i know the difference b/w ondraw() and onpaint()....
|
|
|
|
|
You mean other than what the documentation provides?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
A warm welcome, David [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
One difference is that OnDraw () works with views, and OnPaint () works with dialog boxes. There's no good reason for this; just unnecessary Microsoft complexity.
|
|
|
|
|
Hi,
I am a c# programmer. I got an application in c++, i need to integrate that to my application in c#.net. I dont know c++ programing, not even to run.
How can i use the c++ application in c#?
Thankyou
YPKI
|
|
|
|
|
Are you wanting to convert your C++ code to C#, or are you wanting to run an application from within C#?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
For the latter, try ShellExecute() or CreateProcess() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Is there any difference between
auto_ptr<<foo>> p;
...
p = auto_ptr<<foo>>(new foo);
and
auto_ptr<<foo>> p;
...
p = new foo;
I saw the first form in examples and wondered why it was being used.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: p = new foo;
are you sure. that you'd able to do this? I think compiler will throw error.
You've to be careful about auto_ptrs unusual characteristic. Copying them them to null, and the copying pointer assumes sole ownership of the resource
See the example demonstrate this issue from Effective C++ 3rd Ed.
std::auto_ptr<Investment>
pInv1(createInvestment());
std::auto_ptr<Investment> pInv2(pInv1);
pInv1 = pInv2;
// object, and pInv2 is null
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks for the reply.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
Can u pls suggest me any book to start with for MFC in VS2003 and even im new to vc++..
|
|
|
|
|
Hi,
Programming Windows with MFC[^] is a great book, written by Jeff Prosise.
Legend says that one starts with Programming Windows with C++ and work your way up through frameworks and libraries. If you'd like to pursue that path, you could start with Programming Windows[^] by Charles Petzold.
Of course, you would be expected to be able to do C/C++ programming well before you touch any of these.
Happy learning.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I learnt from an earlier version of this one[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The name (Programming with Microsoft Visual C++ .NET) of this version looks like it would explain managed stuff too.
I'm not against managed code, but I don't like the idea of mixing up managed code with good old native C++. It's like eating garlic with ice cream.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Good one!
Welcome again int CP's Memorable Quotes list [^] (what a day! Yours is the second entry, so far...).
BTW:Rajesh R Subramanian wrote: Of course, you would be expected to be able to do C/C++ programming well before you touch any of these.
is a great one too...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I ain't sure if I can keep up to the heat.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
That was actually the name of the product - remember it used to be Visual Studio .NET rather than just plain Visual Studio? 5 out of the 35 chapters cover .NET - the rest are plain Visual C++ and MFC (I know because it's on Safari & I can see it ).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|