64,651
社区成员
发帖
与我相关
我的任务
分享
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
HICON m_hIcon;
//在MainFrm的OnCreate()里
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//1.初始化变量
//m_psockServer=new CTCPSocket(TCP_SOCKET_SERVER);
//m_psockClient=new CTCPSocket(TCP_SOCKET_CLIENT);
//if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
// | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
// !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
//{
// TRACE0("Failed to create toolbar\n");
// return -1; // fail to create
//}
//去掉标题栏及其他样式
// SetWindowLong(this->m_hWnd,GWL_STYLE,0);
//去掉边框及其他样式
SetWindowLong(this->m_hWnd,GWL_EXSTYLE,0);
//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
//}
/////////////创建控制条///////////////
if (!m_wndMyBar1.Create(_T("我的控制条1"), this, CSize(150,260),TRUE,123)) //原来176
{
TRACE0("Failed to create mybar\n");
return -1;
}
if (!m_wndMyBar2.Create(_T("我的控制条2"), this,CSize(100,105),TRUE,124))
{
TRACE0("Failed to create mybar\n");
return -1;
}
if (!m_wndMyBar3.Create(_T("我的控制条3"), this,CSize(496,200),TRUE,125)) //原来620 ,300
{
TRACE0("Failed to create mybar\n");
return -1;
}
if (!m_wndMyBar4.Create(_T("我的控制条4"), this,CSize(750,105),TRUE,126)) //原来960,105
{
TRACE0("Failed to create mybar\n");
return -1;
}
m_TabCtrl.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),&m_wndMyBar3,128);
m_TabCtrl2.Create(TCS_DOWN|WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),&m_wndMyBar2,126);
/////////////创建仿QQ抽屉////////////////
if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, CRect(0,0,0,0),
&m_wndMyBar1, 123, OBS_XT_DEFAULT))
{
TRACE0("Failed to create outlook bar.");
return FALSE;
}
// Add items to the outlook bar.
m_wndOutlookBar.SetBackColor(RGB(0xe6,0xe6,0xfa));//(RGB(0x3a,0x6e,0xa5));
m_wndOutlookBar.SetTextColor(RGB(0x00,0x00,0x00));
/////////////这一段代码创建树型控件////////////
if (!m_RichEdit.Create(//WS_CHILD|WS_VISIBLE|
WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_MULTILINE|ES_READONLY|ES_WANTRETURN|TVS_LINESATROOT,
CRect(0, 0, 0, 0), &m_TabCtrl, IDC_MYTREECTRL))
{
TRACE0("Failed to create instant bar child\n");
return -1;
}
m_RichEdit.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_RichEdit.SetType(CHATLOG);
if (!m_RichEdit1.Create(//WS_CHILD|WS_VISIBLE|
WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_MULTILINE|ES_READONLY|ES_WANTRETURN|TVS_LINESATROOT,
CRect(0, 0, 0, 0), &m_TabCtrl, 61205))
{
TRACE0("Failed to create instant bar child\n");
return -1;
}
m_RichEdit1.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_RichEdit1.SetType(CHATLOG);
if (!m_RichEdit2.Create(//WS_CHILD|WS_VISIBLE|
WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_MULTILINE|ES_READONLY|ES_WANTRETURN|TVS_LINESATROOT,
CRect(0, 0, 0, 0), &m_TabCtrl, 61206))
{
TRACE0("Failed to create instant bar child\n");
return -1;
}
m_RichEdit2.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_RichEdit2.SetType(CHATLOG);
if(!m_SendEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|TVS_LINESATROOT,CRect(0,0,0,0),&m_wndMyBar4,1102))
return -1;
m_SendEdit.ModifyStyleEx(0,WS_EX_CLIENTEDGE);
m_TabCtrl.AddPage(&m_RichEdit,L"JBT群聊... ",IDI_ICON1);
m_TabCtrl.AddPage(&m_RichEdit1,L"JBT私聊... ",IDI_ICON2);
m_TabCtrl.AddPage(&m_RichEdit2,L"小组公告... ",IDI_ICON3);
// m_TabCtrl.AddPage(&m_RichEdit,L"JBT私聊... ",IDI_ICON2);
m_TabCtrl.UpdateWindow();
// m_RichEdit.SubclassWindow(m_sendEditCtrl.GetSafeHwnd());
//m_TabCtrl2.AddPage(&m_func,IDD_BASEF," 基本设置 ",IDI_ICON6);
m_TabCtrl2.AddPage(RUNTIME_CLASS(base_func),IDD_BASEF,L" 基本功能 ",IDI_ICON4);
m_TabCtrl2.AddPage(RUNTIME_CLASS(FileAndVOL),IDD_FILE,L"传输功能 ",IDI_ICON5);
m_TabCtrl2.AddPage(RUNTIME_CLASS(PortSet),IDD_COMMSET,L"通讯设置 ",IDI_ICON6);
m_TabCtrl2.UpdateWindow();
///////////////停靠控制///////////////////
m_wndMyBar1.SetBarStyle(m_wndMyBar1.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndMyBar2.SetBarStyle(m_wndMyBar2.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndMyBar3.SetBarStyle(m_wndMyBar3.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndMyBar4.SetBarStyle(m_wndMyBar4.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// m_wndMyBar5.SetBarStyle(m_wndMyBar5.GetBarStyle() |
// CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndMyBar1.EnableDocking(CBRS_ALIGN_ANY);
m_wndMyBar2.EnableDocking(CBRS_ALIGN_ANY);
m_wndMyBar3.EnableDocking(CBRS_ALIGN_ANY);
m_wndMyBar4.EnableDocking(CBRS_ALIGN_ANY);
// m_wndMyBar5.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY );
// FloatControlBar (&m_wndMyBar4, CPoint (400, 200));
// DockControlBar(&m_wndToolBar);
DockControlBar(&m_wndMyBar3, AFX_IDW_DOCKBAR_LEFT);
DockControlBar(&m_wndMyBar1, AFX_IDW_DOCKBAR_LEFT);
DockControlBar(&m_wndMyBar2, AFX_IDW_DOCKBAR_BOTTOM);
// DockControlBar(&m_wndMyBar5, AFX_IDW_DOCKBAR_BOTTOM);
DockControlBar(&m_wndMyBar4, AFX_IDW_DOCKBAR_LEFT);
// DockControlBarLeftOf(&m_wndMyBar3, &m_wndMyBar1);
DockControlBarLeftOf(&m_wndMyBar4, &m_wndMyBar2);
////////使浮动与停靠显示相同的头部////
#ifdef _SCB_REPLACE_MINIFRAME
m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
#endif //_SCB_REPLACE_MINIFRAME
InitializeOutlookBar();
//删除原始菜单栏
CMenu *pMenu = GetMenu();
if (NULL!=pMenu)
{
DelAllMenu(pMenu->GetSafeHmenu());
}
CenterWindow( );
//m_RichEdit.AddMessageUser(_T("海洋之心"),RGB(0,110,254));
//m_RichEdit.AddMessgaeText(_T("欢迎使用静态表情控件CRichEditCtrlEx扩展类,更多信息在http://blog.csdn.net/akof1314无幻博客"),_T("宋体"),9,false,false,false,RGB(0,0,0),&m_BmpPicker);
return 0;
}
void CMainFrame::DockControlBarLeftOf(CCoolBar* Bar,CCoolBar* LeftOf)
{ //设置工具条并列停靠在同一条边上
CRect rect; //矩形区域定义
DWORD dw;
UINT n=0;
RecalcLayout();//重新显示
LeftOf->GetWindowRect(&rect);
// rect.OffsetRect(1,0);//设置偏移值以停靠在同一边上
rect.OffsetRect(0,1);
dw=LeftOf->GetBarStyle();
n=(dw&CBRS_ALIGN_TOP)?AFX_IDW_DOCKBAR_TOP:n;
n=(dw&CBRS_ALIGN_BOTTOM&&n==0)?AFX_IDW_DOCKBAR_BOTTOM:n;
n=(dw&CBRS_ALIGN_LEFT&&n==0)?AFX_IDW_DOCKBAR_LEFT:n;
n=(dw&CBRS_ALIGN_RIGHT&&n==0)?AFX_IDW_DOCKBAR_RIGHT:n;
DockControlBar(Bar,n,&rect);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
/*cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;*/
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
cs.style&=~WS_THICKFRAME;//禁止用户改变窗口大小
cs.style&=~WS_MAXIMIZEBOX;//禁止用户改变放大窗口
cs.cx=650; //原来800
cs.cy=450; //原来500
return TRUE;
}