|
You'll need partial template specialization for this to work. Ie:
#include <vcclr.h>
using namespace System;
template <typename T> class TestClass
{
T member;
public:
TestClass (T mem) : member (mem){}
};
template <typename T> class TestClass<T^>
{
gcroot<T^> member;
public:
TestClass (T^ mem) : member (mem){}
};
int main(array<System::String ^> ^args)
{
TestClass<String^> tc(gcnew System::String(L"something")); //managed
TestClass<int> tn(1); //native
return 0;
}
<hr>
<a href = http://www.codeproject.com/script/profile/whos_who.asp?id=14112#Blog> My programming blahblahblah blog</a>. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Oooh ok. I did try partial specialization, but I didn't get the syntax for specializing for managed classes (T^). I guess the syntax is the same as for specializing for T*.
Thanks a lot.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Dear fellow CPians,
I am perplexed as to what's the fuss about a trivial phrase like 'Initialisation is Resource Acquisition'. I would be grateful if some kind enlightened soul could shed some light on it. What does it signify?
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
|
|
Guys thanks a lot for the pointers. Its not a big deal after all, only the obvious restated as jargon.
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
I'm using visual C++ .NET, and I'd like to make an ActiveX control for on a website, but I fail to find how to do it.. Sure you have many sites on how to us vb.NET and C# into a control for a website (such as, say; windows update), but I can't find a *manual* that says how to do it in vc++ .NET.
I know it's something with making an assembly, but.. that's all i have now.. an empry assembly..
Any help is much appreciated,
Michael
|
|
|
|
|
It's actually alot easier than you would suspect.
There is a utility that is included with the .NET Framework SDK, called:
AxImp.exe
This converts your ActiveX control into a .NET assembly.
|
|
|
|
|
Sounds pretty simple, you just need a nested loop.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If both arrays are same size, then you can just put them into a
for(i=0;i<length;i++)
snprintf(newarray, maxlen, "%s/%s", oldarray[0][i], oldarray[1][i]);
Otherwise, as Christian says, a nested loop.
|
|
|
|
|
Hi all,
I've got an application where a window (parent) opens a child window. How do I ensure that only one of these windows (child) can be open at any time????
Thanks all
|
|
|
|
|
The problem now is that I need to check whether the form is open and if so bring it to the front when required. I can do this ok but when I've closed the from it won't reopen until an application restart.
Any ideas anyone???
|
|
|
|
|
I've got some C++ classes doing some math and I want to use them in windows forms app.
I add for example file.cpp and file.h to project
////////////////////////////////////////////////////////////////////////
file.h
class Test1
{
public:
Test1();
~Test1();
...etc
};
file.cpp
Test1::Test1()
{
etc...
}
...etc...
////////////////////////////////////////////////////////////////////////
then add some button to windows form for instance:
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
Test1 *pp;
pp = new Test1; //err no default constructor
pp->func();
}
and then comes a lot of errors for this Test1 class allocation?
9ine
|
|
|
|
|
The most likely problem is that you need to add #include "stdafx.h" at the top of your cpp file. OTherwise, there's no reason for the class to not fit in with no changes
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
the problem was that I as accustomed put (#include "testclass.h") to the Form1.cpp file of the windows forms and (class TestClass;) in Form1.h which was the problem with "no default constructors" and the like erro messages for TestClass, but it should be only (#include "testclass.h") in Form1.h file and all activity concerning my TestClass should be in Form1.h file only.
9ine
|
|
|
|
|
I have my Form borders set to "none", because I am using a bitmap for my
background. How do I drag the Form so the user can move the Form?
|
|
|
|
|
By catching a click and drag in whatever area works for you and setting your own window position based on the difference between the current mouse pos, and the mouse pos when you last checked.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Would you show me some code examples?
|
|
|
|
|
POINT lastDrag
OnMouseDown
{
lastDrag = CurrentMousePosition (should be a parameter passed in to the event handler, but not this name )
}
OnMouseMove
{
POINT moved = lastDrag - CurrentMousePosition
lastDrag = CurrentMousePosition
::SetWindowPos(NULL, currentX + moved.X, currentY + moved.Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER)
}
This is pseudocode.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Here's the solution: http://www.codeproject.com/csharp/CustomForms.asp[^]
Point mouse_offset;
.._MouseDown(..., System::Windows::Forms::MouseEventArgs * e)
{
mouse_offset = Point(-e->get_X(), -e->get_Y());
}
.._MouseMove(..., System::Windows::Forms::MouseEventArgs * e)
{
if (e->Button == MouseButtons::Left){
Point mousePos = this->get_MousePosition();
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
this->set_Location(mousePos);
}
}
|
|
|
|
|
I am having a difficult time convincing DevStudio 97 to accept and display Chinese character fonts during program time. When I run the exe the Chinese characters display fine, but only at runtime. I have been through all of the necessary steps with WinXP and the problem lies solely within Studio97 and C++. Does anybody have any ideas or suggestions specific to C++ 5.0 or Studio 97 that I am missing?
I have:
1) Installed/enabled East Asian fonts (XP)
2) Enabled various keyboard layouts applicable to the desired font (XP)
3) Installed appwzchs.dll
4) Set C++ resource files to default to ChinesePRC
5) Defined _Unicode
6) Entered WinMainCRTStartup as entry point in project settings
I am using PinYin IME.
I may be forgetting something here, if so I apologize. Any help, suggestions, critiques, ideas, etc. will be GREATLY APPRECIATED!!
|
|
|
|
|
You are in the wrong forum. This is the C++/CLI forum (the C++.NET forum). Perhaps you should be asking in the Visual C++ forum.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
|
I want to be able to get buddy lists from MSN Messenger. I wrote a little bit of code in C# that does that but I need to rewrite this in C++. I made a new new MFC dll project ( its supposed to be that way ) and added a reference to MessengerAPI. I cant seem to access the API in the same was as the C# code.
I am completely new to C++ so any help will be appreciated.
public ArrayList GetBuddyList()
{
MessengerAPI.Messenger msgr = new Messenger();
IMessengerContacts contacts;
ArrayList retlist = new ArrayList();
int i, j;
i = 1;
j = 1;
msgr.AutoSignin();
groups = msgr.MyGroups;
foreach (IMessengerGroup group in groups)
{
contacts = group.Contacts;
foreach (IMessengerContact contact in contacts)
{
if ( contact.Status == 2 )
{
ContactItem item = new ContactItem( contact.SigninName,
contact.FriendlyName );
retlist.Add( item );
}
}
}
msgr.Signout();
}
|
|
|
|
|
Hello,
i've inserted a .NET control in a MFC Dialog, i'd like to append functions to the events of the component but when i try to do (for example):
<br />
component1->OnItemMove += new OnItemMoveEvent(this, myFunction)<br />
the compiler gives my a C3363 error, saying that i cannot create a delegate for OnItemMoveEvent from a member of a unmanaged class (the dialog class where myFunction is defined) or a non member function.
Is there a "trick" to use .NET events from my MFC application or i cant do that in any way?
Thank you,
Gianmaria
|
|
|
|