|
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
|
|
|
|
|
I was considering a class variable. So it seems like a big limitation that we cant declare class members that are a reference. I think I've seen stuff like
local function
{
someType xyz;
someType &abc;
abc=xyz (not abc=&xyz right?)
I have a locally declared & variable and wanted to use it in another function....
|
|
|
|
|
If it's a class variable I'd have thought it would work if you used an initialiser list as in my first reply.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
To declare a pointer to a type, use '*' instead of '&'.
for example:
long *mLongVar;
To make it accessible to everybody put it under 'public:'
|
|
|
|
|
Thats what I ended up doing....so thank you very much for confirming that my approach was correct.
ns
|
|
|
|
|
Hi all
I need to get server side system time from my computer
how to do this?
Thanks
|
|
|
|