|
I already figured out a similar workaround using OnCommand, but I have than the problem that than also the Enter Key does not work any ware, when I intercept the return key in OnCommand it is not passed to OnChar, or else, i assume PreTranslateMessage will have the same problems.
The only thing bypasses the interception is OnKeyUp, OnKeyDown seems to dont work at all on PPC 2003 for the enter key.
I'm looking for a realy clean solution.
|
|
|
|
|
OwenBurnett wrote: i assume PreTranslateMessage will have the same problems.
try it
|
|
|
|
|
Seems to work better than OnCommand,
OnKeyDown is triggerd properly but with nChar == 0, but this is a minor problem and can be easly handled.
thx.
|
|
|
|
|
From where i can look at the OnMouseMove Flags for the some mousemove events.
Bitte tun Sie mir nicht antworten, wenn Sie nicht wissen, die Ursache des Problems wirklich oder nur als Antwort. Was ist das? Dies ist das Buch sitzen.
|
|
|
|
|
nFlags
Indicates whether various virtual keys are down. This parameter can be any combination of the following values:
MK_CONTROL Set if the CTRL key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the SHIFT key is down.
|
|
|
|
|
Thanks
Bitte tun Sie mir nicht antworten, wenn Sie nicht wissen, die Ursache des Problems wirklich oder nur als Antwort. Was ist das? Dies ist das Buch sitzen.
|
|
|
|
|
Hi,
I am working on an element of a program which is performance cruical and I wanted to clarify something with regards to basic C++ inheritance.
Consider the following:
class BaseClass<br />
{<br />
public:<br />
BaseClass();<br />
<br />
void foo();<br />
<br />
private:<br />
int baz;<br />
};<br />
<br />
class AnotherClass : public BaseClass<br />
{<br />
public:<br />
AnotherClass();<br />
<br />
void bar();<br />
};
It is important to note that no virtual functions will be used within this element; including no virtual destructor.
My question is this, would there be any performance differences between the above source and the source listed below?
class CombinedClass<br />
{<br />
public:<br />
CombinedClass();<br />
<br />
void foo();<br />
void bar();<br />
<br />
private:<br />
int baz;<br />
};
The first example would be easier for me to maintain because there will be many variations of 'AnotherClass'. Does anybody know of the nitty-gritty low-level differences between the two and any such differences in performance?
Also do overloaded methods cause performance differences?
Any advice would be greatly appreciated!
Lea Hayes
|
|
|
|
|
Theoretically there should be no performance difference. The calls to foo() and bar() should be non-virtual in either case. But you can try having a look at the generated assembler code just to be sure.
BTW, if it's not a secret, what are you doing so special that you cannot use a virtual function call?
Florin Crisan
|
|
|
|
|
On second thought (assuming your constructors are not trivial and cannot be optimized away), if you use two classes you would get two function calls: first to the constructor of the derived class, then to the constructor of the base class. But the other function calls should be the same.
Florin Crisan
|
|
|
|
|
Hi,
It is a math class which will be used extremely frequently. There are a variety of different math classes, and some of which are derived upon the others...There is no multi-inheritance, and I have ruled out virtual methods here because they would offer no gain, and automatically require additional memory to reference a vtable.
Thanks for your advice!
|
|
|
|
|
lhayes00 wrote: My question is this, would there be any performance differences between the above source and the source listed below?
IMHO none noticeable (There are two constructors instead of one, though, if you have a huge number of objects...).
lhayes00 wrote: The first example would be easier for me to maintain because there will be many variations of 'AnotherClass'.
The above is a good reason to go on with inheritance.
lhayes00 wrote: Also do overloaded methods cause performance differences?
IMHO no, they are translated by the compiler to different named methods (in fact functions).
BTW C++ language is fairly efficient (is one of its design goals), I think that you should first address your efforts to good, clean design and then on optimization of your algorithms, and finally worry about efficiency of different language constructs.
Please note that I gave you general guidelines, I'm not an expert of that
lhayes00 wrote: nitty-gritty low-level
things.
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.
[my articles]
|
|
|
|
|
I should learn to read the whole message
Also do overloaded methods cause performance differences?
Well, a normal non-virtual function call has the normal overhead of a, well, normal function call. That is, the arguments are pushed to the stack, the return address is pushed to the stack, etc.
(As far as I know) If you have a polymorphic object, in most implementations it keeps a (hidden) pointer to a table of function pointers (known as 'vtable'). So, before making the call, the pointer to the vtable and then the one to the function would have to be de-referenced. (I really don't know how expensive that is; it may be significant on some systems, but probably nothing significant for normal use).
However, if the compiler is able to tell the exact type of the object, it won't need to call the function virtually.
For example
<br />
Derived x;<br />
x.bar();
<br />
Base *x;<br />
x->foo();
If you really think it would make a difference, try it both with virtual and with non-virtual and see what happens. (And let us known what the result was )
Florin Crisan
|
|
|
|
|
Googling around for virtual function calls, I found this research paper[^], but I'm too lazy to read it. Hope it helps.
Florin Crisan
|
|
|
|
|
What a mess. It took me so many messages to say so little.
I'm going to get some sleep before the party. Happy New Year!
Florin Crisan
|
|
|
|
|
Florin Crisan wrote: Also do overloaded methods cause performance differences?
Florin Crisan wrote: (As far as I know) If you have a polymorphic object, in most implementations it keeps a (hidden) pointer to a table of function pointers (known as 'vtable'). So, before making the call, the pointer to the vtable and then the one to the function would have to be de-referenced. (I really don't know how expensive that is; it may be significant on some systems, but probably nothing significant for normal use).
However, if the compiler is able to tell the exact type of the object, it won't need to call the function virtually.
For example
Derived x;
x.bar(); // x is a derived -- call Derived::bar() directly
Base *x;
x->foo(); // is x a Base or a Derived? use the function pointer to be sure
Method overload and method override are two quite distinct concepts, he asked for the former, you're talking about the latter.
Florin Crisan wrote: Derived x;
x.bar(); // x is a derived -- call Derived::bar() directly
Base *x;
x->foo(); // is x a Base or a Derived? use the function pointer to be sure
AFAIK method invocation is always done via vtables.
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.
[my articles]
|
|
|
|
|
CPallini wrote: Method overload and method override are two quite distinct concepts, he asked for the former, you're talking about the latter.
My bad.
CPallini wrote: AFAIK method invocation is always done via vtables.
I remember reading differently in Stroustrup's book, but it might be just the lack of sleep. I guess it's really up to the compiler's implementer.
Florin Crisan
|
|
|
|
|
Florin Crisan wrote: I remember reading differently in Stroustrup's book
Well, I surely don't debate against C++ founder, maybe you're right.
Happy New Year
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.
[my articles]
|
|
|
|
|
Thank you very much for all of your input!
I am just about to get started on the link you suggested, it looks for interesting reading.
Happy new year!!
|
|
|
|
|
hi to all
itook a varible BYTE *bByte and want to convert bByte[1] into a CString type varible,bByte varible has hex value,
i done CString csValue=(CHAR)bByte;
where am i wrong
|
|
|
|
|
Assuming that you want to create a string representation of the number (that is 32 => "32" rather than 32 => " " – space being the character with the ASCII code 32), you can use something like this:
CString x;<br />
BYTE b = 123;<br />
x.Format("%u", (unsigned int) b);
or
x.Format("%x", (unsigned int) b); // "7b"
You need to convert it to unsigned int because there doesn't seem to be a way to specify a 1-byte integer in the format string.
Or, if you feel adventurous, you can try stringstream[^] or The Boost Format Library[^].
Florin Crisan
|
|
|
|
|
In your code, bByte is actually a pointer to a BYTE rather than a BYTE . You should have named it better: pbySomethingUseful . p stands for pointer, by stands for byte (b stands for bool , and that one is actually as big as an int ). The rest should be a useful name
So your code should look like:
csValue.Format("%x", (unsigned int) (*pbySomethingUseful)) .
Florin Crisan
|
|
|
|
|
You can use CString::Format
csValue.Format( "%x", bByte[1] );
modified on Monday, December 31, 2007 9:36:06 AM
|
|
|
|
|
Hi,
You are attempting to cast a BYTE* into a CHAR. A BYTE* is a pointer to BYTE data....so the casted CHAR will be a CHAR representation of the pointer address of bByte.
CString csValue = (CHAR)bByte[0]; // for individual character
or
CString csValue = (CHAR*)bByte;
If you want to show the hex value of the byte, you can do something like the following:
CString csValue;<br />
csValue.Format(_T("%02X"), bByte[0]);
If you wanted to show the entire contents of the byte array as hex then you will need to wrap the above within a loop and concatenate the result each time to the result string.
<br />
CString csValue, csTemp;<br />
BYTE *pActiveByte = bByte;<br />
while(*pActiveByte)<br />
{<br />
csTemp.Format(_T("%02X"), *pActiveByte++);<br />
csValue.Append(csTemp);<br />
}
I hope that this helps...
Lea Hayes
|
|
|
|
|
I must say that I am little surprised that it works with a BYTE . Weren't %x and %u supposed to take a (four-byte) integer?
Florin Crisan
|
|
|
|
|
Hi all
There is a mfc project and uses my extension mfc dlls. When i look with "Process Explorer" at my mfc exe, the virtual memory of the project is growing. But i am sure there is no memory leak, i tested my projects with Devpartner.
What can be the reason of this growth?
thx.
caner abali
|
|
|
|