Click here to Skip to main content
12,305,299 members (72,409 online)

Managed C++/CLI

 
QuestionHow to activate keys combination with hook ? Pin
zayl54317-Aug-12 0:18
memberzayl54317-Aug-12 0:18 
SuggestionRe: How to activate keys combination with hook ? Pin
sanjaylk12-Sep-12 2:00
membersanjaylk12-Sep-12 2:00 
Questionvoid GetFieldValue( LPCTSTR lpszName, CString& strValue ); Pin
lucky_122119-Jul-12 22:21
memberlucky_122119-Jul-12 22:21 
Questionsearch in a text fiel Pin
byank18-Jul-12 2:06
memberbyank18-Jul-12 2:06 
AnswerRe: search in a text fiel Pin
Richard MacCutchan18-Jul-12 3:28
mvpRichard MacCutchan18-Jul-12 3:28 
GeneralRe: search in a text fiel Pin
byank19-Jul-12 10:58
memberbyank19-Jul-12 10:58 
GeneralRe: search in a text fiel Pin
Richard MacCutchan19-Jul-12 22:05
mvpRichard MacCutchan19-Jul-12 22:05 
QuestionConvert string to integer only such that if it is alphanumeric or float it shouldnot return anything Pin
Abinash Mohanty17-Jul-12 3:13
memberAbinash Mohanty17-Jul-12 3:13 
GeneralRe: Convert string to integer only such that if it is alphanumeric or float it shouldnot return anything Pin
John Schroedl17-Jul-12 3:29
memberJohn Schroedl17-Jul-12 3:29 
GeneralRe: Convert string to integer only such that if it is alphanumeric or float it shouldnot return anything Pin
Abinash Mohanty17-Jul-12 18:13
memberAbinash Mohanty17-Jul-12 18:13 
QuestionRead char by char in a file after write char by char to another file in vc++. Pin
lucky_122116-Jul-12 23:03
memberlucky_122116-Jul-12 23:03 
AnswerRe: Read char by char in a file after write char by char to another file in vc++. Pin
Richard MacCutchan16-Jul-12 23:32
mvpRichard MacCutchan16-Jul-12 23:32 
QuestionC++/CLI - Pin a function pointer Pin
krishter10-Jul-12 23:16
memberkrishter10-Jul-12 23:16 
GeneralRe: C++/CLI - Pin a function pointer Pin
paul_7114-Jul-12 23:51
memberpaul_7114-Jul-12 23:51 
Difficult to say from what you have shown. You can pin a handle to a managed object only temporarily, since a pin_ptr can only be created on the stack. Therefore, if you have something like this:
IntPtr YourClass::GetFuncPointer()
{
    FuncDelegate^ fp = gcnew MessageFuncDelegate(this, &Handler);
    pin_ptr<MessageFuncDelegate^> pinnedFunctionPointer = &fp;
    return ((ProcMessageFunc)pinnedFunctionPointer);
}
then you effectively have only pinned fp for the duration of this method call. A correct way to do this depends on your scenario. I'd recommend something along the lines of the following (I didn't compile it, but you get the idea):

public ref class ClientRegistrar abstract sealed {
    static FuncDelegate^ s_ManagedReceiverList;
    
    // ...
    public static void RegisterClient(YourClient^ p_Client)
    {
        // thread safety for free
        s_ManagedReceiverList += 
            gcnew MessageFuncDelegate(p_Client, &YourClient::Handler);
 
        // here I assume that ::Receiver is an unmanaged global function which
        // takes a funtion pointer of type ProcMessageFunc. Don't know
        // if you need to deal with multiple registrations....
        ::Receiever((ProcMessageFunc)Marshal::GetFunctionPointerForDelegate(s_ManagedReceiver));
    }
 
    public static void UnregisterClient(YourClient^ p_Client)
    {
        s_ManagedReceiverList -=
            gcnew  MessageFuncDelegate(p_Client, &YourClient::Handler);
        // use the same schema to unregister from the native receiver
    }
}

