Product Home Class IndexDownloadLicense

Mouse Events

This page describes how an application using the library can get Windows mouse events.  This includes:

Since the Chilkat engine runs the application's main loop, a method is provided to allow an application to receive each Windows message before the Chilkat engine's handler.  The CK_ddEngine::setWndProc member function can be called to establish a Windows procedure for the application.   Below is an example of how to establish a Windows procedure.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <chilkat.h>
class ApplicationClass : public CK_WndProc
{
    public: 
	int wndProc(HWND hWnd, UINT message, 
            WPARAM wParam, LPARAM lParam);
	// Other application member functions go here.
}
int ApplicationClass::wndProc(HWND hWnd, UINT message, 
            WPARAM wParam, LPARAM lParam)
{
   // In this example, the application needs to do special processing for 
    // mouse move events.  All Windows events will be sent to this 
    // procedure, not just mouse related events.
    if (wParam == WM_MOUSEMOVE)
	{
	// Application code to do something special goes here.
	}
    return TRUE;  // Allow the Chilkat engine to process the message.
}
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
			LPSTR lpCmdLine, int nCmdShow)
    {
    ApplicationClass app;

    CK_ddEngine &engine = CK_ddEngine::create("Example1",
	640,480,16,TRUE);
    // Establish a Windows procedure.
   engine.setWndProc(&app);
    // Finish initialization and run the engine's main loop.
    engine.mainLoop();
    return 0;
    }

 

Handling Mouse Events through CK_Screen

The Chilkat engine routes mouse events to the current screen's componentCB function. An application can inherit CK_Screen, and provide an implementation for componentCB.   The advantage of handling mouse events this way is that the component in which they occured is immediately known.  The componentCB function has four parameters:

  1. A pointer to the component where the event occured.
  2. An integer telling what type of event occured, such as CEV_MouseMove.
  3. The component's callback argument #1
  4. The component's callback argument #2

The CK_Screen event types are defined in ck_component.h, and include the following: