ImageControls 3.1 Application Note

ImageControls Toolkit 3.1 is the latest release of the Kofax ImageControls Toolkit product.


To access the following Web pages for this release, please click on the desired page's link.

Application Notes - Error Codes - Frequently Asked QuestionsRevision Levels  - Supported Configurations


Accessing Standard VB Properties in Visual C++

How do you access the Height and Width properties of the KView control for the purpose of resizing the control at runtime?

When you add a control to a VC++ project, a couple of classes are created and displayed in the Class View. If you use the ClassWizard, these will be _DKView and _DKViewEvents. If you add the control from the Component Gallery, the CKView and COleFont classes will be created. Using the ClassWizard is the preferred method since it will automatically create the event handler class. Now, let's say you want to set the size of the KView window by setting the Height and Width properties. However, when you open the _DKView or CKView class there are no SetHeight or SetWidth functions. Since the KView is derived from the CWnd base class, it inherits all the functionality of the CWnd. The CWnd class has a function called MoveWindow() that can easily be used to both position and size the KView. VCDemo implements this in the CVCKView::Resize() function as follows:

/////////////////////////////////////////////////////////////////////////////

// Function: Resize

// Purpose: Resize the KView control to the current window dimensions

// Note: Errors are displayed before returning from this function

// Returns: NONE

/////////////////////////////////////////////////////////////////////////////

void CVCKView::Resize()

{

CRect rect, viewrect;

int nNewWidth;

m_pParentWnd->GetClientRect(&rect);

if (m_bTwoWindows)

{

if (!::IsWindow(m_kviewOcx1.m_hWnd) || !::IsWindow(m_kviewOcx2.m_hWnd))

{

return;

}

nNewWidth = rect.right / 2;

viewrect.top = viewrect.left = 0;

viewrect.right = nNewWidth;

viewrect.bottom = rect.bottom;

m_kviewOcx1.MoveWindow(&viewrect);

 

viewrect.left = nNewWidth;

viewrect.right = rect.right;

m_kviewOcx2.MoveWindow(&viewrect);

}

else

{

if (!::IsWindow(m_kviewOcx1.m_hWnd))

{

return;

}

m_kviewOcx1.MoveWindow(&rect);

}

}

The MoveWindow() function can be called in one of two ways:

void MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE );

void MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );

Parameters

  • x   Specifies the new position of the left side of the CWnd.
  • y   Specifies the new position of the top of the CWnd.
  • nWidth   Specifies the new width of the CWnd.
  • nHeight   Specifies the new height of the CWnd.
  • bRepaint   Specifies whether CWnd is to be repainted. If TRUE, CWnd receives a WM_PAINT message in its OnPaint message handler as usual. If this parameter is FALSE, no repainting of any kind occurs. This applies to the client area, to the nonclient area (including the title and scroll bars), and to any part of the parent window uncovered as a result of Cwnd's move. When this parameter is FALSE, the application must explicitly invalidate or redraw any parts of CWnd and parent window that must be redrawn.
  • lpRect   The CRect object or RECT structure that specifies the new size and position.