|
Thanks Tobias, I'm using C++ BuilderX, a freeware. i've got C++ Builder 5. more like Visual C++. Actually i'm not a great fan of high level languages and object oriented stuff but i'm force to used C++... Huhuhuhuh... but i find it great. it's nice to explore things beside assembler stuff.
Thanks bro....
|
|
|
|
|
Thanks bro... i'm currently studying it. it's somewhat difficult for me learning C++ at the same time designing the Hardware and Software side of a USB interface.... Huhuhuhuhuh.... thanks for the support... i feel i'm not alone now in this square figure called cubicle..
Thanks,
Kuroro Rucilful
|
|
|
|
|
Hi I need to make a program where you get the price of an item and you get the change needed back. And then it needs to show the bills and cents given back to the customer. such as
Twenties: 2
Tens: 1
Fives: 1
Singles: 4
Quarters:
Dimes:
Nickles:
Pennies:
The only part I don't know how to do the output of the 20's and such, i understand everything before it. Please help Thanks (written in C++)
Also if you have extra time what is an up to date program to use for C++ code and how much/where can i get it
Kevin
-- modified at 17:11 Sunday 19th March, 2006
|
|
|
|
|
get the price in pennies format (total number of pennies) as an int.
nickels = pennies/5
pennies %= 5
quarters = nickels/5
nickels %= 5
dimes = nickels/2
nickels %= 2
singles = quarters/4
quarters %= 4
fives = singles/5
singles %= 5
tens = fives/2
fives %= 2
twenties = tens/2
tens %= 2
|
|
|
|
|
[memcpy() and Structs in MC++]
Ok, I have a problem (obviously).
For years now I have been writing realtime network code to send and receive data
as such:
<br />
struct Header<br />
{<br />
unsigned short size;<br />
unsigned short rangeID;<br />
unsigned short format;<br />
unsigned short numItems;<br />
char[] rangeName;<br />
...<br />
};<br />
struct TSPIFormat<br />
{<br />
unsigned short int InstRefID;<br />
unsigned short int InstID;<br />
unsigned short int InstType;<br />
double xVel;<br />
double yVel;<br />
double zVel;<br />
...<br />
};<br />
<br />
char buffer[1500];<br />
Header* TSPIHeader;<br />
TSPIFormat* TSPIData;<br />
TSPIHeader->RangeID = 1;<br />
TSPIHeader->format = 1;<br />
...<br />
TSPIdata = m_TrackList[i];<br />
...<br />
memcpy(&buffer[0],TSPIHeader,sizeof(Header));<br />
memcpy(&buffer[sizeof(Header)],TSPIData,sizeof(TSPIFormat));<br />
serverOut->SendTo(buffer,sizeof(Header)+sizeof(TSPIFormat),m_Port,m_IPAddress);<br />
And receiving it in the reverse manner.
Now that I'm trying to learn MC++ (ver 1.0, I havent delved into 2.0 yet) I'm having
trouble replicating this behavior in MC++.
I realize there isnt any sizeof() in MC++ and I think I understand the reasons why. But
the managed structs I create do not have a related size (because of the unknowns such
as the char array) so that I can pass off the different struct sizes to the memcpy().
I'm assuming there are other ways to Cast the structs into the char buffer such as marshalling
or streams, but I havent found concrete enough (for me) descriptions as to how these
structures would work in my situation.
If anyone can be of any help it would be greatly appreciated.
Thanks,
Scott
|
|
|
|
|
|
Hi,
I'm attempting to use an existing C++ codebase from a C# application. At certain times I need to let the unmanaged code notify the managed code (via a callback) that an event has occurred.
After having read a few articles on the subject I came up with the following piece of code. I'm not sure if this is the right way to do things, however, as several of the examples I found online were written using the old C++ managed syntax (using __event and __gc) and I wanted to use the newest syntax.
So, now I'm turning to you guys for advice. The code below works without any problems, but I want to know if it is even remotely correct (and by correct, I mean in accordance with the best practice approach):
Unmanaged C++ code:
http://blacksmith-studios.dk/csharp/Foo.h
http://blacksmith-studios.dk/csharp/Foo.cpp
Managed C++ code:
http://blacksmith-studios.dk/csharp/WrapperLib.h
http://blacksmith-studios.dk/csharp/WrapperLib.cpp
C# code
http://blacksmith-studios.dk/csharp/Main.cs
I've used the following article as a heavy reference:
http://www.codeguru.com/cpp/cpp/cpp...icle.php/c6867/
Thanks!
|
|
|
|
|
Heyas all,
So let's say that my windows form has approx 20 different textbox controls on it. I'm wanted to do something like this:
<br />
for each(System::Windows::Forms::Textbox txt in MainForm)<br />
{<br />
if (txt.Text.Length > 0) <br />
DoSomething();<br />
else if (txt.Text.Length == 0)<br />
DoSomethingElse();<br />
}<br />
<br />
Obviously this is semipseudocode and doesn't work, would anyone be willing to show me this code in working order?<br />
<br />
I'd really appreciate it.<br />
<br />
<br />
Thanks,<br />
John
|
|
|
|
|
MainForm is not a control! So your code won't work!
for each (System::Windows::Forms::Control ^control in this->Controls)
{
if (control->GetType() == TextBox::typeid)
{
TextBox ^tb = safe_cast<TextBox^>(control);
tb->Text = tb->Name;
}
}
-- modified at 17:55 Friday 17th March, 2006
|
|
|
|
|
Hey George,
I'm still working on this same problem, let me show you what I have:
<br />
for each(Control^ ctrl in this->AddCustomerFormSiteInformationGroupBox->Controls)<br />
{<br />
if (ctrl->GetType() == TextBox) {<br />
TextBox^ txt = safe_cast<TextBox^>(ctrl);<br />
<br />
if (txt->Text->Length > 0) {<br />
if (MessageBox::Show("Discard Changes?", "Confirm", MessageBoxButtons::YesNo, <br />
MessageBoxIcon::Warning) == ::DialogResult::Yes) <br />
this->Close();<br />
}<br />
else {<br />
this->Close();<br />
}<br />
}<br />
}<br />
I'm not sure what you're refering to with TextBox::typeid
Thanks,
John
|
|
|
|
|
for each (System::Windows::Forms::Control ^control in this->Controls)
{
if (control->GetType() == TextBox::typeid)
{
TextBox ^tb = safe_cast<TextBox^>(control);
tb->Text = tb->Name;
}
}
TextBox::typeid is the same as __typeof(TextBox) in MC++ 7.1
I hope that helps!
|
|
|
|
|
Hello everyone.
I need to get the status of a specific CheckBox inside a window of another application.
I've got the HWND of the control, I just need to know how to get its status (marked with V or not)
Any help would be appreciated.
|
|
|
|
|
<br />
SendMessage(hwnd, BM_GETCHECK , 0, 0)<br />
<br />
this return BST_CHECKED or BST_INDETERMINATE or BST_UNCHECKED <br />
<br />
|
|
|
|
|
What is the difference between normal C++, C++/CLI and managed C++? I do know the difference between normal C++ and managed C++, but what the heck is C++/CLI??
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
wikipedia:
"C++/CLI (Common Language Infrastructure) is the newer language specification due to supersede Managed Extensions for C++. Completely reviewed to simplify the older Managed C++ syntax, it provides much more clarity over code readability than Managed C++. Like Microsoft .NET, C++/CLI is standardized by ECMA. It is currently only available on Visual C++ 2005."
http://en.wikipedia.org/wiki/C%2B%2B/CLI
http://msdn2.microsoft.com/en-us/library/b23b94s7(en-us,vs.80).aspx
another msdn article which explains the New Language Design:
http://msdn2.microsoft.com/en-us/library/ms235215(VS.80).aspx
Tobias
|
|
|
|
|
why can't we create object of an abstract class?
|
|
|
|
|
MSDN help:
A member can only be defined in a derived type.
A type cannot be instantiated (can only act as a base type).
another resource:
http://cplus.about.com/od/cprogrammin1/l/bldef_abstract.htm
Definition: An abstract class can only be a base class for other classes. A class is abstract if it has any pure virtual functions.
This should explain your problem. (furthermore i think those facts are basic knowledge of progamming)
Tobias
|
|
|
|
|
are you calling into question the bases of OOP ?
|
|
|
|
|
I have a base shared library written in C++/CLI. It contains a pointer to an instance of an unmanaged class. I would like to expose this pointer to my C++/CLI executable that is using the library. At first I wrote this simple code:
public:
static property DataPointModel* DPModel
{
DataPointModel* get()
{
if( NULL == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
The DataPointModel class is actually implemented in an unmanaged library.
It appears that the compiler hides this function to all external libraries because it exposes an unmanaged pointer. Is there any way to get around this so that I can access this pointer?
-- modified at 17:51 Thursday 16th March, 2006
|
|
|
|
|
static property IntPtr DPModel
{
IntPtr get()
{
if( nullptr == m_sharedPortsContainer )
{
DeserializeModel();
}
return m_sharedPortsContainer;
}
}
I haven't tested this, but I believe it might work. You will have to cast, the returned value to your DataPointModel*, however.
|
|
|
|
|
First of all, this is the (Managed) C++/CLI Forum! You may have better luck posting in the Visual C++ Forum.
|
|
|
|
|
Alright, im working on a Plugin script in my application.
Every plugin got saved in a seperated Dll with a main class:
public ref class Plugin : public PluginInterface::IPlugin
IPlugin is a abstract class with some basic info like Name, Date, Descryption and a few virtual methods, Initialize and so on.
Now my load function:
void cPlugins::AddPlugin(System::String ^FileName)<br />
{<br />
Assembly^ PluginAssembly = Assembly::LoadFrom(FileName);<br />
<br />
for each (Type^ PluginType in PluginAssembly->GetTypes()){<br />
if (PluginType->IsPublic){<br />
if (!PluginType->IsAbstract){<br />
Types::AvailablePlugin^ NewPlugin = gcnew Types::AvailablePlugin();<br />
NewPlugin->Instance = dynamic_cast<IPlugin^>(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));<br />
<br />
if ((NewPlugin != nullptr)&&(NewPlugin->Instance!=nullptr)){<br />
NewPlugin->AssemblyPath = FileName;<br />
NewPlugin->Instance->Host = this;<br />
NewPlugin->Instance->Initialize();<br />
<br />
if (!this->AvailPlugins)<br />
this->AvailPlugins = gcnew Types::AvailablePlugins();<br />
this->AvailPlugins->Add(NewPlugin);<br />
}<br />
}<br />
}<br />
}<br />
}
or at least, code above is something like that. i tried to many different things. The definition of AvailablePlugin is like this,
public ref class AvailablePlugin<br />
{<br />
public:<br />
IPlugin^ Instance;<br />
String^ AssemblyPath;<br />
};
Now, for some or other reason, He wont give me a valid class. << Means, that the when i do a typecheck, he just says its a total different type. dynamic_cast<iplugin^>(Activator::CreateInstance(***)) wont agree with it.
How can i make this work? can anyone help?
Thanks already
|
|
|
|
|
Is this line correct?
NewPlugin->Instance = dynamic_cast(Activator::CreateInstance(PluginAssembly->GetType(PluginType->ToString())));
I can't see the type your are casting to? Probably a typo in your post. Wasn't it dynamic_cast < type-id > ( expression ) I guess you are using <IPlugin^>, don't you?
|
|
|
|
|
yes i am, as i already said, that piece of code is all messed up
|
|
|
|
|
I every one,
I want to know the maximum characters a String type can contain . 256 characters or more ?
|
|
|
|