ActiveX VNCX_svr (How to build)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveX VNCX_svr (How to build)

Oscar Usifer
Folks,

Wow! It really came together finally. Here is how to do it with Visual Studio 2005.

* Use MFC Wizard to create an ActiveX MFC control (called VNCX_svr)
* Add WinVNC source to the project so that it compiles OK.
* In Wizard generated Cvncx_svrCtrl sources, make the following changes:


Add to Cvncx_svrCtrl class (in vncx_svrCtrl.h header):

#include "vncServer.h"
#include "vncMenu.h"
#include "vncInstHandler.h"
#include "VSocket.h"
#include "WinVNC.h"

#include "vncService.h"

private:
        VSocketSystem *socksys;
        vncInstHandler *instancehan;
        vncServer *server;
        vncMenu *menu;


Modify "vncx_svrCtrl.cpp" as follows:

Cvncx_svrCtrl::Cvncx_svrCtrl()
{
        InitializeIIDs(&IID_Dvncx, &IID_DvncxEvents);
        // TODO: Initialize your control's instance data here.

        // Save the application instance and main thread id
        hAppInstance = GetModuleHandle(0);
        mainthreadId = GetCurrentThreadId();

        // Initialise the VSocket system
        socksys = new VSocketSystem();
        if (!socksys->Initialised())
        {
                //MessageBox(NULL, "Failed to initialise the socket system", szAppName, MB_OK);
                return;
        }
        vnclog.Print(LL_STATE, VNCLOG("sockets initialised\n"));

        SetProcessShutdownParameters(0x100, 0);
       
        // Check for previous instances of WinVNC!
        instancehan = new vncInstHandler();
        if (!instancehan->Init())
        {
                // We don't allow multiple instances!
                //MessageBox(NULL, "Another instance of WinVNC is already running", szAppName, MB_OK);
                return;
        }

        // CREATE SERVER
        server = new vncServer();

        // Set the name and port number
        server->SetName(szAppName);
        server->SockConnect(true);
        vnclog.Print(LL_STATE, VNCLOG("server created ok\n"));

        // Create tray icon & menu if we're running as an app
        menu = new vncMenu(server);
        if (menu == NULL)
        {
                vnclog.Print(LL_INTERR, VNCLOG("failed to create tray menu\n"));
                PostQuitMessage(0);
        }
}


CvncxCtrl::~CvncxCtrl()
{
        // TODO: Cleanup your control's instance data here.
        vnclog.Print(LL_STATE, VNCLOG("shutting down server\n"));

        if (menu != NULL)
                delete menu;
}


Notes: The control creates properly, and works. No icon is created because resource .ico was not added to my proj work. May need to double check for memory leaks in between objects created and not deleted. VNCHooks.dll is assumed to live in the .ocx directory.

My wife finally stopped screaming at me for not paying attention to her between 2am to 7am, giving me an opportunity to hop back in the saddle and create a working demo. I am writing this email while she's up, so if it's not coherent enough, you know why.

Thanks,
OSC

--
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
VNC-Tight-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vnc-tight-devel
Reply | Threaded
Open this post in threaded view
|

Re: ActiveX VNCX_svr (How to build)

Oscar Usifer
Additional bug notes:

* I noticed deleting the VNCX_svr closed the test container (unexpectedly). If anyone knows why, please share, but in the mean time I will research.
* Because the web is rife with VNCX references (to the viewer), I renamed the project to VNCX_svr to emphasize this is the server project.

HTH,
-OSC

> ----- Original Message -----
> Subject: ActiveX VNCX_svr (How to build)
> Date: Sun, 2 Mar 2008 11:55:49 -0500
>
> Wow! It really came together finally. Here is how to do it with
> Visual Studio 2005.
>
> * Use MFC Wizard to create an ActiveX MFC control (called VNCX_svr)
> * Add WinVNC source to the project so that it compiles OK.
> * In Wizard generated Cvncx_svrCtrl sources, make the following changes:
>
>
> Add to Cvncx_svrCtrl class (in vncx_svrCtrl.h header):
>
> #include "vncServer.h"
> #include "vncMenu.h"
> #include "vncInstHandler.h"
> #include "VSocket.h"
> #include "WinVNC.h"
>
> #include "vncService.h"
>
> private:
> VSocketSystem *socksys;
> vncInstHandler *instancehan;
> vncServer *server;
> vncMenu *menu;
>
>
> Modify "vncx_svrCtrl.cpp" as follows:
>
> Cvncx_svrCtrl::Cvncx_svrCtrl()
> {
> InitializeIIDs(&IID_Dvncx, &IID_DvncxEvents);
> // TODO: Initialize your control's instance data here.
>
> // Save the application instance and main thread id
> hAppInstance = GetModuleHandle(0);
> mainthreadId = GetCurrentThreadId();
>
> // Initialise the VSocket system
> socksys = new VSocketSystem();
> if (!socksys->Initialised())
> {
> //MessageBox(NULL, "Failed to initialise the socket system",
> szAppName, MB_OK);
> return;
> }
> vnclog.Print(LL_STATE, VNCLOG("sockets initialised\n"));
>
> SetProcessShutdownParameters(0x100, 0);
>
> // Check for previous instances of WinVNC!
> instancehan = new vncInstHandler();
> if (!instancehan->Init())
> {
> // We don't allow multiple instances!
> //MessageBox(NULL, "Another instance of WinVNC is already
> running", szAppName, MB_OK);
> return;
> }
>
> // CREATE SERVER
> server = new vncServer();
>
> // Set the name and port number
> server->SetName(szAppName);
> server->SockConnect(true);
> vnclog.Print(LL_STATE, VNCLOG("server created ok\n"));
>
> // Create tray icon & menu if we're running as an app
> menu = new vncMenu(server);
> if (menu == NULL)
> {
> vnclog.Print(LL_INTERR, VNCLOG("failed to create tray menu\n"));
> PostQuitMessage(0);
> }
> }
>
>
> CvncxCtrl::~CvncxCtrl()
> {
> // TODO: Cleanup your control's instance data here.
> vnclog.Print(LL_STATE, VNCLOG("shutting down server\n"));
>
> if (menu != NULL)
> delete menu;
> }
>
>
> Notes: The control creates properly, and works. No icon is created
> because resource .ico was not added to my proj work. May need to
> double check for memory leaks in between objects created and not
> deleted. VNCHooks.dll is assumed to live in the .ocx directory.


--
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
VNC-Tight-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vnc-tight-devel