现在想把状态栏放大,里边的字也随之放大!
我用的是VC6.0,我在用GetWindowRect()得到了他的高度,但我却无法设置状态栏的高度,我在CStatusBar类里看到了int m_nMinHeight;但他是protected,是我无法访问的,还有OnSetMinHeight()是一个消息映射函数,我不知道在哪里凋用它。里边的字体在哪里设置啊?自己编程序?那就请帮我编好!!我的信箱[email protected] 明天急用 谢谢
我用的是VC6.0,我在用GetWindowRect()得到了他的高度,但我却无法设置状态栏的高度,我在CStatusBar类里看到了int m_nMinHeight;但他是protected,是我无法访问的,还有OnSetMinHeight()是一个消息映射函数,我不知道在哪里凋用它。里边的字体在哪里设置啊?自己编程序?那就请帮我编好!!我的信箱[email protected] 明天急用 谢谢
你在编辑状态栏资源的时候,把资源的图标拖大。显示出来的状态栏就是多大。
字体可以用SetFont()设置
个人感觉到基本上满足了你的要求!
代码已经发到你的信箱
[email protected]
南京
宋业文
----------------------------------------//custom the personal statusbar in child frame
static UINT indicators[]=
{
ID_SEPARATOR,
ID_INDICATOR_X,//"x=0000"
ID_INDICATOR_Y//"y=0000"
};/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlersint CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here //create the child frame status bar with default font size :6
if(!this->m_wndStatusBar.Create(this,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,IDW_CHILD_STATUSBAR)
||!this->SetStatusBarFont(&this->m_wndStatusBar)||!this->m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create the status bar!\n");
return -1;
} //initialize the pane to show nothing at the beginning
int iCount=this->m_wndStatusBar.GetCount();
for(int i=0;i<iCount;i++)
this->m_wndStatusBar.SetPaneText(i,NULL);
//no need to call the SetMinHeight() function to set the height of statusbar
//because of status bar will adjust the height to fit the height of its font!
//this->m_wndStatusBar.GetStatusBarCtrl().SetMinHeight(20);
return 0;
}CStatusBar* CChildFrame::GetChildStatusBar()
{
ASSERT(::IsWindow(this->m_wndStatusBar.m_hWnd));
return &this->m_wndStatusBar;
}BOOL CChildFrame::SetStatusBarFont(CStatusBar *pStatusBar,int nFontSizes)
{
ASSERT_VALID( pStatusBar );
//1-prepare to clear the prev font
if(this->m_StatusBarFont.GetSafeHandle()!=NULL)
{
this->m_StatusBarFont.DeleteObject();
}
// 2 - Create font
// Initializes a CFont object with the specified characteristics.
VERIFY(m_StatusBarFont.CreateFont(
nFontSizes*5, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial")); // lpszFacename // 3 - Set status bar font
pStatusBar->SetFont( &m_StatusBarFont );
return TRUE;
}CFont& CChildFrame::GetFontSize()
{
return this->m_StatusBarFont;
}
-----------------------------------
void CMdiStatusBarView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CChildFrame *pFrame=(CChildFrame*)(this->GetParentFrame());
CStatusBar *pStatusBar=pFrame->GetChildStatusBar();
int index_x=pStatusBar->CommandToIndex(ID_INDICATOR_X);
int index_y=pStatusBar->CommandToIndex(ID_INDICATOR_Y);
CString str;
str.Format("x=%4d",point.x);
pStatusBar->SetPaneText(index_x,str);
str.Format("y=%4d",point.y);
pStatusBar->SetPaneText(index_y,str); CView::OnMouseMove(nFlags, point);
}void CMdiStatusBarView::OnSizeSmall()
{
// TODO: Add your command handler code here
CChildFrame *pFrame=(CChildFrame*)(this->GetParentFrame());
CStatusBar *pStatusBar=pFrame->GetChildStatusBar();
pFrame->SetStatusBarFont(pStatusBar,8);
CClientDC dc(pStatusBar);
CFont *pOldFont=dc.SelectObject(&pFrame->GetFontSize());
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
//update the width of status bar
int iCount=pStatusBar->GetCount();
for(int i=0;i<iCount;i++)
{
CString str;
str=pStatusBar->GetPaneText(i);
pStatusBar->SetPaneText(i,str);
int nID=pStatusBar->GetItemID(i);
UINT nStyle=pStatusBar->GetPaneStyle(i);
str.Format("x=0000");//max size
CSize size=dc.GetTextExtent(str);
pStatusBar->SetPaneInfo(i,nID,nStyle,size.cx);
}
dc.SelectObject(pOldFont);
//force the frame to redraw noclient zone!
pFrame->SendMessage(WM_SIZE,0,0);
}