// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "rebartest.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
LRESULT CALLBACK XWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
if(msg==WM_PAINT)
{
RECT r;//={0,0,500,25};
::GetClientRect(hwnd,&r);
HTHEME ht=OpenThemeData(hwnd,L"REBAR");
TRACE("XP2:%p",ht);
DrawThemeBackground(ht,GetDC(hwnd),6,0,&r,0);
CloseThemeData(ht);
// GetDC()->Rectangle(0,0,25,25);
}
return DefWindowProc(hwnd,msg,wParam,lParam);
return 0;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
}
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar) ||
!m_wndReBar.AddBar(&m_wndDlgBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
long gwl=GetWindowLong(m_wndReBar,GWL_EXSTYLE);
gwl|=WS_EX_COMPOSITED;
SetWindowLong(m_wndReBar,GWL_EXSTYLE,gwl);
gwl=GetWindowLong(m_wndToolBar,GWL_EXSTYLE);
gwl|=WS_EX_COMPOSITED;
SetWindowLong(m_wndToolBar,GWL_EXSTYLE,gwl);
gwl=GetWindowLong(m_wndDlgBar,GWL_EXSTYLE);
gwl|=WS_EX_COMPOSITED;
SetWindowLong(m_wndDlgBar,GWL_EXSTYLE,gwl);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY);
SetWindowLong(m_wndDlgBar,GWL_WNDPROC,(LPARAM)XWndProc);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CFrameWnd::OnPaint() for painting messages
// RECT r={0,0,30,30};
HTHEME ht=OpenThemeData(m_wndReBar,L"REBAR");
DrawThemeBackground(ht,*m_wndReBar.GetDC(),6,0,0,0);
CloseThemeData(ht);
}
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
/* if(message==WM_ERASEBKGND)
{
}*/
return CFrameWnd::WindowProc(message, wParam, lParam);
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
/* if(pMsg->message==WM_ERASEBKGND)
{
if(pMsg->hwnd==m_wndToolBar)
{
int x=0;
x++;
}
if(pMsg->hwnd==m_wndReBar)
{
int y=0;
y++;
}
}
if(pMsg->message==WM_ERASEBKGND)
{
TRACE("EB");
}
if(pMsg->message==WM_PAINT)
{
RECT r={0,0,20,20};
HTHEME ht=OpenThemeData(m_wndDlgBar,L"TOOLBAR");
TRACE("XP:%p",ht);
DrawThemeBackground(ht,*m_wndDlgBar.GetDC(),1TP_BUTTON,5TS_CHECKED,&r,0);
CloseThemeData(ht);
CPaintDC xdc(&m_wndDlgBar);
xdc.Rectangle(0,0,25,25);
// m_wndDlgBar.GetDC()->Rectangle(0,0,25,25);
GetDC()->Rectangle(0,0,25,25);
return 0;
}*/
return CFrameWnd::PreTranslateMessage(pMsg);
}