|
If you email me the project (christian dot graus at gmail dot com ), I'll look at it for you.
But, next time ask in the right forum
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks! I really apreciate it.
About the wrong sorry, yeah :s sorry about that. Didnt see the Visual C++ formun 
|
|
|
|
|
Ok Christian, thanks for all the help but I managed to track down the error. Must of had some other bug I fixed before when I tried to compile everything under the same project because otherwise it should have worked.
The thing is that in the FMatrix.h header file included in the Test project I wasn't including the private definitions. I thought that the header acted more like an interface than anything else and thus private members were not needed.
Once I included the private definitios in the FMatrix.h header file inside the Test app the problem disappeared.
Thanks for your help!
|
|
|
|
|
No worries, glad to help ( and glad that people are still learning C++ )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi all ,
i have a problem when i am trying to connect to the data base via Network or via Web.
this is my connection string :
static private string GetConnectionString()
{
return "Data Source=10.0.0.25\\SQLEXPRESS\\Databases\\FWR.MDF;Integrated Security=True;User Instance=True";
}
and i recive this error exption :
(An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).
i want to know how to solve this error.
Best Regards
Ahmed EL Gendy
|
|
|
|
|
|
Dear all,
I want to use the DataSet component for my Multiclient application.
I want to use data sets in my wrapper class coded in managed C++ which provids an interface to my main application.
But I experienced some problem here. I want my DataSets will be act as a global one , through which all my functions in that class can access it.
How can I set it to be a global one ?
I can declare it in a function ...like :
A.cpp
-------------
void A::fun1()
{
Dataset^ ds;
ds = gcnew DataSet();
}
But when I am trying to set it in ".h " for public access ..like..
A.h
--------------
class A {
public :
Dataset^ ds;
};
I got some "mixing unmanaged and managed code " error...
I am a beginner in C++/CLI , but I need to port my existing VC 6 application
to VS 2005 and also I need to use DataSets for DB access .
So I use "#pragma managed " and "#pragma unmanaged " while compiling my application with /CLR option. Now I want to use the above said wrapper to replace my existing VC 6 wrapper class .
So pls help me...
Regards,
vinsankar
|
|
|
|
|
#include <vcclr.h>
...
class A {
public:
gcroot<Dataset^> ds;
};
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello George.L.Jackson,
Your suggestion is good .... thank you...
Can u pls give me some links or some good books to refer C++/CLI...?
Regards
vinsankar
|
|
|
|
|
|
Another data type conversion question:
Is it possible to pass a c# stream to a C++/CLI wrapper method which in turn converts it to VARIANT type and passes it to an unmanaged C++ method?
Here are the two pieces of code that I would like to see working together:
<code>
Stream csStream = ...
managed.ManagedMethod( csStreamVar );
UnmanagedClass::UnmanagedMethod( VARIANT unmanStream )
{
...
}
</code>
Can someone help me fill the following C++/CLI wrapper method that converts the stream to VARIANT?
<code>
ManagedClass::ManagedMethod( Stream^ manStream )
{
... How to convert? ...
unmanaged.UnmanagedMethod( ...???... );
}
</code>
Thanks,
-----------------
Genaro
|
|
|
|
|
picazo wrote: Is it possible
Yes but you have to know what is in the stream to know how to configure the VARIANT, unless of course you have some Magic++ library that does that for you.
led mike
|
|
|
|
|
Can you give me an example of how you would do this if the stream is to contain well-formatted xml.
-----------------
Genaro
|
|
|
|
|
picazo wrote: Can you give me an example of how you would do this if the stream is to contain well-formatted xml
No, I will show an example of how things work, I will not do your work for you by providing you an example of how I "would" do it.
System::Xml::XmlDocument^ doc = gcnew System::Xml::XmlDocument();
System::IO::StringReader^ stream = gcnew System::IO::StringReader("<halp><halpme value=\"22\"/></halpme>");
doc->Load(stream);
System::String^ managedStr = doc->DocumentElement->Name;
System::String^ sval =
((System::Xml::XmlElement^)doc->DocumentElement->FirstChild)->GetAttribute("value");
int nval = System::Convert::ToInt32( sval);
_variant_t variant(nval);
std::cout << nval << std::endl;
std::cout << (int)variant << std::endl;
led mike
|
|
|
|
|
Hello,
I have the following unmanaged method:
<code>
BSTR UnmanagedClass::UnmanagedMethod( BSTR x, VARIANT y, BSTR z )
{
...
}
</code>
I am wrapping that method with the following C++/CLI method:
<code>
String^ ManagedClass::ManagedMethod( String^ x, String^ y, String^ z )
{
CComBSTR bstrX, bstrZ;
bstrX.Attach( ( BSTR )( void * )Marshal::StringToBSTR( x ) );
bstrZ.Attach( ( BSTR )( void * )Marshal::StringToBSTR( z ) );
????
return gcnew String( unmanaged->UnmanagedMethod( bstrX, ???, bstrZ ) );
}
</code>
The C++/CLI wrapper method will be accessed from C# as follows:
<code>
string x="some value", y="another value", z="a third value";
managed.ManagedMethod( x, y, z );
</code>
The problem I am having is converting the managed string handle (String^ y) to an unmanaged VARIANT parameter. I would like to be able to solve this problem without having to modify the unmanaged C++ code. Does anyone have any suggestions or ideas on how to do this?
Thanks in advance,
-----------------
Genaro
|
|
|
|
|
picazo wrote: Marshal::StringToBSTR
Returns an IntPtr. You can't just cast that to a BSTR you have to use a method like ToInt32().
led mike
|
|
|
|
|
led mike wrote: You can't just cast that to a BSTR you have to use a method like ToInt32().
ToPointer would be a better method to use there.
|
|
|
|
|
Nishant Sivakumar wrote: would be a better method to use
Sure but my level of apathy for people writing production code that can't blow their own nose is fairly high today.
I feel like starting a new CodeProject account with the user name "HellNo" for replying to all the "can you provide the code" lovelies. Or maybe I shoudl write a programming book titled "Copy Paste for Idiots"... wait...
Chapter One
Copy the following code and paste it into your code file at the appropriate location:
<code>int n = 11;</code>
Now modify the code until it produces the desired results. There finished... now all I need is to send it off to a publisher.
led mike
|
|
|
|
|
You could do a String^ -> BSTR -> VARIANT.
|
|
|
|
|
could you provide some sample code of how to do this? I thought of doing that, but I couldn't get it to work.
Thanks,
-----------------
Genaro
|
|
|
|
|
picazo wrote: could you provide some sample code of how to do this? I thought of doing that, but I couldn't get it to work.
Since you've already written code to convert String^ to BSTR, I presume your problem is with converting that to a VARIANT. To do that, you can use _variant_t which has a constructor that takes a BSTR, and use that. You can pass _variant_t anywhere a VARIANT is expected.
|
|
|
|
|
Hey Guys,
I have a simple DLL file that performs an smtp email function for one of my applications. The problem with the DLL is - it sends an OK dialog box to the user once the email has successfully been sent. I was wondering if it were simple enough for you to remove the OK dialog box from the DLL.
If successful the OK dialog box should not appear after the email has been sent.
Can a DLL be changed like this, or do I have to create a new one altogether?
Thank you,
Stephen
Big Steve
Independant programmer for small business. Client management solutions
(888) 263-2690
|
|
|
|
|
It depends if you have the source code or not, I suspect not.
If the functionality of the DLL is not too large, then I would just rewrite it - it would be much quicker than trying to hack the DLL.
|
|
|
|
|
I have posted this under Visual Studio too as i was unsure of the correct fourm.
I have a Crystal Report 10 report which i need to use in my app. I use Managed solution for this. There are no compiler or linker problems. I am not able to display this report on the screen but am able to print the report. I tried all member methods - Visible, Show, BringToFront, set_Size etc. Am i missing something.?
Here is the code snippet for your ref:
crReportDocument = new ReportDocument();
// MessageBox("Report Document Instance Created", "New Reports");
crReportDocument->Load("BATCHSQL.RPT");
// MessageBox("File Loaded to Report Document Instance ", "New Reports");
//Setup the connection information structure to be used
//to log onto the datasource for the report.
crConnectionInfo = new ConnectionInfo();
// MessageBox("Connection Info set", "New Reports");
//Get the table information from the report
crDatabase = crReportDocument->Database;
crTables = crDatabase->Tables;
// MessageBox("Start Looping through all tables in the REPORT", "New Reports");
//Loop through all tables in the report and apply the connection information for each table.
// MessageBox("Show the Report", "New Reports");
//Set the viewer to the report object to be previewed.
crViewer = new CrystalReportViewer();
crViewer->ReportSource = crReportDocument;
// MessageBox("View the Report", "New Reports");
crViewer->Location = System::Drawing::Point(60, 60);
crViewer->Size = System::Drawing::Size(750, 750);
crViewer->Show();
crViewer->BringToFront();
crViewer->Visible = TRUE ;
crViewer->RefreshReport();
crViewer->Zoom(200);
crViewer->DisplayToolbar = TRUE ;
crViewer->DisplayBackgroundEdge = TRUE;
// crViewer->PrintReport(); ---- This works
MessageBox("Refreshing of the Report Complete", "New Reports");
Any suggestions?
Thanks,
Madhu

|
|
|
|
|
Hello,
I was using extern functions like:
<br />
extern "C" <br />
{ <br />
__declspec (dllimport) int TextExtern(int sizel);<br />
<br />
}
in MFC, when I try to use this with CLI it takes such a long time to load this function that it is imposible to use this function. Just in case this extern function TextExtern is writed in FORTRAN
Can anybody help me??
Thanks,
Best regards
|
|
|
|