Click here to Skip to main content
15,889,281 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionShow a dialog inside a third party application. Pin
emmmatty13-Oct-10 19:49
emmmatty13-Oct-10 19:49 
AnswerRe: Show a dialog inside a third party application. Pin
Nish Nishant5-Oct-10 5:04
sitebuilderNish Nishant5-Oct-10 5:04 
QuestionChange the colour of a selected cell on a C++ Datagrid view Pin
Ger Hayden3-Oct-10 3:54
Ger Hayden3-Oct-10 3:54 
AnswerRe: Change the colour of a selected cell on a C++ Datagrid view Pin
Nish Nishant5-Oct-10 5:02
sitebuilderNish Nishant5-Oct-10 5:02 
QuestionCLI/BOOL to bool conversion. Pin
Mike Doner28-Sep-10 5:34
Mike Doner28-Sep-10 5:34 
AnswerRe: CLI/BOOL to bool conversion. Pin
Nish Nishant28-Sep-10 6:35
sitebuilderNish Nishant28-Sep-10 6:35 
GeneralRe: CLI/BOOL to bool conversion. Pin
Mike Doner28-Sep-10 7:01
Mike Doner28-Sep-10 7:01 
QuestionProcessing mouse events in C# works - how do I do the same in managed C++? Pin
i_kant_spel26-Sep-10 16:09
i_kant_spel26-Sep-10 16:09 
I'm using the HookManager class provided here:
Processing Global Mouse and Keyboard Hooks in C#[^]

I've reduced the included demo app to do nothing but trap mouse movement and print a message each time. The code looks like this:
using System;
using System.Windows.Forms;
using UserActivityMonitor;

namespace UserActivityMonitorDemo
{
    public partial class TestFormStatic : Form
    {
        public TestFormStatic()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            HookManager.MouseMove += HookManager_MouseMove;
        }

        private void HookManager_MouseMove(object sender, MouseEventArgs e)
        {
            textBoxLog.Text += "Mouse was moved!" + System.Environment.NewLine;
        }

    }
}


I want to be able to use this in C++, but I'm not really sure how to handle events in managed C++, and searching through Google/MSDN is giving me mixed messages. This is more or less what I tried first:
#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace System::Windows::Forms;
using namespace UserActivityMonitor;
using namespace std;

void HookManager_MouseMove(Object^ sender, MouseEventArgs^ e)
{
	cout << "Mouse was moved!\n";
}

int _tmain(int argc, _TCHAR* argv[])
{
	HookManager::MouseMove += HookManager_MouseMove;

	while (true)
	{
		::System::Threading::Thread::Sleep(100);
	}
	return 0;
}


It won't compile. The part where I'm trying to add the HookManager_MouseMove function gives this error:
error C2664: 'UserActivityMonitor::HookManager::MouseMove::add' : cannot convert parameter 1 from 'void (__clrcall *)(System::Object ^,System::Windows::Forms::MouseEventArgs ^)' to 'System::Windows::Forms::MouseEventHandler ^'

I've tried changing the function from void to MouseEventHandler, but then I have to make it return a value, and I have no idea what to do about that, so I suspect that's barking up the wrong tree. What do I do?

Thanks.
AnswerRe: Processing mouse events in C# works - how do I do the same in managed C++? Pin
Nish Nishant27-Sep-10 11:47
sitebuilderNish Nishant27-Sep-10 11:47 
AnswerRe: Processing mouse events in C# works - how do I do the same in managed C++? Pin
Dave Doknjas27-Sep-10 18:18
Dave Doknjas27-Sep-10 18:18 
GeneralRe: Processing mouse events in C# works - how do I do the same in managed C++? Pin
i_kant_spel28-Sep-10 11:35
i_kant_spel28-Sep-10 11:35 
QuestionBest practise for embedding .NET Winforms in MFC MDI App Pin
Rolf Kristensen20-Sep-10 10:04
Rolf Kristensen20-Sep-10 10:04 
AnswerRe: Best practise for embedding .NET Winforms in MFC MDI App Pin
Nish Nishant22-Sep-10 12:54
sitebuilderNish Nishant22-Sep-10 12:54 
GeneralRe: Best practise for embedding .NET Winforms in MFC MDI App [modified] Pin
Rolf Kristensen22-Sep-10 21:05
Rolf Kristensen22-Sep-10 21:05 
GeneralRe: Best practise for embedding .NET Winforms in MFC MDI App Pin
Nish Nishant23-Sep-10 3:13
sitebuilderNish Nishant23-Sep-10 3:13 
GeneralRe: Best practise for embedding .NET Winforms in MFC MDI App [modified] Pin
Rolf Kristensen23-Sep-10 3:20
Rolf Kristensen23-Sep-10 3:20 
GeneralRe: Best practise for embedding .NET Winforms in MFC MDI App Pin
Nish Nishant24-Sep-10 4:14
sitebuilderNish Nishant24-Sep-10 4:14 
QuestionConversion between array&lt;String^&gt;^ and const char *const* and back? Pin
Ed K15-Sep-10 8:19
Ed K15-Sep-10 8:19 
AnswerRe: Conversion between array<String^>^ and const char *const* and back? Pin
N a v a n e e t h15-Sep-10 22:50
N a v a n e e t h15-Sep-10 22:50 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
ian__lindsay16-Sep-10 0:30
ian__lindsay16-Sep-10 0:30 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
N a v a n e e t h16-Sep-10 1:11
N a v a n e e t h16-Sep-10 1:11 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
Luc Pattyn16-Sep-10 1:38
sitebuilderLuc Pattyn16-Sep-10 1:38 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
N a v a n e e t h16-Sep-10 2:24
N a v a n e e t h16-Sep-10 2:24 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
Luc Pattyn16-Sep-10 2:27
sitebuilderLuc Pattyn16-Sep-10 2:27 
GeneralRe: Conversion between array^ and const char *const* and back? Pin
N a v a n e e t h16-Sep-10 18:01
N a v a n e e t h16-Sep-10 18:01 

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.