home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Basic / GridOne / setup.EXE / VIRTUALINTERFACEDLG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-09  |  4.0 KB  |  147 lines

  1. // VirtualInterfaceDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "VirtualInterface.h"
  6. #include "VirtualInterfaceDlg.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. // CVirtualInterfaceDlg dialog
  16.  
  17. CVirtualInterfaceDlg::CVirtualInterfaceDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CVirtualInterfaceDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CVirtualInterfaceDlg)
  21.         // NOTE: the ClassWizard will add member initialization here
  22.     //}}AFX_DATA_INIT
  23.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  24.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  25. }
  26.  
  27. void CVirtualInterfaceDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CVirtualInterfaceDlg)
  31.         // NOTE: the ClassWizard will add DDX and DDV calls here
  32.     //}}AFX_DATA_MAP
  33.    DDX_BeeGrid(pDX, IDC_GRID1, m_grid);
  34. }
  35.  
  36. BEGIN_MESSAGE_MAP(CVirtualInterfaceDlg, CDialog)
  37.     //{{AFX_MSG_MAP(CVirtualInterfaceDlg)
  38.     ON_WM_PAINT()
  39.     ON_WM_QUERYDRAGICON()
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CVirtualInterfaceDlg message handlers
  45.  
  46. BOOL CVirtualInterfaceDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     // Set the icon for this dialog.  The framework does this automatically
  51.     //  when the application's main window is not a dialog
  52.     SetIcon(m_hIcon, TRUE);            // Set big icon
  53.     SetIcon(m_hIcon, FALSE);        // Set small icon
  54.     
  55.    //
  56.     // Initialize BeeGrid
  57.    //
  58.  
  59.    try
  60.    {
  61.       m_grid.intf->AutoResize        = sgNoAutoResize;
  62.       m_grid.intf->AllowAddNew       = VARIANT_FALSE;
  63.       m_grid.intf->RowNumbering      = VARIANT_TRUE;
  64.       m_grid.intf->ScrollBarTrack    = VARIANT_TRUE;
  65.       m_grid.intf->GroupByBoxVisible = VARIANT_TRUE;
  66.  
  67.       m_grid.intf->DataMode = sgVirtualInterface;
  68.       m_grid.intf->SimpleDataSource = m_virtualData.GetIsgGridDataSource();
  69.  
  70.       // Add few columns
  71.       IsgColumnsPtr spColumns = m_grid.intf->Columns;
  72.       spColumns->RemoveAll(false);
  73.  
  74.       IsgColumnPtr spCol = spColumns->Add(L"Col1");
  75.       spCol->Caption  = L"Column 1";
  76.       spCol->DataType = sgtLong;
  77.       spCol->Width    = 50;
  78.  
  79.       spCol = spColumns->Add(L"Col2");
  80.       spCol->Caption  = L"Column 2";
  81.       spCol->DataType = sgtLong;
  82.       spCol->Width    = 50;
  83.       
  84.       spCol = spColumns->Add(L"Col3");
  85.       spCol->Caption  = L"Column 3";
  86.       spCol->DataType = sgtLong;
  87.       spCol->Width    = 50;
  88.  
  89.       spCol = spColumns->Add(L"Col4");
  90.       spCol->Caption  = L"Column 4";
  91.       spCol->DataType = sgtLong;
  92.       spCol->Width    = 50;
  93.  
  94.       // Resize heading column
  95.       spCol = spColumns->At(0L);
  96.       spCol->Width = 52;
  97.    }
  98.    catch (_com_error& e)
  99.    {
  100.       AfxMessageBox(e.Description());
  101.    }
  102.    
  103.     return TRUE;  // return TRUE  unless you set the focus to a control
  104. }
  105.  
  106. // If you add a minimize button to your dialog, you will need the code below
  107. //  to draw the icon.  For MFC applications using the document/view model,
  108. //  this is automatically done for you by the framework.
  109.  
  110. void CVirtualInterfaceDlg::OnPaint() 
  111. {
  112.     if (IsIconic())
  113.     {
  114.         CPaintDC dc(this); // device context for painting
  115.  
  116.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  117.  
  118.         // Center icon in client rectangle
  119.         int cxIcon = GetSystemMetrics(SM_CXICON);
  120.         int cyIcon = GetSystemMetrics(SM_CYICON);
  121.         CRect rect;
  122.         GetClientRect(&rect);
  123.         int x = (rect.Width() - cxIcon + 1) / 2;
  124.         int y = (rect.Height() - cyIcon + 1) / 2;
  125.  
  126.         // Draw the icon
  127.         dc.DrawIcon(x, y, m_hIcon);
  128.     }
  129.     else
  130.     {
  131.         CDialog::OnPaint();
  132.     }
  133. }
  134.  
  135. // The system calls this to obtain the cursor to display while the user drags
  136. //  the minimized window.
  137. HCURSOR CVirtualInterfaceDlg::OnQueryDragIcon()
  138. {
  139.     return (HCURSOR) m_hIcon;
  140. }
  141.  
  142. BEGIN_EVENTSINK_MAP(CVirtualInterfaceDlg, CDialog)
  143.     //{{AFX_EVENTSINK_MAP(CVirtualInterfaceDlg)
  144.     //}}AFX_EVENTSINK_MAP
  145. END_EVENTSINK_MAP()
  146.  
  147.