Using LBitmapWindow as a Control

To use the LBitmapWindow (or any derived) class as a windowed control in your application, you must create an LBitmapWindow object as a child window of some parent window, such as a dialog box, using LBitmapWindow::CreateWnd. After that, the parent window will receive control notification messages that you can process if you like.

This example was done using MFC, so your code may look different if you use some other foundation class library.

 

// First, you should create a button control in your dialog box (IDC_BUTTON)
 

// Next, in your View class, declare an LBitmapWindow (or derived) class object
LBitmapWindow m_Image;

 

// Finally, in your application's initialization code, you can add the following to use
// the LBitmapWindow (or derived) object as a windowed control:

 

// NOTE: Do not forget to load the libraries in application's initialization code:
// LBase::LoadLibraries(LT_ALL_LEADLIB);


CRect rcRect;
COLORREF rgb;
CWnd *pWnd;

// Get the window for the created button
pWnd = GetDlgItem(IDC_BUTTON);

// Get the rectangle of the button
pWnd->GetClientRect(rcRect);

// Create the LBitmapWindow control, make it visible, and make it center the image
m_Image.CreateWnd(pWnd->m_hWnd, 901, WS_VISIBLE|L_BS_CENTER,
rcRect.TopLeft().x, rcRect.TopLeft().y, rcRect.BottomRight().x,
rcRect.BottomRight().y);

// Load the file
m_Image.Load(TEXT("c:\\ltwin14\\images\\sample1.cmp"));

// Get the background of the button
rgb = GetSysColor(COLOR_BTNFACE);

// Set the window background color
m_Image.SetPatternBackColor(rgb);

// Fit the image in the window
m_Image.SetZoomMode(ZOOM_FIT, TRUE);