|
I've got an SDI app with a CFormView in the main frame when it initializes. That works fine. I'd like to be able to toggle on/off that view to an empty client view via a menu command.
The MSDN docs say you can only have one view at a time in SDI but doesn't give any examples on how to remove the current view, create a new one and do I need a new frame window to do it?
I've tried to switch to a simple text view....but, I'm still trying to learn this doc/view stuff.
appPtr->pDocTemplate->RemoveDocument(GetActiveDocument());
delete appPtr->pDocTemplate;
appPtr->pDocTemplate = new CSingleDocTemplate(IDR_TEXTTYPE,
RUNTIME_CLASS(CTest3Doc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTextView));
appPtr->AddDocTemplate(appPtr->pDocTemplate);
|
|
|
|
|
|
Thanks. I found something here. D-OH-H-H-H!!!! I Should have checked first. Anyways, in case anyone else want to know:
http://www.codeproject.com/docview/replacingview.asp
http://www.codeproject.com/docview/switchingviews.asp
|
|
|
|
|
I Read the article http://www.codeproject.com/useritems/asyncwininet.asp;
and write the code like 'asyncdemo' which from msdn:
http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/downloads/samples/internet/networking/asyncdemo/default.asp
but I have a question
when I call InternetQueryDataAvailable() ,it return ERROR_IO_PENDING
then I will recieve a callback status :INTERNET_STATUS_REQUEST_COMPLETE
and the LPINTERNET_ASYNC_RESULT (lpvStatusInformation)->dwError!=0,
the download incorrect.
what's the matter???
the 'asyncdemo' alse download file incorrect
who have the source code of asynchronous download
thanks very much
|
|
|
|
|
I am interested in making a window similar to a start bar but creating it at the top of the desktop and having it so that when a window is maximized it won't cover over the window I have created (instead all windows) will think that the bottom of my window is the top of the screen.
I know this can be done but I don't even know what it is called. If anyone could even tell me what this is called or point me in the right direction it would be greatly appreciated.
Thanks
|
|
|
|
|
Check out the SHAppBarMessage API. I've been meaning to right my first CP article on this - I promise I will get round to it as soon as I have moved house (about a week to 10 days ish, if you can wait that long)
Dylan Kenneally
London, UK
|
|
|
|
|
After creation of ur window, use SetWindowPos(...) with HWND_TOPMOST property for the hWndInsertAfter parameter. This will ensure that your application maintains its topmost position even when it is deactivated, ie other applications are having focus.
|
|
|
|
|
Hello,
I'm trying to use TextOut() to put a string to a window, but when I put the \n or \r\n in the CString.Format(), they print as black-boxes, not linefeeds. My intent is to get one CString with linefeeds to print to the screen.
Any ideas? Thanks!
JennyP
|
|
|
|
|
|
Golly... that seems like a lot of work to keep track of the text positioning! What about word processors? Do they keep maps of each line of text and its position? I would assume this is available in some control....?
thanks! JP
JennyP
|
|
|
|
|
|
You can have Windows wrap text for you if you use DrawText() . Use the DT_CALCRECT flag to determine the rect's dimensions before writing. You should also use DT_WORDBREAK . As functions go, it's a most excellent function!
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I spotted that someone suggested you use DrawText() with DT_CALCRECT . When you have multiple lines MSDN states that DrawText() with DT_CALCRECT will not alter the .right attribute of your CRect , but when I tried to use that (with both \n and \r\n as line breaks) DrawText() always altered the .right attribute! To get round this, you might want to try the technique used in Roger Allen's 'Example of how to print a long CString across multiple pages' of output using the MFC print architecture
' article.
Dylan Kenneally
London, UK
|
|
|
|
|
I have a class - CVariable In the constructor I want to transfer the address of that instance to a CVariableManager class so that I can iterate though all my CVariable instances. I use
CVariableManager::Add(CVariable * pvar) and from the constructor add the CVariable m_VarMgr::Add(this)
The trouble is that the this value is always the same value. I assume that it points to the vtable for the function addresss.
How can I get a pointer to the data instance
HHEELLPP!
David
|
|
|
|
|
You'll find that your object does not actually exist until the constructor returns. This could well be part of your problem. I don't believe you can use 'this' inside a constructor.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
If you "don't believe" try this:
class _A
{
public:
_A()
{
m_this = this;
};
_A *m_this;
void f()
{
printf("instance: %p\n",m_this);
}
};
void main()
{
_A a1,a2, *pa1,*pa2 ;
a1.f();
a2.f();
pa1 = new _A();
pa2 = new _A();
pa1->f();
pa2->f();
delete pa1;
delete pa2;
return;
}
soptest
|
|
|
|
|
Hmmm... well, I wonder what the rule was then ? I had some problem to do with assuming an item was existant in the constructor, when it was only after the constructor returned that it existed.....
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Actually one can use this in the constructor. The address is valid and does not change any more - so you can safely store it or pass it to someone else. It depends on how you use it.
You have to consider that all members you did not initialize already are still undefined. And virtual functions are not dereferenced as expected during constructor execution. While beeing constructed, the object behaves like "static" typed. All functions are executed as if the object is of the class which constructer is currently executed:
class A {
public:
A() {
vf();
}
virtual void vf() {
printf("A::vf() called\n");
}
};
class B : public A {
public:
virtual void vf() {
printf("B::vf() called\n");
}
};
void main ()
{
A a;
B b;
}
The output of this little program would be:
A::vf() called
A::vf() called
The reason for this is, that constructers are called in order of the inheritance graph beginning with the most general base class(es). (The constructer of the base class(es) is always executed before the constructor of the derived class is entered.) And the very first thing a constructor does is to init the vtable. So at the point in time the A part of a B instance is constructed, the vtable is still the one of class A .
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
That's it - it was the virtual function problem that bit me before.
Thanks.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I had the similar problem some time ago. I need to call a virtual function from within base class constructor, which is of course impossible (cause the derriven class is not yet constructed).
You can write define or template function. Pass the type as the argument. After construction (operator new for instance), call required virtual member, then return newly created instance of the object.
This works fine for me.
Mukkie
|
|
|
|
|
u can do it, i am sure because i use the way often to pass an instance itself to manager (or whatever).
i.g.
class MyClass
{
public:
MyClass()
{
mng.Add(this);//Manager mng;
}
};
if u don't beleave, simplify ur code to do a test.
includeh10
|
|
|
|
|
It would be possible to sort of hide the constructor of the CVariable class, and to instead, have variables allocated by the CVariableManager class. Something like this maybe:
<br />
class CVariableManager;<br />
class CVariable()<br />
{<br />
private:<br />
friend class CVariableManager;<br />
CVariable( );<br />
~CVariable();<br />
<br />
public:<br />
};<br />
<br />
class CVariableManager<br />
{<br />
public:<br />
CVariableManager();<br />
~CVariableManager();<br />
<br />
CVariable * CreateVariable( );
void DeleteVariable( CVariable * p_poVariable );
};<br />
Then you can use the CVariableManager to actually manage the variable creation and deletion.
Chris Richardson
|
|
|
|
|
Compiler says it needs initialized. So how can I create it as a member variable and put its declaration in the (public)h file so everyone can access it?
Thanks,
ns
|
|
|
|
|
A member variable that needs to be initialised can be done like so
(in .h )
class Blah
{
SomeType m_st;
(in .cpp)
Blah::Blah() : m_st("initialisiation values"
{
etc.
However, for you to have a reference, it needs something to reference to. Is it a class variable, or a global ( in a namespace of course ).
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|