|
you can put it anywhere you need to change the window style.
but PreCreateWindow[^] is a good place if you want to make sure the change happens before the window is drawn.
|
|
|
|
|
ok fine....and may i know what is purpose of Oncreate() func or when
it ill be useful...
|
|
|
|
|
See here.
"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
|
|
|
|
|
Hi,
I am using the following code:
CString csXmlFile = "MyXML.xml";
CComPtr<msxml::ixmldomdocument xmlns:msxml="#unknown"> fXmlValDocPtr;
HRESULT hr = fXmlValDocPtr.CoCreateInstance( L"Microsoft.XMLDOM" );
VARIANT_BOOL isSuccessful = VARIANT_FALSE;
if( hr == S_OK )
{
fXmlValDocPtr->put_async( VARIANT_FALSE );
BSTR bstrCsXmlFile = csXmlFile.AllocSysString();
_variant_t tempcsXmlFile(bstrCsXmlFile);
hr = fXmlValDocPtr->load(tempcsXmlFile, &isSuccessful);
tempcsXmlFile.Detach();
}
Getting the following exception. Can I know what is the bug in above code.
kernel32!RaiseException+58 e0000001 00000000 00000001
msxml3!Exception::raiseException+5f 800c0006 8fd64972 00000000
msxml3!Document::HandleEndDocument+45 8fd64926 00000000 07ade1a8
msxml3!NodeFactory::abort+34 07ad46a8 00000000 8fd648de
msxml3!NodeFactory::Error+2d 07ad6000 07ad46a8 c00ce551
msxml3!Document::abort+e9 07ad6000 8fd6486a 00000000
msxml3!Document::_load+1b8 07adf000 00000000 00000000
msxml3!Document::load+44 07ade038 00000000 8fd64bf6
msxml3!DOMDocumentWrapper::load+1e4 00000000 00000008 00000030
|
|
|
|
|
How do you figure this has to do with the usage of CComPtr ?
Does it work if you use a raw interface pointer instead?
It looks to me as if the exception is raised because the document you're trying to load fails to do so.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Catch the fricking exception, see what it says.
As the exceptions in the load method....are you sure you're feeding it XML, not your source code?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
okay I've created a program that has a 2D array that I want to display and edit. The class I created is called CChannel.
I'm using SDI to display it, in the View class I have defined this,
m_pChans = GetDocument()->GetChan();
m_chan is defined, CChannel m_chan;
GetChan() is this.
CChannel* GetChan() {
return &m_chan;
}
CChannel has an array defined in it called,
int arr[16][3600];
Okay, so within my View file I run the lines,
m_pChans->arr[i][j]=1;
that works fine and updates the array good, but when I copy this code in a function then try call it called from another file I get problems. First it asks me to make that function static, I'm not sure why,
error C2352: 'CUCPView::UpdateOutputs' : illegal call of non-static member function
so I make the function static, then it has this error,
error C2227: left of '->arr' must point to class/struct/union/generic type
I don't understand why it works within View, but when I try to use it in a function and make it static it doesn't work. I've been trying to look up the error codes and such, but with no luck. Could someone please help me with this.
I'll post more code if needed, but this already is pretty long
Cheers
|
|
|
|
|
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
|
|
|
|