VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 133|回复: 0

SDI重绘时如何布局

[复制链接]
89_avatar_middle
最佳答案
2 
在线会员 发表于 2022-4-2 16:52:26 | 显示全部楼层 |阅读模式
10驿站币
如题,各位大佬,在SDI重绘时,想做成的预期效果是如下截图: SDI重绘时如何布局
目前当前的效果如截图所示:
SDI重绘时如何布局
我的具体代码如下:
  1. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  2. {
  3.         if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  4.                 return -1;

  5. #if 0
  6.         // enable Windows XP look:
  7.         CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows));
  8. #else
  9.         OnApplicationLook(theApp.m_nAppLook);
  10. #endif

  11.         CMFCToolBar::EnableQuickCustomization ();

  12.         //设置标题左侧图标
  13.         m_hIcon = AfxGetApp()->LoadIcon(/*IDR_MAINFRAME*/IDR_MAINFRAME);
  14.         SetIcon(m_hIcon, TRUE);
  15.         SetIcon(m_hIcon, FALSE);

  16.         //---------------------------------
  17.         // Set toolbar and menu image size:
  18.         //---------------------------------
  19.         CMFCToolBar::SetSizes (CSize (28, 28), CSize (22, 22));
  20.         CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16));

  21.         // TODO: Define your own basic commands. Be sure, that each pulldown
  22.         // menu have at least one basic command.

  23.         CList<UINT, UINT>        lstBasicCommands;

  24.         lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
  25.         lstBasicCommands.AddTail (ID_APP_EXIT);
  26.         lstBasicCommands.AddTail (ID_APP_ABOUT);
  27.         lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
  28.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_OFF_2003);
  29.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS_2005);
  30.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_OFF_2007_BLUE);
  31.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_OFF_2007_SILVER);
  32.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_OFF_2007_BLACK);
  33.         lstBasicCommands.AddTail (ID_VIEW_APPLOOK_OFF_2007_AQUA);
  34.         lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
  35.         lstBasicCommands.AddTail (ID_COMMAND_HISTORY);
  36.         lstBasicCommands.AddTail (ID_VIEW_LARGEICON);
  37.         lstBasicCommands.AddTail (ID_VIEW_SMALLICON);
  38.         lstBasicCommands.AddTail (ID_VIEW_LIST);
  39.         lstBasicCommands.AddTail (ID_VIEW_DETAILS);
  40.         lstBasicCommands.AddTail (ID_EDIT_CUT);
  41.         lstBasicCommands.AddTail (ID_EDIT_COPY);
  42.         lstBasicCommands.AddTail (ID_EDIT_PASTE);

  43.         CMFCToolBar::SetBasicCommands (lstBasicCommands);

  44.         if (!m_wndMenuBar.Create(this/*, TBSTYLE_TRANSPARENT*/))
  45.         {
  46.                 TRACE0("Failed to create menubar\n");
  47.                 return -1;      // fail to create
  48.         }

  49.         m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);

  50.         // Remove menubar gripper and borders:
  51.         m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() &
  52.                 ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));

  53.         // Detect color depth. 256 color toolbars can be used in the
  54.         // high or true color modes only (bits per pixel is > 8):
  55.         CClientDC dc (this);
  56.         BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;

  57.         UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
  58.         UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0;
  59.         UINT uiMenuID = bIsHighColor ? IDB_MENU256 : IDB_MENU16;

  60.         if (!m_wndToolBar.CreateEx(this/*, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC*/) ||
  61.                 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE, 0, 0, uiToolbarHotID))
  62.         {
  63.                 TRACE0("Failed to create toolbar\n");
  64.                 return -1;      // fail to create
  65.         }

  66.         // Remove toolbar gripper and borders:
  67.         m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() &
  68.                 ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));

  69.         //----------------------------------------
  70.         // Create a combo box for the address bar:
  71.         //----------------------------------------
  72.         if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1))
  73.         {
  74.                 TRACE0("Failed to create combobox\n");
  75.                 return -1;      // fail to create
  76.         }

  77.         m_wndAddress.EnableActiveAccessibility();

  78.         // Each rebar pane will ocupy its own row:
  79.         DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK;

  80.         if (!m_wndReBar.Create(this) ||
  81.                 !m_wndReBar.AddBar (&m_wndMenuBar) ||
  82.                 !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle) ||
  83.                 !m_wndReBar.AddBar(&m_wndAddress, _T("地址")/*_T("Address")*/, NULL, dwStyle))               
  84.         {
  85.                 TRACE0("Failed to create rebar\n");
  86.                 return -1;      // fail to create
  87.         }

  88.         m_wndMenuBar.AdjustLayout ();
  89.         m_wndToolBar.AdjustLayout ();

  90.         // TODO: Remove this if you don't want chevrons:
  91.         m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T(""));
  92.         m_wndToolBar.EnableCustomizeButton (TRUE, -1, _T(""));


  93.         if (!m_wndFoldersBar.Create (_T("文件"),
  94.                 this, CRect (0, 0, 400, 200), TRUE, ID_VIEW_FOLDERS, WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION))
  95.         {
  96.                 TRACE0("Failed to create folders bar\n");
  97.                 return -1;      // fail to create
  98.         }

  99.         EnableDocking (CBRS_ALIGN_ANY);

  100.         m_wndReBar.EnableDocking (CBRS_TOP);
  101.         DockPane (&m_wndReBar);

  102.         m_wndFoldersBar.EnableDocking (CBRS_LEFT | CBRS_RIGHT);
  103.         DockPane (&m_wndFoldersBar);

  104.         BOOL bValidString;
  105.         CString strMainToolbarTitle;
  106.         bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR);
  107.         m_wndToolBar.SetWindowText (strMainToolbarTitle);

  108.         // TODO: Remove this if you don't want tool tips
  109.         m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() |
  110.                 CBRS_TOOLTIPS | CBRS_FLYBY);
  111.         m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() |
  112.                 CBRS_TOOLTIPS | CBRS_FLYBY);

  113.         return 0;
  114. }
复制代码
请问各位大佬,如何在重绘时如何工具栏如何实现图标向上,文字在下呢?还有就是地址栏如何再加其他按钮或搜索框呢??麻烦各位大佬帮忙看看,小弟在此多谢了!






上一篇:远程线程注入,加键盘钩子没反应,求大佬指点
下一篇:TCPIP通讯 不知道接收数据大小 如何直到接收到回车换行符
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号-4 )|网站地图wx_jqr

GMT+8, 2022-10-5 04:38

Powered by CcTry.CoM

© 2009-2021 cctry.com

快速回复 返回顶部 返回列表