Used Tablet PC
Results 1 to 2 of 2

Thread: InkPicture Control in C++...

  1. #1
    vintab Guest

    Default InkPicture Control in C++...

    hi...
    I was trying out InkPicture Control, but couldn't implement it succesfully.
    Can any out there solve out my doubts... (C++...please...)

    Q1.) Can we have a window control of InkPicture through a CComPtr ?

    Q2.) I have got a Rich edit text on my dialog. Can I attach a InkPicture control to this edit box. If YES, How?

    Q3.) For CComPtr InkPicture, how can I access the InkDisplay's & all ?

    Pls. reply...
    thanks...
    vinTab...

  2. #2
    SWick Guest

    Default

    Hello vinTab,

    here are the answers to your questions:

    A1) Yes you can instantiate an InkPicture through a CComPtr and then attach it to a suitable container (e.g. ATL's CAxWindow). See sample code below.

    A2) In this case you want an InkOverlay instead of an InkPicture. InkOverlay and InkPicture are pretty much identical except that InkPicture has its own window while InkOverlay is attached to other windows/controls. See sample code below to learn how to attach InkOverlay to RichEdit.

    A3) If you instantiate InkPicture/Overlay as CComPtr, you can access the automation API just as it is documented in the SDK doc. See code sample below to learn how to access the APIs.

    #include "stdafx.h"
    #include <atlbase.h>
    #include <atlwin.h>
    #include "msinkaut_i.c"
    #include "msinkaut.h"

    HINSTANCE hInst;
    HWND hWndMain;
    CComPtr <IInkPicture> g_spInkPicture;
    CComPtr <IInkOverlay> g_spInkOverlay;
    CAxWindow* pHostWindow;

    ATOM MyRegisterClass(HINSTANCE hInstance);
    BOOL InitInstance(HINSTANCE, int);
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

    int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    {
    MSG msg;
    IUnknown* punk;
    MyRegisterClass(hInstance);
    if (!InitInstance (hInstance, nCmdShow))
    return FALSE;
    CoInitialize(NULL);
    LoadLibrary(_T("riched20.dll"));
    HWND hWndRE = CreateWindow(_T("RICHEDIT20W"), NULL, WS_CHILD|WS_VISIBLE|WS_BORDER, 100, 100, 150, 50, hWndMain, NULL, NULL, NULL);

    g_spInkOverlay.CoCreateInstance(CLSID_InkOverlay);
    g_spInkOverlay->put_hWnd((long)hWndRE);
    g_spInkOverlay->put_Enabled(VARIANT_TRUE);

    pHostWindow = new CAxWindow;
    HWND hWndHost = CreateWindow(_T("STATIC"), NULL, WS_CHILD|WS_VISIBLE|WS_BORDER, 300, 100, 150, 50, hWndMain, NULL, hInstance, NULL);
    pHostWindow->Attach(hWndHost);
    HRESULT hr = g_spInkPicture.CoCreateInstance(CLSID_InkPicture);
    hr = g_spInkPicture.QueryInterface(&punk);
    hr = pHostWindow->AttachControl(punk, NULL);

    while (GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    CoUninitialize();
    return (int) msg.wParam;
    }
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = (WNDPROC)WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = _T("IPIO_CPP");
    wcex.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);

    return RegisterClassEx(&wcex);
    }

    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
    hInst = hInstance;
    hWndMain = CreateWindow(_T("IPIO_CPP"), _T("InkPicture/Overlay Sample"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    if (!hWndMain)
    return FALSE;
    ShowWindow(hWndMain, nCmdShow);
    UpdateWindow(hWndMain);
    return TRUE;
    }

    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_DESTROY:
    g_spInkOverlay.Release();
    g_spInkPicture.Release();
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
    }

    Thanks

Similar Threads

  1. Drag/drop image onto InkPicture
    By hawk-i in forum General Tablet PC Discussion
    Replies: 1
    Last Post: 01-20-2005, 03:40 AM
  2. InkPicture Saving
    By sinistrx in forum General Tablet PC Discussion
    Replies: 24
    Last Post: 11-22-2004, 04:20 AM
  3. How to get the image´s name of an InkPicture control
    By fumaillo in forum General Tablet PC Discussion
    Replies: 0
    Last Post: 11-24-2003, 10:08 PM
  4. InkPicture Control
    By qqwert in forum General Tablet PC Discussion
    Replies: 0
    Last Post: 09-29-2003, 09:41 AM
  5. My pen is out of control! I know this is not th
    By beetechie in forum General Tablet PC Discussion
    Replies: 2
    Last Post: 03-03-2003, 07:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •