|
Can you post the entire CPassword function and the DataSet class...it would help to understand your problem
the problem can be in the try catch.....how do you implement the catch (not reported in the forum)
|
|
|
|
|
Thank u for ur reply.
Actually I solved my problem by not returning 'DataSet' object, it pass as a reference in function parameter.
|
|
|
|
|
Ok, so first off, I'm really new to C++ so please let me know if this is in the wrong forum. I'm trying to finish a small project using Visual Studio 2008 Professional and I'm running into an error:
"The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail".
So this is roughly what I'm doing:
1. Create a new Windows Forms Application project
2. Add some Labels (one of them is dynamic and displays the current time), some bitmap pictures, and a clickable hyperlink
3. Create a version.rc file to display version info on the compiled .EXE file.
4. After making sure it runs in Debug mode, I compile it in Release mode
The compiled .EXE file works just fine on my 64-bit Windows 7 box I'm developing on, and it works fine on several 32-bit Windows 7 machines I've tested. It also worked on an XP box I got my hands on. However, when I had some others here at work test it, they got the above error on a Windows Vista machine and on a Windows XP machine.
So what gives? How can I create a simple little app that we can launch on all the various newer (XP on up) operating systems without having to rely on a prerequisite add-on being installed? I'm just looking to create some basic user notification windows. Nothing too fancy.
Is there something I need to change to get this thing to work consistently on all the OSes? Or do I need to do something other than a Windows Forms Application?
Thanks!
|
|
|
|
|
|
I think I've got it working now. I ended up copying the files located in "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT" into the same folder as my .EXE and it now seems to be working on all the machines I've tested.
|
|
|
|
|
Instead of manually copuing the required CRT files, you might want to look into using a Setup and Deployment project. Right-click on the project and select Add Merge Module, and select the module corresponding to the CRT file you listed above. If there are any components your app depends on, you can add those to the project as well. When the user runs the generated setup.exe file, it will autoamtically install the prerequisites (including the merge module), and then install your app.
Regarding the prerequistes, there's a handy utility here[^] that allows you to build custom prerequisite packages for VS.
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Hi ,
I am new to VC++/CLI and have been struggling with creating an expandable property in the property grid. I can create an expandbale property with an ExpabdableObjectConverter and I can even customize its vaklue field by overriding the ToString() method but where I run into problems is with TypeConverter. I want to create a simple expandable property, say Person, that has subproperties LastName, FirstName and ID - ID is an int. I can't seem to understand if I need CanConvertFrom, ConvertFrom, CanConvertTo and ConvertTo. I am finding TypeConverter very difficult and would appreciate any help you may be able to provide. Would anyone kindly direct me to some info or an example on how to do this? Thank you very much in advance.
Regards,
Paul
The code I have so far is
ref class CustomPersonConverter;
[TypeConverter(CustomPersonConverter::typeid)]
ref class CustomPerson {
private:
String^ _FirstName;
String^ _LastName;
int _ID;
public:
CustomPerson(void) {}
[DisplayName("Person's first name")]
[Description("First Name"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property String^ FirstName {
String^ get() {return _FirstName;}
void set(String^ new_FirstName) {_FirstName=new_FirstName;}
}
[Description("Last Name"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property String^ LastName {
String^ get() {return _LastName;}
void set(String^ new_LastName) {_LastName=new_LastName;}
}
[Description("ID"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property int ID {
int get() {return _ID;}
void set(int new_ID) {_ID=new_ID;}
}
[System::Security::Permissions::PermissionSet(System::Security::
Permissions::SecurityAction::Demand, Name = "FullTrust")]
ref class CustomPersonConverter : public TypeConverter {
public:
virtual bool GetPropertiesSupported(ITypeDescriptorContext^ context) override {
return true;
}
virtual PropertyDescriptorCollection^ GetProperties(ITypeDescriptorContext^
context, Object^ value, array<Attribute^>^ attributes) override
{
return TypeDescriptor::GetProperties(CustomPerson::typeid);
}
virtual bool CanConvertFrom(ITypeDescriptorContext^ context, Type^ sourceType)
override {
if ( sourceType == String::typeid | sourceType == InstanceDescriptor::typeid )
{
return true;
}
return TypeConverter::CanConvertFrom( context, sourceType );
}
virtual bool CanConvertTo( ITypeDescriptorContext^ context, Type^
destinationType ) override {
if ( destinationType == String::typeid | destinationType ==
InstanceDescriptor::typeid )
{
return true;
}
return TypeConverter::CanConvertTo( context, destinationType );
}
/* This code performs the actual conversion from a Person to an InstanceDescriptor. */
virtual Object^ ConvertTo( ITypeDescriptorContext^ context, CultureInfo^ culture,
Object^ value, Type^ destinationType ) override {
if ( destinationType == InstanceDescriptor::typeid )
{
return;
}
return TypeConverter::ConvertTo( context, culture, value, destinationType );
}
};
};
|
|
|
|
|
Hi,
I'm new to C++/CLI and I am getting compiler errors in a DLL appliction I am writing....
The DLL is passed in a text string from the calling application which needs to be cast to an unsigned int....
unsigned int^ pointParam = reinterpret_cast<unsigned int^>(dictParameters[POINT_PARAM]);
Then I am using the integer value to create an array of double values
but I need to increase the value by 2 so I thought I could add it in the array declaration statement...
sagXArray = gcnew array<double>(pointParam + 2);
I am getting the following compile error...
1>.\StrandedWireSag.cpp(42) : error C2676: binary '+' : 'System::UInt32 ^' does not define this operator or a conversion to a type acceptable to the predefined operator
Why is the compiler unhappy about adding two values in a declaration?
Thanks
|
|
|
|
|
The compiler complains because you are trying to add a number with a reference (a reference is like a C++ pointer, but it "points" to a garbage collected object).
unsigned int ^ is a reference to an unsigned int , so you should dereference it to get the actual value:
sagXArray = gcnew array<double>(*pointParam + 2);
But this will not work if you pass a number as a string (ex. "135"), you have to convert the string to a number using the method int::Parse :
int pointParam = int::Parse(dictParameters[POINT_PARAM]);
sagXArray = gcnew array<double>(pointParam + 2); Note that in this case I'm not dereferencing pointParam because it is declared as an int .
Hope it helps!
|
|
|
|
|
Hi Ghydo,
So, "reinterpret_cast" will cast to a reference (pointer), while "int::Parse" casts to a value.
Is that correct?
Thanks for the help!
regards,
Bert
|
|
|
|
|
Hi Bert,
reinterpret_cast can cast to anything you want: to cast to a unsigned int you can use reinterpret_cast<unsigned int^> . (MSDN[^])
int::Parse is a method that takes a string and converts it (not cast) into its integer value (string "135" --> int 135).
If dictParameters[POINT_PARAM] is an array of unsigned int ^ your cast was correct and you should dereference pointParam to obtain the value, but if it is an array of string you have to convert it using int::Parse .
How is dictParameters defined?
I hope it is clearer!
|
|
|
|
|
I'm almost brand new to C++ so I'm hoping someone can help me out. I'm using Visual Studio 2008 to create a C++ Windows Form application, and I want to display the current time in place of some static text I was previously using as one of my Label controls. I've spent some time poking around and I think I'm missing something basic.
I was trying something like this:
this->label1->Text = System::DateTime::Now;
and something a little more complexe like this:
this->label1->Text = (System::DateTime::Now.ToString("T"));
But no matter how I manipulate the line, either the code editor or the design editor within Visual Basic Studio barks at me. On my first example shown above, the code editor tells me it "....cannot convert parameter 1 from 'System::DateTime' to 'System::String ^'" while the design editor is just fine. And on my second example shown above, the design editor tells me "C++ CodeDOM parser error:Line:76, Column:56 --- Internal Error" while the code editor is just fine.
So can someone help me out here and let me know what I'm missing? My goal is to just have something like "5:11:45 PM" show up as the text of my Label control when a user runs the program.
Thanks!
|
|
|
|
|
I would start by dropping the parentheses around the righthand side.
|
|
|
|
|
If I change it to this: this->label1->Text = System::DateTime::Now.ToString("T");
I get the same error in the design editor as when it's set to this: this->label1->Text = (System::DateTime::Now.ToString("T"));
I should also mention, that as long as the code editor doesn't have a problem, when I run the compiled .EXE it works just fine. But I'm leary of ignoring an error in the design editor since this is kinda of my first C++ project.
|
|
|
|
|
Hi,
1.
as long as there are compiler errors, you are not running your new code.
you are either running a previous version (the last EXE that got build successfully), or not at all.
which it is depends on some option (see menu Tools/Options/Projects and Solutions/Build and Run/On Run, when errors occur...; I suggest "Do not launch").
2.
this->label1->Text=DateTime::Now.ToString("T");
works fine for me.
|
|
|
|
|
Okay, so this is what I tried just now...
1. Make a brand new Windows Forms Application project (in Visual Studio 2008 Professional Edition).
2. Place a Label control on the empty form.
3. Select View | Code.
4. Change the line that reads "this->label1->Text = L"label1";" to "this->label1->Text = DateTime::Now.ToString("T");"
5. Select Build | Build Solution.
6. The code editor says the build succeeded.
7. I click the "Form1.h" tab to switch to the design editor, and it says "C++ CodeDOM parser error:Line:70,Column:47 --- Internal Error".
So am I doing something wrong, or missing something?
|
|
|
|
|
Your code is correct, but you should not modify "by hand" the code inside the InitializeComponent method. You should put your custom initialization code inside the constructor, after the call to InitializeComponent() .
|
|
|
|
|
Wohoo! That did it. Thanks!
|
|
|
|
|
Hello, I need to know how to chagne text color.
for example, I declar a text variable
System::Object^ text; how do I change the color of variable text.
thanks.
|
|
|
|
|
i think you should get a book or start from http://msdn.microsoft.com/en-us/library/w0x726c2.aspx[^]
because you are missing the basics
...anyway in one form you can add this code:
System::Windows::Forms::Label ^my_label=gcnew System::Windows::Forms::Label();
my_label->ForeColor=System::Drawing::Color::FromArgb(255,0,0);
my_label->Location = System::Drawing::Point(0, 0);
my_label->Text = "my personal text";
and then add the object to some control object like form's one
this->Controls->Add(this->my_label);
|
|
|
|
|
jashimu wrote: System::Object^ text; how do I change the color of variable text.
You don't. A System::Object does not have a colour attribute, and if it did it would still not be much use. Text formatting is applied when the text is displayed on an output device such as a screen or printer. I also wonder why you are declaring a text item as a System::Object , I'm sure there is a more appropriate class to use.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Sorry, wrong Forum, please delete this Thread
Hallo,
I upgraded from Visual Studio 2005 to Visual Studio 2008, and converted my Project from from VS2005 to VS2008.
But now I get an Error in the following lines:
LOGFONT lFont;
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS), &ncm, 0));
lFont = ncm.lfMessageFont;
SystemParametersInfo() returns false, and there are the following Values in ncm after executing the SystemParametersInfo() Function:
When I open my Project in Windows 7, it works without problem. In XP I get an access exeption in msvcr90d.dll when I ignore the failed execution of SystemParametersInfo.
Can someone help me?
Thank you!
|
|
|
|
|
Are you generating a manifest file?
|
|
|
|
|
Hello,
I'm using VC++.I have a TextBox, and want to convert its String^ value to a char[512] array ???
I thank CodeProject...
|
|
|
|
|
use the search function of the forum....this has been discussed so much times...
hint: look for System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi then it'll be easy
|
|
|
|