|
Unfortunately C# generics are not C++ generics, C# doesn't support numeric generics because there is no common base class of int/float/whatever that support calculation operations. You can do it the old manner, creating a class for every type you wish to support. There is another solution that uses generics in a different manner here[^].
|
|
|
|
|
Hi, im using C# dll in VC++ application.I have somedetails in VC++ like
PageNumer
pageTitle
PageDesc
BoxDetail .
I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me.
VC++ Function:
struct SCS3OverVwPg
{
__int32 iOvrPgNo;
char sOvrPgTitle[30];
};
void CToolTab::SendOverview()
{
SCS3OverVwPg *pOverVw = 0;
pOverVw = new SCS3OverVwPg;
Globals1::gwtoolbar->SetTree(pOverVw);
}
C# function:
public struct SCS3Over
{
Int32 iOvrPgNo;
char[] sOvrPgTitle;
}
public void SetTree(SCS3Over x)
{
MessageBox.Show("Data received");
}
If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over'
If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.
Anu
|
|
|
|
|
the structure (SCS3Over ) in c# dll is public? if it's public you can directly use it in visual c++ without having to redeclare it...so your visual c code:
void CToolTab::SendOverview()
{
Globals1::SCS3Over tmp;
tmp.iOvrPgNo=1;
tmp.sOvrPgTitle="ciao";
Globals1::gwtoolbar->SetTree(tmp);
}
|
|
|
|
|
Hello everyone,[it may not be the correct place to ask but in case some one has an idea, please] I am wondering if any one know or can help me how to convert regular windows program to windows ce. My application is written in VS C++ 2005 and another one is in C#. What I am trying to do is convert both of the application and deploy into windows ce device.
Thanks
|
|
|
|
|
Ive been on this for 3 hours now something I thought that was going to be easy isnt
I have a richtextbox control that contains a rtf file (that cant be edited) in the form and Im wanting to print that somehow.
It doesnt seem easy to do, is there a short tutorial somewhere?
thanks zed
|
|
|
|
|
Hi,
RTB is one of those Controls that don't print right away; they need some Win32 assistance. See here[^].
|
|
|
|
|
Thanks Luc, Ill look into that
seems wierd that RTB doesnt support printing cause if u would make a list of what controls you would like to have printing functionality it would be at the top of the list!
I might just ignore RTB and use a webbrowser widget instead (since that supports printing)
|
|
|
|
|
hi friends,
i want to use datagridview in c++, i am using data binding. i add object list to binding and use this binding as data source to gridview. then i set the the dataPropertyName as the member of the object.
my problem is i am not able to view my data in the grid. at runtime i want to add objects to the binding so that they can be viewed in the grid.
my code is as below
//bs is the binding object
for(int j = 0; j< CustInfo.oCust->Customer->Count;j++)
bs->Add(gcnew CustomerDetails(custobject));
CustGridView->DataSource = bs;
DataGridViewColumn^ column1 = gcnew DataGridViewTextBoxColumn();
column1->DataPropertyName = "m_strName"; // member of CustomerDetails
column1->Name = "Name";
column1->Width = 227;
CustGridView->Columns->Add(column1);
DataGridViewColumn^ column2 = gcnew DataGridViewTextBoxColumn();
column2->DataPropertyName = "m_strStreet"; //// member of CustomerDetails
column2->Name = "Street";
column2->Width = 120;
CustGridView->Columns->Add(column2);
can any one help
thanks in anticipation
Regds
Samir
|
|
|
|
|
Hi,
I'm quite new to C++/CLI and ran into a problem. I'm trying to get data from some textboxes on a form, for use in another source file. I think the best way to do this is to make a method in the form code which gets the textbox data and passes is to the source file when called. However, somehow I cannot get this working. Can anyone maybe point me in the right direction?
Any help would be great!
|
|
|
|
|
is there some reletion between the first form and the second form....
do the first form generate the second form or the second form generate the first?
|
|
|
|
|
Actually the code in which the data from the form is needed is no form itself. There is no relation between the form and the source file in which the data from the form is to be used.
I hope this makes it clear.
|
|
|
|
|
google for this....and you'll find the solution
[DllImport("user32.dll")]
extern IntPtr FindWindow(String^ lpClassName, String^ lpWindowName);
once you have the pointer to the data's form, you have several way to get the data
|
|
|
|
|
I'll have a go with that at Google. Thanks for your help!
|
|
|
|
|
I want to convert an object to a string and if it is a float, double, etc,,, then I would want to set the precision like I can with a printf statement.
What would be an efficient way to test if a System::Object is some decimal type and then set the precision? Thanks
//I've tried the following, but it does not work properly
switch (System::Type::GetTypeCode(columnYValues[n]->GetType())) {
case System::TypeCode::Decimal:
case System::TypeCode::Double:
case System::TypeCode::Single:
X=System::String::Format( "{0:f15}", columnYValues[n]->ToString() );
break;
default:
X = columnYValues[n]->ToString();
}
I am trying to create pivot tables using decimal headers and half of the time it does not work because of C++ .NET or ADO .NET's string conversions and zero tolerance.
modified on Friday, April 9, 2010 2:38 AM
|
|
|
|
|
try with the following:
System::Convert::ToInt32
System::Convert::ToDouble
System::Convert::To......
|
|
|
|
|
I'm not sure if this is possible, since I haven't been able to find much of anything on it, but I'm looking to call a control's event handlers programmatically. What I have is an application with multiple windows. Across the top of the app in a tool bar and one of those buttons, lets say copy, must preform that action on whichever window is currently active. They only way I can think to do this (as for various reasons the only way I can get these windows is as an instance of System::Windows::Forms::Control) is to trigger its Key Pressed event handler with 'Ctrl+C', but I can't seem to get access to it. Is this even possible? And if so how?
Thanks!
|
|
|
|
|
So you press the button and want for example that in windows#1 it copy something, in windows#2 it copy something and so on....
if the toolbar is the 'creator' of the windows# you can use a list to have the pointer of all of the window you have created....then you can loop through the list and see which windows is active, and then call the specified function on that window....do i understand your problem?
|
|
|
|
|
Right, if the button is pushed the copy event is called in whatever window is currently active. I have the a active window part already, from the tool bar I have an 'active Window' pointer, so thats not a problem, but since that pointer is just a System::Windows::Forms::Control pointer, I don't have access to any of the controls specially written "Copy" functions, just the standard Forms::Control functions. All of the controls which have some sort of copy functionality already can do it through "Ctrl+C" so I wanted to know if I could programmatically trigger its KeyPress event handler to use their copy functionality. I'm just not sure how to trigger an event like keypress via code.
|
|
|
|
|
loaak at
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx[^]
also...you black boxes give you the possibilities only to use the "control+c" key or they provide also some public function to do the operations? if they give also public function you can always try to static_cast or dynamic_cast the Control pointer...if this is your case this is far better than trigger the ctr+c command
|
|
|
|
|
Hi,
IMO you should not attempt to call an event handler explicitly; one reason is you would have to provide fake parameters, sender wouldn't be a problem, the particular EventArgs may prove more difficult to fake. Unless of course you're absolutely sure the handler doesn't (and never will) use its parameters.
There are two alternatives I would recommend:
1. some events can be triggered by calling an appropriate method, e.g. Button.PerformClick().
2. when the functionality of an event handler is also useful outside the normel event handling, refactor it into a separate method, call that from the event handler, and from anywhere else you'd like to call it.
|
|
|
|
|
Thanks for the reply! My problem I have with you're second suggestion is that some of the windows contain third party controls, and are basically black boxes, so I cannot move that functionality into a seperate method. You're first suggestion seems promising, is there a way to do something like that, but with key stokes instead of Button.PerformClick()? Thanks!
|
|
|
|
|
yes, you can send key strokes and mouse actions to any window you like, whether in your own app or another one. However may be tricky, and error prone; the user (assuming there is one) may well interfere with your automation (or vice versa), so I do not recommend it in general.
If you must, there is the SendKeys class; its SendWait() method is useful. What I have been doing for mouse automation mostly is based on Win32 functions such as SetCursorPos() and SendInput(), both in user32.dll
WARNING: localization changes the shortcut letters that can be used to steer menu's and buttons.
|
|
|
|
|
We have been bringing our old C++ code that uses MFC into the .NET world by compiling it into a mixed-mode assembly. We have found that when this assembly is loaded in an AppDomain e.g. by NUnit or by ASP .NET, the dll is not unloaded when the AppDomain is unloaded. The host application can load the dll many times, and may eventually run out of memory.
I have found that this is due to static data. If I make a simple mixed mode assembly with no static data, or with a static object with a default constructor, the dll is unloaded correctly. If the object has a non-trivial constructor, then the dll is not unloaded.
Even the simplest MFC dll has a static CWinApp derived object, so I don't think it would be possible to remove this kind of static data from our mixed-mode dll without a removing its dependency on MFC (a task that is too big to contemplate at the moment). Is there any other way to force the mixed-mode dll to be freed when the AppDomain is unloaded?
|
|
|
|
|
Hi,
I am able to call the funtion successfully, when linked the dll implicitly.
But when I am linking explicitly using LoadLibrary and GetProcAddress, GetProcAddress returning NULL value.
what mightbe the problem, I am using the same function name as I have used while implicit linking.
regards,
Charan
|
|
|
|
|
Are you saying it works when you link statically? Have you exported the functions that are eligible to call?
Best wishes,
Navaneeth
|
|
|
|