Usage (C#):

YourClient tClient = new YourClient();
// ...
ClientRegistrar.RegisterClient(tClient);
// ...


s_ManagedReceiverList and any YourClient instance you register via RegisterClient will be kept alive as long as the current application domain will exist. Implement UnregisterClient if you need more fine grained control. A delegate does not need to be pinned, the CLR takes care of proper handling of that. It just needs to be kept alive.

Cheers,

Paul

modified 17-Jul-12 10:14am.

QuestionHow to Make and Use Resource DialogBoxes in VC++ 2008 Pin
ICEFLOWER226-Jun-12 4:07
memberICEFLOWER226-Jun-12 4:07 
AnswerRe: How to Make and Use Resource DialogBoxes in VC++ 2008 Pin
Richard MacCutchan26-Jun-12 4:31
mvpRichard MacCutchan26-Jun-12 4:31 
GeneralRe: How to Make and Use Resource DialogBoxes in VC++ 2008 Pin
ICEFLOWER226-Jun-12 7:53
memberICEFLOWER226-Jun-12 7:53 
GeneralRe: How to Make and Use Resource DialogBoxes in VC++ 2008 Pin
Richard MacCutchan26-Jun-12 8:24
mvpRichard MacCutchan26-Jun-12 8:24 
QuestionGetting MdiParent Instance From MdiChild - Windows Forms Application Pin
Paramu197312-Jun-12 1:50
memberParamu197312-Jun-12 1:50 
AnswerRe: Getting MdiParent Instance From MdiChild - Windows Forms Application Pin
Richard MacCutchan12-Jun-12 2:15
mvpRichard MacCutchan12-Jun-12 2:15 
GeneralRe: Getting MdiParent Instance From MdiChild - Windows Forms Application Pin
Paramu197312-Jun-12 2:30
memberParamu197312-Jun-12 2:30 
GeneralRe: Getting MdiParent Instance From MdiChild - Windows Forms Application Pin
Richard MacCutchan12-Jun-12 3:03
mvpRichard MacCutchan12-Jun-12 3:03 
GeneralRe: Getting MdiParent Instance From MdiChild - Windows Forms Application Pin
Paramu197315-Jun-12 1:30
memberParamu197315-Jun-12 1:30 
QuestionHow to convert from 'WCHAR' to 'System::String ^' Managed C++ Pin
ptr_Electron7-Jun-12 20:08
memberptr_Electron7-Jun-12 20:08 
AnswerRe: How to convert from 'WCHAR' to 'System::String ^' Managed C++ Pin
Richard MacCutchan7-Jun-12 21:58
mvpRichard MacCutchan7-Jun-12 21:58 
Questionint x = (Int32) thisisObjectType is boxing, if the type is already checked ? Pin
ptr_Electron7-Jun-12 18:15
memberptr_Electron7-Jun-12 18:15 
AnswerRe: int x = (Int32) thisisObjectType is boxing, if the type is already checked ? Pin
Richard MacCutchan8-Jun-12 0:34
mvpRichard MacCutchan8-Jun-12 0:34 
QuestionVS2010 Error()- Method or Property 'VCFilter::get_Url Behavior' deprecated and nolonger implemented Pin
Paramu19736-Jun-12 23:57
memberParamu19736-Jun-12 23:57 
QuestionC++ CX and WPF Pin
Super Lloyd6-Jun-12 15:04
memberSuper Lloyd6-Jun-12 15:04 
QuestionStrong vs static typing Pin
elelont25-Jun-12 9:37
memberelelont25-Jun-12 9:37 
AnswerRe: Strong vs static typing Pin
Paul Conrad5-Jun-12 10:37
memberPaul Conrad5-Jun-12 10:37 
GeneralRe: Strong vs static typing Pin
Luc Pattyn5-Jun-12 11:13
mvpLuc Pattyn5-Jun-12 11:13 
GeneralRe: Strong vs static typing Pin
Paul Conrad5-Jun-12 12:10
memberPaul Conrad5-Jun-12 12:10 
AnswerRe: Strong vs static typing Pin
Richard MacCutchan5-Jun-12 21:08
mvpRichard MacCutchan5-Jun-12 21:08 
GeneralRe: Strong vs static typing Pin
elelont26-Jun-12 5:09
memberelelont26-Jun-12 5:09 
GeneralRe: Strong vs static typing Pin
Richard MacCutchan6-Jun-12 5:21
mvpRichard MacCutchan6-Jun-12 5:21 
QuestionImage Integral Pin
MUJIS29-May-12 4:40
memberMUJIS29-May-12 4:40 
QuestionHow to get the total length of elements in ##__VA_ARGS__ Pin
elelont222-May-12 3:10
memberelelont222-May-12 3:10 
AnswerRe: How to get the total length of elements in ##__VA_ARGS__ Pin
jschell28-May-12 7:57
memberjschell28-May-12 7:57 
QuestionA calendar look like iCal of MacOsX Pin
XRay221-May-12 4:30
memberXRay221-May-12 4:30 
Questionc++ A Cessna Skyhawk Skeleton for Further Development in OpenGL (GLUT) Pin
ody kurniawan18-May-12 11:55
memberody kurniawan18-May-12 11:55 
QuestionType casting Pin
givinisha17-May-12 6:50
membergivinisha17-May-12 6:50 
AnswerRe: Type casting Pin
John Schroedl17-May-12 8:01
memberJohn Schroedl17-May-12 8:01 
QuestionVideo Display hangs in Windows after unlocking Pin
Faez Shingeri16-May-12 21:37
memberFaez Shingeri16-May-12 21:37 
AnswerRe: Video Display hangs in Windows after unlocking - Repost ... Pin
Richard MacCutchan16-May-12 23:12
mvpRichard MacCutchan16-May-12 23:12 
GeneralRe: Video Display hangs in Windows after unlocking - Repost ... Pin
Faez Shingeri16-May-12 23:16
memberFaez Shingeri16-May-12 23:16 
GeneralRe: Video Display hangs in Windows after unlocking - Repost ... Pin
John Schroedl17-May-12 3:28
memberJohn Schroedl17-May-12 3:28 
AnswerRe: Video Display hangs in Windows after unlocking Pin
jschell17-May-12 11:26
memberjschell17-May-12 11:26 
QuestionFinding a pointer from a list of pointers Pin
elelont226-Apr-12 20:21
memberelelont226-Apr-12 20:21 
AnswerRe: Finding a pointer from a list of pointers Pin
Richard MacCutchan26-Apr-12 22:28
mvpRichard MacCutchan26-Apr-12 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 24 May 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid