|
Use LimitText( long lLimit )
ComboBox m_Combobox;
m_Combobox.LimitText( 64 );
"Dream bigger...Do bigger...Expect smaller"
aji
|
|
|
|
|
hello all,
I want to serially transmit float variables/data types between the PC and the serial device (RABBIT 3000 -an 8bit microcontroller).
I am transmitting with databits as 8 for serial transmission as my microcontroller is an 8bit one.
I convert float to long and bitshift to assign it to a buffer of type char.
But if I do this, then say,
I want to transmit 3.4,then I can transmit only 3 and not the .4
as I convert form float to long before transmitting.
How can I transmit a float data variable from PC to microcontroller or the vice-versa serially.?
|
|
|
|
|
Use...
typedef union
{
float fFloatVar;
UCHAR ucFloatByteArray;
}FloatConverter;
FloatConverter fc;
fc.fFloatVar = 23.456f;
Now just send the bytes in FloatConverter.ucFloatByteArray one by one.
Now while receiving store each byte into the byte array FloatConverter.ucFloatByteArray and then
float fFloatNumber = FloatConverter.fFloatVar;
I guess this should help you.
Thanks to toxcct ...
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
thanks very much.
It works perfectly.
thanks for ur help.
|
|
|
|
|
Or how about:
unsigned char* byteptr = (unsigned char*)&floatVal;
for(int i = 0; i < sizeof(float); ++i)
Send(byteptr[i]); You can use this technique for any struct/basic type, without having to create a "converter" union for each type.
--
For External Use Only
|
|
|
|
|
I need to use a ccontrol list to show data, after pressing button 'showdata'.....in a old project(DIALOG BASED).....the problem is that..... in this project i can't use class wizard.
kamalesh
|
|
|
|
|
Have you removed the wizard comments from source?
AFAIK we can use class wizard, only if we created the project by classwizard.
When pressing the Ctrl+W it will ask for the list of files. I think it appears only for the projects created through class wizard
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
I set a treeview toolbar in my MDI project.
just like the VC++ 6.0 workspace toolbar,Click the item/filename of the fileview, the related file opens and become active. and insert/delete item of the tree, it will new/close the related doc/file .
1.>how to create a new file for the new item ?
2.>when DbclickTree() happens, how to active the related file?
3.>does the files can searched/sort by filename as the treeview item sort?
thanks for ur kind help!
|
|
|
|
|
Hey Guys,
does anybody know a good implementation of the Sorenson H.263 Codec ? I couldn't find a nice on. Well I found some links but they were dead
I appreciate any help.
Thanks,
Ben
|
|
|
|
|
Hi all,
I created combo box with control variable. I like to set the no of characters to be keyed in in the combobox(editable).
In brief, set the text limit to the Combobox control variable. Can anyone help me in this problem?
Thanks in Advance.
Regards,
Ram
|
|
|
|
|
Follow these steps:
1) From View menu, bring up the MFC ClassWizard
2) Add a member variable of CString type for the ComboBox
3) Set maximum characters to a number of your choice
4) Recompile the project
Best,
Jun
|
|
|
|
|
I already set member variable type CComboBox type to the combobox.
And now i have created one more member variable CString type as u hv specified. still i couldnt able to set the text limit to the combo box. advice on this.
Thanks.
Regards,
Ram
|
|
|
|
|
On the "Member Variable" panel, select the variable you just created. As it's a CString type, an edit box named "Maximum characters" will appear at the bottom.
Best,
Jun
|
|
|
|
|
class RTI_EXPORT RTIambassador {<br />
public:<br />
#include "RTIambServices.hh"<br />
RTIambPrivateData* privateData;<br />
private:<br />
RTIambPrivateRefs* privateRefs;<br />
};<br />
<br />
class RTI_EXPORT FederateAmbassador {<br />
public:<br />
#include "federateAmbServices.hh"<br />
};
WHOAA!! What is this suppose to mean
How come we have two names for this class
class RTI_EXPORT RTIambassador {<br />
<br />
.....<br />
<br />
};
Does this mean you can refer to this class by two different names
|
|
|
|
|
|
i need to know how to get the width of a string of text
.GetLength("string"); will return 6
.GetLength("String"); also returns 6
but
.GetStringWidth("string"); returns 22
.GetStringWidth("String"); returns 27 which is what i need but .GetStringWidth is part of a listctrl and i may not always use a listctrl with my class so i need a work around for it.
i hope this is clear on what i need.
|
|
|
|
|
from the MSDN:
CListCtrl::GetStringWidth : The width, in pixels, of the string pointed to by lpsz.
CString::GetLength: A count of the bytes in the string.
bytes != pixels
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
i know that i need the width in pixels just dont know how to get it.
|
|
|
|
|
in that case, you need to :
1. create a font object that reflects the font you're going to use when you draw the text
2. create a DC
3. select your font into that DC
4. use something like DrawTextEx or CDC::GetTextExtent to measure the text
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
class Derived: public string <br />
{<br />
public:<br />
~ Derived() { --destr;}<br />
};<br />
int main()<br />
{<br />
string * p = new Derived;<br />
delete p;
cout>> destr >>endl;
}
Class Derived publicly inherits from Class String
My question is, is
String *p = new Derived;
same as
String *p;<br />
p = new Derived;
-- modified at 17:38 Tuesday 4th July, 2006
|
|
|
|
|
Deriving from std::string is asking for trouble...
--
Based on a True Story
|
|
|
|
|
what are virual destructors? I'm tryin to understand this file
why do we have a destructor function from a derived class which is empty
class ObjectRoot <br />
{<br />
public:<br />
<br />
virtual ~ObjectRoot<br />
<br />
};<br />
<br />
<br />
<br />
class Ball : public ObjectRoot <br />
{<br />
public :<br />
<br />
virtual ~Ball<br />
};<br />
<br />
ObjectRoot::~ObjectRoot<br />
{<br />
......<br />
......<br />
......<br />
}<br />
<br />
<br />
Ball::~Ball <br />
{<br />
}
CAN ANYONE TELL ME WHAT IS GOING ON HERE PLZ
-- modified at 16:59 Tuesday 4th July, 2006
|
|
|
|
|
The virtual destructor allows the destructor of derived classes to be called when deleting the instance through the base class.
In other words, an instance of Ball can be assigned to an ObjectRoot pointer:
ObjectRoot* pBase = (ObjectRoot*) new Ball;
and then deleted:
delete pBase;
The virtual destructor ensures that Ball's destructor will be called.
Often, destructors do nothing, but the empty virtual implementation is left just in case something later is added.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
class A {
public:
A() { }
~A() { }
};
class B : public A {
public:
B() { }
~B() { }
};
B* b = new B();
delete b;
A* a = new B();
delete a;
When a C++ compiler sees a method call, it first checks to see if the method is virtual or not. If it is not virtual, it will use the object variable's static type information, to determine what method to call. If the variable is of type B* , it will first look in B 's definition, and fallback on A if no matching method could be found.
If the method is virtual, the compiler will generate code which calls the method furthest down in the inheritance tree.
The same idea applies to destructors. If you call delete on b , as above, the compiler will first check if the destructor is virtual in the class hierarchy. In this case, it's not. Therefore it will inspect B 's definition, as the variable is of type B* . It'll find the destructor, and call it. After that, the compiler will generate code which calls all parent classes' destructors. In the case of the variable a , the compiler will, as earlier, see that the destructor is not virtual, and will therefore look into A 's definition for the destructor (a is of type A* ). The compiler will then generate code which calls A::~A() , and nothing more. You can easily understand that this is a problem, if B::B() did stuff like new ... .
Two analogies: virtual destructors are like doubly linked lists; you can always find the end of the list from any node in the list - meaning that the compiler will always call the destructor furthest down the inheritance tree, and then work its way back to the root. Non-virtual destructors are like singly linked lists; you can not find the end of the list from all nodes in the list - meaning that the compiler can't call the destructors which comes "after" the class in question.
The golden rule: virtual methods are virtual, if and only if, the first declaration is declared as virtual.
--
Transmitido en Martian en SAP
|
|
|
|
|
Hey, thanks for the descriptive information on destructors. The only problem is that Im a beginner.
A* a = new B();
how can a Pointer to an A object create a new B object?
its like saying
int *a = new double;
Im definately not right but, I have a hard time thinking how it looks like
Please help me out here.
Thanks,
Jay
|
|
|
|