how to load an image in mainframe window's client area
i found the solution in code procect but it's working under the VS2005 version
i'm using VS2008 (2005 style, MDI project)
Do you have any solution??
Under Callback Function is not called in my project
**********************************************************
#include "stdafx.h"
#include "afxwinappex.h"
#include "skin4.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "skin4Doc.h"
#include "skin4View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(Cskin4App, CWinAppEx)
ON_COMMAND(ID_APP_ABOUT, &Cskin4App::OnAppAbout)
ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup)
END_MESSAGE_MAP()
HBITMAP hBkBmp; WNDPROC pfnOldWndProc;
LRESULT CALLBACK pfnNewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
HDC hdc = (HDC)wParam;
HDC hcompdc;
RECT rect;
switch (uMsg) {
case WM_SIZE :
SendMessage(hwnd, WM_ERASEBKGND, (WPARAM)GetDC(hwnd), 0);
return 1;
case WM_ERASEBKGND :
hcompdc = CreateCompatibleDC(hdc);
SelectObject(hcompdc, hBkBmp);
GetClientRect(hwnd, &rect);
if (FALSE == StretchBlt(hdc, rect.left, rect.top, rect.right, rect.bottom,
hcompdc, 0, 0, 600, 377, SRCCOPY))
MessageBox(hwnd, "error", "while StretchBlt", MB_OK);
DeleteDC(hcompdc);
return 1;
default :
return CallWindowProc(pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
}
BOOL Cskin4App::InitInstance()
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4);
InitContextMenuManager();
InitKeyboardManager();
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_skin4TYPE,
RUNTIME_CLASS(Cskin4Doc),
RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(Cskin4View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
hBkBmp = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
if (hBkBmp == NULL)
MessageBox(NULL, "Error", "Bitmap could not be loaded !!!", MB_OK);
HWND hMain = pMainFrame->GetWindow(GW_CHILD)->GetSafeHwnd();
pfnOldWndProc = (WNDPROC)GetWindowLong(hMain, GWL_WNDPROC);
SetWindowLong(hMain, GWL_WNDPROC, (LONG)pfnNewWndProc);
Drawing Image on MDI Main Frame background[
^]