Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Function to load a bitmap on a dialog

, 6 Apr 2006
Here is a function to load a bitmap on any dialog.
bitmapdialogexe.zip
SBitDialog
SBitDialog.exe
bitmapdialog_src.zip
res
BACK.BMP
grass.bmp
Image1.bmp
Image2.bmp
login1.bmp
SBitDialog.ico
TRY1.BMP
TRY2.BMP
SBitDialog.clw
SBitDialog.dsp
SBitDialog.dsw
// SDlg.cpp: implementation of the SDlg class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SBitDialog.h"
#include "SDlg.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SDlg::SDlg()
{

}

SDlg::~SDlg()
{

}
BEGIN_MESSAGE_MAP(SDlg, CButton)
	
	ON_WM_MOUSEMOVE()
	
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
    
END_MESSAGE_MAP()
void SDlg::SetToolTipText(CString s)
{
	
	if(m_tooltip.m_hWnd==NULL)
	{
		if(m_tooltip.Create(this))	//first assignment
			if(m_tooltip.AddTool(this, (LPCTSTR)s))
				m_tooltip.Activate(1);
	}
	else {
		m_tooltip.UpdateTipText((LPCTSTR)s,this);
	}

}

void SDlg::RelayEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
	
// This function will create a MSG structure, fill it in a pass it to
// the ToolTip control, m_ttip.  Note that we ensure the point is in window
// coordinates (relative to the control's window).
	if(NULL != m_tooltip.m_hWnd){
		MSG msg;
 		msg.hwnd = m_hWnd;
		msg.message = message;
		msg.wParam = wParam;
		msg.lParam = lParam;
		msg.time = 0;
		msg.pt.x = LOWORD(lParam);
		msg.pt.y = HIWORD(lParam);
		m_tooltip.RelayEvent(&msg);
	}

}

void SDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	RelayEvent(WM_MOUSEMOVE,(WPARAM)nFlags,MAKELPARAM(LOWORD(point.x),LOWORD(point.y)));
	CButton::OnMouseMove(nFlags, point);
}

bool SDlg::MakeButton(CString st,UINT Resource, UINT ResourceSel, UINT ResourceFocus, UINT ResourceDisabled)
{
	LoadBitmaps(Resource,ResourceSel,ResourceFocus,ResourceDisabled);
    SetToolTipText(st);
	SizeToContent();
	return true;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Saday Sarkar
Web Developer
India India
This is Saday Chand Sarkar , New in MFC world.
Working in Trek Technology Pte.Ltd.

| Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 7 Apr 2006
Article Copyright 2006 by Saday Sarkar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid