home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / SPLITPRG.ZIP / MySplitDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-13  |  5.5 KB  |  228 lines

  1. // MySplitDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MySplit.h"
  6. #include "MySplitDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16.  
  17. class CAboutDlg : public CDialog
  18. {
  19. public:
  20.     CAboutDlg();
  21.  
  22. // Dialog Data
  23.     //{{AFX_DATA(CAboutDlg)
  24.     enum { IDD = IDD_ABOUTBOX };
  25.     //}}AFX_DATA
  26.  
  27.     // ClassWizard generated virtual function overrides
  28.     //{{AFX_VIRTUAL(CAboutDlg)
  29.     protected:
  30.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  31.     //}}AFX_VIRTUAL
  32.  
  33. // Implementation
  34. protected:
  35.     //{{AFX_MSG(CAboutDlg)
  36.     //}}AFX_MSG
  37.     DECLARE_MESSAGE_MAP()
  38. };
  39.  
  40. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  41. {
  42.     //{{AFX_DATA_INIT(CAboutDlg)
  43.     //}}AFX_DATA_INIT
  44. }
  45.  
  46. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  47. {
  48.     CDialog::DoDataExchange(pDX);
  49.     //{{AFX_DATA_MAP(CAboutDlg)
  50.     //}}AFX_DATA_MAP
  51. }
  52.  
  53. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  54.     //{{AFX_MSG_MAP(CAboutDlg)
  55.         // No message handlers
  56.     //}}AFX_MSG_MAP
  57.  
  58. END_MESSAGE_MAP()
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CMySplitDlg dialog
  62.  
  63. CMySplitDlg::CMySplitDlg(CWnd* pParent /*=NULL*/)
  64.     : CDialog(CMySplitDlg::IDD, pParent)
  65. {
  66.     //{{AFX_DATA_INIT(CMySplitDlg)
  67.         // NOTE: the ClassWizard will add member initialization here
  68.     //}}AFX_DATA_INIT
  69.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  70.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  71. }
  72.  
  73. CMySplitDlg::~CMySplitDlg()
  74. {
  75. }
  76.  
  77. void CMySplitDlg::DoDataExchange(CDataExchange* pDX)
  78. {
  79.     CDialog::DoDataExchange(pDX);
  80.     //{{AFX_DATA_MAP(CMySplitDlg)
  81.         // NOTE: the ClassWizard will add DDX and DDV calls here
  82.     //}}AFX_DATA_MAP
  83. }
  84.  
  85. BEGIN_MESSAGE_MAP(CMySplitDlg, CDialog)
  86.     //{{AFX_MSG_MAP(CMySplitDlg)
  87.     ON_WM_SYSCOMMAND()
  88.     ON_WM_PAINT()
  89.     ON_WM_QUERYDRAGICON()
  90.     ON_WM_DESTROY()
  91.     //}}AFX_MSG_MAP
  92.     ON_MESSAGE( WM_SPLITTER_MOVED, OnWmSplitterMoved )
  93. END_MESSAGE_MAP()
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CMySplitDlg message handlers
  97.  
  98. BOOL CMySplitDlg::OnInitDialog()
  99. {
  100.     CDialog::OnInitDialog();
  101.  
  102.     // Add "About..." menu item to system menu.
  103.  
  104.     // IDM_ABOUTBOX must be in the system command range.
  105.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  106.     ASSERT(IDM_ABOUTBOX < 0xF000);
  107.  
  108.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  109.     if (pSysMenu != NULL)
  110.     {
  111.         CString strAboutMenu;
  112.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  113.         if (!strAboutMenu.IsEmpty())
  114.         {
  115.             pSysMenu->AppendMenu(MF_SEPARATOR);
  116.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  117.         }
  118.     }
  119.  
  120.     // Set the icon for this dialog.  The framework does this automatically
  121.     //  when the application's main window is not a dialog
  122.     SetIcon(m_hIcon, TRUE);            // Set big icon
  123.     SetIcon(m_hIcon, FALSE);        // Set small icon
  124.     
  125.     // TODO: Add extra initialization here
  126.     // x-splitter 1
  127.     m_xSplitter1.BindWithControl(this, IDC_XBAR1);
  128.     m_xSplitter1.SetMinWidth(10, 50);
  129.  
  130.     m_xSplitter1.AttachAsRightPane(IDC_LEFTPANE1);
  131.     m_xSplitter1.AttachAsRightPane(IDC_YBAR);
  132.     m_xSplitter1.AttachAsRightPane(IDC_LEFTPANE2);
  133.  
  134.     m_xSplitter1.RecalcLayout();
  135.  
  136.     // x-splitter 2
  137.     m_xSplitter2.BindWithControl(this, IDC_XBAR2);
  138.     m_xSplitter2.SetMinWidth(50, 100);
  139.  
  140.     m_xSplitter2.AttachAsLeftPane(IDC_LEFTPANE1);
  141.     m_xSplitter2.AttachAsLeftPane(IDC_LEFTPANE2);
  142.     m_xSplitter2.AttachAsLeftPane(IDC_YBAR);
  143.     m_xSplitter2.AttachAsRightPane(IDC_RIGHTPANE1);
  144.  
  145.     m_xSplitter2.RecalcLayout();
  146.  
  147.     // y-splitter
  148.     m_ySplitter.BindWithControl(this, IDC_YBAR);
  149.     m_ySplitter.SetMinHeight(30, 30);
  150.  
  151.     m_ySplitter.AttachAsAbovePane(IDC_LEFTPANE1);
  152.     m_ySplitter.AttachAsBelowPane(IDC_LEFTPANE2);
  153.     m_ySplitter.AttachAsBelowPane(IDC_XBAR2);
  154.  
  155.     m_ySplitter.RecalcLayout();
  156.  
  157.     return TRUE;  // return TRUE  unless you set the focus to a control
  158. }
  159.  
  160. void CMySplitDlg::OnSysCommand(UINT nID, LPARAM lParam)
  161. {
  162.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  163.     {
  164.         CAboutDlg dlgAbout;
  165.         dlgAbout.DoModal();
  166.     }
  167.     else
  168.     {
  169.         CDialog::OnSysCommand(nID, lParam);
  170.     }
  171. }
  172.  
  173. // If you add a minimize button to your dialog, you will need the code below
  174. //  to draw the icon.  For MFC applications using the document/view model,
  175. //  this is automatically done for you by the framework.
  176.  
  177. void CMySplitDlg::OnPaint() 
  178. {
  179.     if (IsIconic())
  180.     {
  181.         CPaintDC dc(this); // device context for painting
  182.  
  183.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  184.  
  185.         // Center icon in client rectangle
  186.         int cxIcon = GetSystemMetrics(SM_CXICON);
  187.         int cyIcon = GetSystemMetrics(SM_CYICON);
  188.         CRect rect;
  189.         GetClientRect(&rect);
  190.         int x = (rect.Width() - cxIcon + 1) / 2;
  191.         int y = (rect.Height() - cyIcon + 1) / 2;
  192.  
  193.         // Draw the icon
  194.         dc.DrawIcon(x, y, m_hIcon);
  195.     }
  196.     else
  197.     {
  198.         CDialog::OnPaint();
  199.     }
  200. }
  201.  
  202. // The system calls this to obtain the cursor to display while the user drags
  203. //  the minimized window.
  204. HCURSOR CMySplitDlg::OnQueryDragIcon()
  205. {
  206.     return (HCURSOR) m_hIcon;
  207. }
  208.  
  209. void CMySplitDlg::OnDestroy() 
  210. {
  211.     m_xSplitter1.Unbind();
  212.     m_xSplitter2.Unbind();
  213.     m_ySplitter.Unbind();
  214.  
  215.     CDialog::OnDestroy();
  216.     
  217.     // TODO: Add your message handler code here
  218. }
  219.  
  220. LONG CMySplitDlg::OnWmSplitterMoved( UINT wParam, LONG lParam )
  221. {
  222.     CString str;
  223.     str.Format("splitter(%08X)\r\nmoved %d\r\n", lParam, wParam);
  224.     GetDlgItem(IDC_LEFTPANE1)->SetWindowText(str);
  225.     return 1L;
  226. }
  227.  
  228.