|
Yeah they said that I didnt need to post it twice but the question basically was:
What is wrong or how can I improve this function:
void* memcpy( void* dest, void* src, size_t size )
{
byte* pTo = (byte*)dest;
byte* pFrom = (byte*)src;
assert( dest != NULL && src != NULL );
while( size-- > 0 )
*pTo++ = *pFrom++;
return (dest);
}
|
|
|
|
|
Hi Josh,
You're copying a byte at a time... it is not as efficient as it could be on architectures such as x86 which has SIMD instructions.
Jeff
|
|
|
|
|
There's absolutely no reason to post this twice.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello,
after the CFormView::OnInitialUpdate() i perform a textbox1.SetDecimal();
In this function of the CEdit derived class i make a ModifyStyle(ES_LEFT|ES_CENTER,ES_RIGHT);
followed an Invalidate() ...
But the textbox is still with an alignment to left (set to left by the designer ).
Is there a special command to applic the Style-Modification ?
Big thanks
|
|
|
|
|
See Edit Control Styles[^], particularly the part that states "After the control
has been created, these styles cannot be modified, except as noted."
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you for your reply.
So it isn't possible to set the alingement to right during the execution of the application.
I tried already to manipulate the CreateStruct before the OnCreate is startet, but this
also don't work.
|
|
|
|
|
Hi,
"before he OnCreate" does it mean PreCreateWindow().
if not please try CEditDerivedClass::PreCreateWindow()
|
|
|
|
|
Thanks for your answer
Is it possible that it don't stop into the CEditDerivedClass::PreCreateWindow()
with a DDX_CONTROL created Textbox ?
|
|
|
|
|
Hi,
So you are using the control already on the resource.
Would I like to know if are applying the style before
Create and I hope not change it thereafter, why don't you
set the edit control style in the resource to Align Right
|
|
|
|
|
To built views faster.
I put for example 50 textboxes on a view. 30 of them are right-align.
I need to change all styles.
During coding the view, i set all 30 textboxes to number-textboxes (labelPrice.SetDecimal() )
Now, the SetDecimal() sets different parameters to the textbox (only numbers, right-align, ... )
I must anyway write one line per textbox, so this line changes also the styles.
If i like to change something, i don't need to change all textboxes on Dialog-Ressource, but only
some line of codes ...
In future, some peoples who don't programm a lot, should design all views, so it should be so quickly and easy as possible
|
|
|
|
|
Hi,
The dialog child items are created at dialog creation.
DDX_Control will only subclass controls not creating the control.
subclassing will allow the messages to be routed to the
class we specified. but at that time the control will be created already, so you won't get oncreate or precreatewindow events for the control.
In my opinion, setting styles after DDX_Control doesnot "built views faster".
If you specify Styles in resource designer it would have assigned at creation.
But you are then interrupting the control while ModifyStyle which involves sendMessage like process.
I suggest you specify styles of controls in resource design and SetDecimal will do the initialisation of data excluding the style.
Best Regards
|
|
|
|
|
I mean by "built views faster", that the developer can design faster the views, not that the view
is faster created at runtime.
Ok, i'll set those styles at the designer.
Big thanks anyway
|
|
|
|
|
baerten wrote: So it isn't possible to set the alingement to right during the execution of the application.
Not exactly. It's just not possible to change those styles after the control has been created.
You need to specify ES_RIGHT when you create the control. If the control is on a dialog resource
(in other words, NOT being created manually at runtime) then set that style in the dialog
resource.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Coders!
IDE: Microsoft Visual Studio version 6.0
Lang: C++
Question:
Would anyone know a standard timing function that provides accuracy at the microsecond(us) scale, or at the very least at the low millisecond(ms) scale?
Why:
I am running an application that is supposed to send out data along a line every 24 milliseconds. I have the data to send at every interval, I just need a timer to send it accurately at the specified times(every 24 ms).
Thanks everyone for your suggestions!!
L
|
|
|
|
|
If you need precision of the order of the milisecond, then you'll need to use another operating system than Windows which is not real-time. You will never be able to have such precision.
EDIT: except if you use WinCE, in which case it is a real-time operating system.
|
|
|
|
|
|
|
These links are excellent!
I am really glad I found this forum!
Thanks!!
|
|
|
|
|
Your're welcome.
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.
|
|
|
|
|
I am getting back into C++(be doing C# heavey for the past few years), Can anyone give me some help on how I can improve the function so no problems dont arise when it is run? I appreciate the help you guys.
void* memcpy( void* dest, void* src, size_t size )
{
byte* pTo = (byte*)dest;
byte* pFrom = (byte*)src;
assert( dest != NULL && src != NULL );
while( size-- > 0 )
*pTo++ = *pFrom++;
return (dest);
}
Thanks.
|
|
|
|
|
joshp1217 wrote: how I can improve the function so no problems dont arise when it is run?
Correctly using the standard one!
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.
|
|
|
|
|
I have to improve this code for a test, so any help you can Provide I would greatly appreciate.
|
|
|
|
|
IMHO it is good as it stands.
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.
|
|
|
|
|
So there is no way I can optimize it or make it more efficient, because when I looked at it it seemed fine to me to but I have to make sure.
|
|
|
|
|
IMHO it seems OK, i.e. It is correct. But maybe you can find a more efficient way to copy memory (e.g. copying machine-words instead of bytes).
I think someone else will give a better hint than me about.
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.
|
|
|
|