Hello Guest it is December 10, 2019, 06:38:55 PM

Author Topic: My First Plugin - Function, Forms And General Troubbles  (Read 6328 times)

0 Members and 1 Guest are viewing this topic.

My First Plugin - Function, Forms And General Troubbles
« on: January 02, 2010, 03:59:39 AM »
Im trying to integrate my keyboard hook program into a form in my mach 3 plugin.

I have included my project (created as 'CustomPlugin' and compiles and works great) as well as my stand alone KeyboardHook project that also works by itself

Here are my questions:
1) To use my keyboard hook it should be as simple as adding the Kennedy.ManagedHooks.dll to the references and then initilize the component as:
Code: [Select]
private Kennedy.ManagedHooks.KeyboardHook keyboardHook = null;
keyboardHook = new Kennedy.ManagedHooks.KeyboardHook();
keyboardHook.KeyboardEvent += new Kennedy.ManagedHooks.KeyboardHook.KeyboardEventHandler(Hook_KeyboardEvent);

then call install in a button:
Code: [Select]
void CPluginTestDlg::OnBnClickedHookInstall()
{
//  Install Keyboard Hook
DbgMsg(("keyboardHook Installed"));

//keyboardHook.InstallHook();
}

void CPluginTestDlg::OnBnClickedHookRemove()
{
//  Remove Keyboard Hook
DbgMsg(("keyboardHook Removed"));

//keyboardHook.UninstallHook();
//keyboardHook = NULL;
}

But I have no idea where to initialize my object! I have tried it in my CustomPluginInit.cpp's header, in myPostInitControl() and all no luck compiler throws errors. Where should I initialize this object?

2) General issue I don't understand. If I use project wizard and make a blank document then add a forum I can add things like textboxes. In my plugin project I cannot add test boxes.

3) General issue is that for some reason in all my other project having variable = null; is correct, 'null' is blued as normal but in my plugin project compuler says 'null' is not defined but I can use 'NULL' and the error clears but NULL does not blue.

Anyone know if I have some random setting messed up that is causing my issues?

Thanks!

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #1 on: January 02, 2010, 11:10:01 AM »
I've been working with the plugin wizard. My project is created in VS 2008.NET. I just added your hooks DLL to my project with no problem. Im not sure how to do it with 2003.
Ryan

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #2 on: January 02, 2010, 11:16:46 AM »
I'm no expert. I just have hundreds of hours learning c++ 2008.NET. I've run into many problems getting the wiiuse dll working with my plugin. I climbed that hill so hopefully I can help you.
Ryan
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #3 on: January 02, 2010, 02:31:28 PM »
Thanks for the response.

I was using VS 2008 myself but I was running into unicode compatibility issues, the same project 2008 would not compile works perfectly in 2003. I followed jemmyell's 'Mach3 Plugin Tutorial Document and Prototype File Set' and had no issues at all besides needing to add the off include to resolve a dependency. My customplugin is a perfect working version of that tutorial that I tried to add the hooks dll to.

I see in your object browser you can actually view the function blocks, in my other projects by adding them to the references they add to the object browser but I have had to manually add system,design,forms,hooks to the object browser manually. This might be normal but usually its automatic for me.

Can you offer any insight to why my null assignments don't work or to why I cannot create a text box?

Also since you can add the dll easily have you been able to initialize the hook object successfully by chance?? (the block of code in pic two)

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #4 on: January 02, 2010, 03:24:26 PM »
I put this line.

Kennedy::ManagedHooks::KeyboardHook^ keyboardHook = gcnew Kennedy::ManagedHooks::KeyboardHook;

Compiled with no errors

Ryan
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #5 on: January 02, 2010, 04:52:10 PM »
Quote
I put this line.

Kennedy::ManagedHooks::KeyboardHook^ keyboardHook = gcnew Kennedy::ManagedHooks::KeyboardHook;

Compiled with no errors

Where did you put that line?? I have tried it in my form initilization, as well as my postinit and customplugininit.cpp header and be it using ::/./-> referencing the compiler does not acknowledge Kennedy as a valad class or namespace at all.

Could you put the line in my project and see if it compile then send the project back? Maybe it works with 2008 but not 2003 but that would suck...

What I don't understand is why in my hook example app does my object work with direct (.) member access and not work in my plugins. I included the Kennedy.ManagedHooks.dll in the same with with both projects and the compile time options are the same (Besides my plugin being a dll that is)
« Last Edit: January 02, 2010, 05:31:30 PM by iceblu3710 »

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #6 on: January 02, 2010, 06:15:44 PM »
Its different in 2008. I also tried it several ways in 2003 and no luck. Try the plugin wizard in 2008.NET
Ryan

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #7 on: January 02, 2010, 06:27:20 PM »
I put the line several places in my code to test
Ryan
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #8 on: January 02, 2010, 07:13:57 PM »
Hey,

I did a VS2008 test with the wizard and i can initialize now buy why on earth is the syntax so different? The documentation states things a bit oversimplified:

Code: [Select]
mouseHook = new MouseHook(); // mouseHook is a member variable

mouseHook.MouseEvent += new MouseHook.MouseEventHandler(mouseHook_MouseEvent);


private void mouseHook_MouseEvent(MouseEvents mEvent, int x, int y)
{
    string msg = string.Format("Mouse event: {0}: ({1},{2}).",
                                           mEvent.ToString(), x, y);
    AddText(msg); // Adds the message to the text box.

}

mouseHook.InstallHook();

mouseHook.UninstallHook();

and says its a pretty standard c++ implementation but its assumed you know how to add all the required files which I don't know how to do.

This is the project I I am basing all this off of

In VS2008 I did what I thought was right, added the Kennedy dll as a resource and with :: member referencing even auto complete works yet in VS2003 it wont. The example projects open in VS2003 without any problems and compile fine yet in VS2008 they need to be converted so its not like im using a compiler older than the examples.

Offline rcrabb

*
  •  146 146
    • View Profile
Re: My First Plugin - Function, Forms And General Troubbles
« Reply #9 on: January 02, 2010, 07:32:28 PM »
Hopefully one of the experts can explain. My knowledge is very limited. I've been having great luck with the wizard.
Ryan