|
I have prepeared project folllowing instrctions given in this article(Calling Managed .NET C# COM Objects from Unmanaged C++ Code).
I have used VS 2008 and .Net Framework 2.0 for both projects.
I am able to access ShowDialog() method as shown in this article but when i added another method to same interface it was not available in c++.
I checked both .tlb and .tlh file I can see both of them having declaration of new method added.
but I try to acces it through pDotNetCOMPtr-><new method="" not="" included="">
Please let me know what I am missing?
|
|
|
|
|
Did you rebuild the .NET project?
Also, it helps if you could show the code.
|
|
|
|
|
By the way, you might also consider making a mixed-mode C++ code. If you cannot put your original C++ code in that project without problems, you might then explore the possibility to create a mixed-mode layer.
In my case, my C++ code is compiled in mixed mode (/clr) so I can mix regular C++ with managed C++ in the same DLL. It might not always be feasible in existing code is large and uses incompatible options.
In that latter case, I might also try to have an extra DLL (mixed-mode C++) that would make the bridge between unmanaged C++ and managed code. Then existing C++ code would uses that DLL to indirectly call C# code.
This approch have some advantage like you could somehow adapt C++ code to be easier to uses or follows your C++ code convention or do some transformation between types like converting System::String^ to wstring for uses in C++.
I have never really tried the C# COM objects by their should be no problem with that method provided that all required symbols are public and GUID are assigned when required.
Philippe Mori
|
|
|
|
|
Hi all,
I wanna to connect postgresql, and I prefer to ODBC with MFC before.
However, I don't know how to do this by c++/cli, can any kind man give me some advice or some online ariticle about this?
Thanks in advance.
Joul
|
|
|
|
|
|
Hi,
I wanna to draw something in the panel which can be scrolled.
For example, I just want to draw a line in the panel, so I added the drawing codes in the on_paint event:
e->Graphics->DrawLine(bluePen, 0, 0, 100, 100);
And then it can be displayed correctly.
However, when I scrolled the vertical scroll bar, it can display ok, but sometimes display with remnant. I don't know whether it's a bug of the panel control.
So I tried to add "Invalidate" function to the panel scroll event, however, the panel can not display ok when scrolling.
Can any kind man give me some advice? Maybe it's a simple question.
Thanks.
Joul
|
|
|
|
|
hi, all.
I found the reason, just add AutoScrollPosition when drawing.
Joul
|
|
|
|
|
Hey Guys,
I've done some Googling and some MSDN searches, but no luck. What I have is two Windows forms. I want to be able to attach a file/files from one of the forms, and then have the other form be able to see/open these attachments. Any ideas on which controls, data structures, or methods to use? I'm a bit stumped right now. I've investigated the FileDialog class, but I don't think that's what I need.
[Insert Witty Sig Here]
|
|
|
|
|
1. The OpenFileDialog and SaveFileDialog let you interact with the user to determine which file he wants opened or saved, that is not what you want.
2. There is no universal control (or app) that can visualize any file you choose, unless in a very low-level form, such as a hex editor would do. So you will have to restrict the list of allowable file types, and/or use several controls, picking the one at run-time that corresponds to the current file type.
3. I have no idea what you mean by "attaching a file to a form".
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Here is a scenario. Form1 is for the manager. From form1 he can enter a description of a project, assign a lead, and enter comments. With most projects, there are associated .doc, .pdf, or .xls files. By attach, I mean that the manager can add those files, similar to an email, so that the lead, from Form2 can see the files. I don't want the files to be viewable/opened from Form2, I'm looking for a way for the manager to add these files, and then have the project lead receive the files from Form2. Sorry if this is a confusing description, I do appreciate the help.
[Insert Witty Sig Here]
|
|
|
|
|
OK, so "Project" would be one of your classes; your manager would use a "ProjectEditForm" to view and alter a Project, he would have some means to add ("attach") relevant files to the Project (maybe through an OpenFileDialog indeed), and the list of attached files should be kept in a collection (maybe a List<string>) and displayed somehow (maybe a ListBox or a TreeView).
The lead does not get the files from the manager's form, he should have his view on the same Project, maybe through a "ProjectViewForm" which could be similar to a "ProjectEditForm" with fewer privileges (and maybe also more details).
In my view you want to persist a Project somehow, maybe in an XML file, maybe in a database.
Conclusion: it is not form-communicates-to-other-form, it is an object-needing-persistence-and-multiple-views.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Can anyone know why the case for i=2 is not executed? stateA, B, C & D are object of my small classes.
The problem is that node5 & node6 are put into the arrays but node3 & node4 are not.
I debugged my program to watch closely step by step but I did not find out what is wrong.
Anyone?
CODE:
for(System::Int32 i=0; i<numOfBits_int+3; i++){
switch(i)
{
case 0:
stateA^ node0 = gcnew stateA(i,0,-1,-1);
aux_trellis1a[i] = node0;
break;
case 1:
String^ str1 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str2 = aux_trellis1a[i-1]->output0;
String^ str3 = aux_trellis1a[i-1]->output1;
stateA^ node1 = gcnew stateA(i,aux_trellis1a[i-1]->metric + compareStrings(str1,str2),i-1,0);
stateB^ node2 = gcnew stateB(i,aux_trellis1a[i-1]->metric + compareStrings(str1,str3),i-1,1);
aux_trellis1a[i] = node1;
aux_trellis1b[i] = node2;
break;
case 2:
String^ str4 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str5 = aux_trellis1a[i-1]->output0;
String^ str6 = aux_trellis1a[i-1]->output1;
stateA^ node3 = gcnew stateA(i,aux_trellis1a[i-1]->metric + compareStrings(str4,str5),i-1,0);
stateB^ node4 = gcnew stateB(i,aux_trellis1a[i-1]->metric + compareStrings(str4,str6),i-1,1);
aux_trellis1a[i] = node3;
aux_trellis1b[i] = node4;
String^ str7 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str8 = aux_trellis1b[i-1]->output0;
String^ str9 = aux_trellis1b[i-1]->output1;
stateC^ node5 = gcnew stateC(i,aux_trellis1b[i-1]->metric + compareStrings(str7,str10),i-1,0);
stateD^ node6 = gcnew stateD(i,aux_trellis1b[i-1]->metric + compareStrings(str7,str11),i-1,1);
aux_trellis1c[i] = node5;
aux_trellis1d[i] = node6;
break;
}
}
modified on Thursday, May 26, 2011 7:11 AM
|
|
|
|
|
I don't see how it couldn't work unless numOfBits_int is <= -1.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We don't have enough to go on.
What's numOfBits set to?
Do you reach the assignment statements or skip case 2 altogether?
Do any of the object ctors accept i by reference and change it?
John
|
|
|
|
|
numOfBits is always bigger than 3, so it's not a problem.
Case 2 is not skipped entirely because aux_trellis1c[2] and aux_trellis1d[2] are filled with appropriate nodes (node5 and node6). I worry why aux_trellis1a[2] and aux_trellis1b[2] are not filled when i has already reached value 3.
"i" is not changed by any other object, it is only internal argument for for loop.
Sorry for so lame description, I'm bad at programming, that is why I have stupid problems and probably the solution is very easy but I just can't see it:/
|
|
|
|
|
please use PRE tags when showing code snippets; they preserve indentation and improve readability. You could still edit your existing message!
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
OK, I don't see how it would be possible to execute the bottom half of a case.
I can only suggest you set a breakpoint at the first statement of case2 and single-step from there (assuming it goes wrong the very first time).
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hi,
I planed to create a form application with menubar and toolbar. I should let the program have the scroll bar, so I setted the AutoScroll = True, AutoScrollMinSize=(2000, 1000). And then the form application did have the scroll bar (both vertical and horizional).
However, there was a problem when I scrolled down the scroll bar, the menubar and the toolbar were scrolled down too. So when I scrolled the scroll bar, the menubar and the toolbar disappeared. very strange!
I had written some winform programs with VC++ 6.0 before, those components(menubar and toolbar) will not be disappeared when scrolling. Why the c++/cli winform program cannot work?
BTW, I'm using VC++ Express 2008. Maybe it's a very simple question, Can any kind man help me and tell me why?
Thanks in advance.
Joul
|
|
|
|
|
try this:
- fill the Form with your menubar, your toolbar, and a Panel (if the Form is resizable, make the Panel anchored or docked).
- make the Panel scroll (ScrollBars property).
- add all actual content to the Panel, not the Form.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for your kind reply.
hello!
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
BTW,I did some test right now, I added some painting codes in panel's on_paint function. However, the painting can not be double buffered, and the panel's double buffered property is private.
If I want to do some painting in the panel, there are some blinks when painting.
How about your idea about this?
Thanks.
Joul
|
|
|
|
|
There are two ways I know of:
1.
you derive your own DoubleBufferedPanel from the normal Panel, then in its constructor you can set the double-buffered property (as it is protected). Once you build a project with such DoubleBufferedPanel class present (but still unused), Visual Designer should have it available and now you can replace the Panel by a DoubleBufferedPanel.
2.
you can change the properties of a regular Panel at run-time, something akin to:
panel.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true);
panel.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,true);
panel.SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
oanel.UpdateStyles();
This also works on pre-2.0 .NET versions where Control.DoubleBuffered didn't exist.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi,
I did some test again, but panel.SetStyle is the private function, and I can not use that function.
For the first way, I can make a DoubleBufferedPanel class, but it's not convinent for visual designer.
I don't know if there is another way. Thanks.
hello!
|
|
|
|
|
Indeed, SetStyle isn't public either, my mistake. So you have to create your own Panel.
Here[^] is an article where I did exactly that; there is a download near the end. It is in C#, I trust it would be basically the same in C++//CLI. Getting Visual Designer to find the new controls depends on a number of factors, I don't think I know them all; one is your code has to compile; another may well be the new Control has to be the first (or only?) class in its source file.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|