要在Dialog中加入自己的浮动工具条,该怎么做?
解决方案 »
- 如何用ShellExecute或者其他api打开播放设备的目录 ? 300分相赠
- 用Dialog怎么实现类似Windows的多级弹出菜单功能?
- 请问如何禁止用户修改NTFS分区中的文件夹的加密属性?
- 警告 LINK : warning LNK4089: all references to "SHLWAPI.dll" discarded by /OPT:REF
- 想用八连通域设计一个算法,迷茫中........
- 关于MFC的动态类机制
- 怎么样才能在调用DLL后立即完全释放?100
- 给一些有关window socket断开连接的思路
- 错误:'Stack<T>::Link' : dependent name is not a type。虽然有帖子也是问这个问题,但还是没改好,前辈帮着看一下吧。
- 如何操作ini文件,在vc中。
- 一个关于 CString 转换为 char * ,的问题??
- MFC Extension Dll中一个有挑战性的问题
m_pImageList = new CImageList;
SetupImages(m_pImageList);TBBUTTON tb;m_ToolBar = new CToolBarCtrl;
m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT,
CRect(0,0,0,0), this, 0);m_ToolBar->SetImageList(m_pImageList);
tb.iBitmap = 0;
tb.iString = NULL;
tb.fsState = TBSTATE_ENABLED;
tb.fsStyle = TBSTYLE_BUTTON;
tb.idCommand = ID_HELP_ABOUT;m_ToolBar->AddButtons(1, &tb);
tb.iBitmap = 1;
tb.idCommand = ID_BOLD;
m_ToolBar->AddButtons(1, &tb);
tb.iBitmap = 2;
tb.idCommand = ID_DRAWING;
m_ToolBar->AddButtons(1, &tb);TBBUTTON tb1;
tb1.fsStyle = TBSTYLE_SEP;
m_ToolBar->AddButtons(1, &tb1);tb.iBitmap = 3;
tb.idCommand = ID_STRIKEOUT;
tb.iString = NULL;
m_ToolBar->AddButtons(1, &tb);创建状态条的代码:
m_StatusBar = new CStatusBarCtrl;
m_StatusBar->Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,
CRect(0,0,0,0), this, 0);int strPartDim[4]= {180, 260, 340, -1};
m_StatusBar->SetParts(4, strPartDim);m_StatusBar->SetText(_T("Dialog / StatusBar / Toolbar"),0,0);
m_StatusBar->SetText(_T("Example"), 1, 0);CString string;
string.LoadString(IDS_MYCOMPUTER);
m_StatusBar->SetText(string, 3 ,SBT_NOBORDERS );
m_StatusBar->SetIcon(3,
SetIcon(AfxGetApp()->LoadIcon(IDI_COMP),
FALSE));
BOOL CYourDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Create the toolbar. To understand the meaning of the styles used, you
// can take a look at the MSDN for the Create function of the CToolBar class.
ToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS |CBRS_FLYBY | CBRS_BORDER_BOTTOM);
// I have assumed that you have named your toolbar's resource as IDR_TOOLBAR1.
// If you have given it a different name, change the line below to accomodate
// that by changing the parameter for the LoadToolBar function.
ToolBar.LoadToolBar(IDR_TOOLBAR1);
CRect rcClientStart;
CRect rcClientNow;
GetClientRect(rcClientStart);
// To reposition and resize the control bar
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0, reposQuery, rcClientNow);
CPoint ptOffset(rcClientNow.left - rcClientStart.left,rcClientNow.top-rcClientStart.top);
CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild, FALSE);
pwndChild = pwndChild->GetNextWindow();
}
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, FALSE);
// And position the control bars
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
return TRUE; // return TRUE unless you set the focus to a control
}
ToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS |CBRS_FLYBY | CBRS_BORDER_BOTTOM);
ToolBar.LoadToolBar(IDR_TOOLBAR1);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);