home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / bar_vbx / setprops.cpp < prev    next >
C/C++ Source or Header  |  1993-11-15  |  3KB  |  105 lines

  1. // setprops.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vctest.h"
  6. #include "setprops.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. extern "C" LPSTR GetLastErrorString(void);
  14. extern "C" int GetLastErrorCode(void);
  15.  
  16. extern CVBControl *BarCodeVBX;
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CSetProps dialog
  19.  
  20. CSetProps::CSetProps(CWnd* pParent /*=NULL*/)
  21.    : CDialog(CSetProps::IDD, pParent)
  22. {
  23.    //{{AFX_DATA_INIT(CSetProps)
  24.    m_Text = "";
  25.    m_BarCodeType = -1;
  26.    m_Ratio = -1;
  27.    m_Width = "";
  28.    m_Checksum = "";
  29.    m_CurrentChecksum = "";
  30.    //}}AFX_DATA_INIT
  31. }
  32.  
  33. void CSetProps::DoDataExchange(CDataExchange* pDX)
  34. {
  35.    CDialog::DoDataExchange(pDX);
  36.    //{{AFX_DATA_MAP(CSetProps)
  37.    DDX_Control(pDX, IDD_RATIO, m_RatioCTL);
  38.    DDX_Control(pDX, IDD_BARTYPE, m_BarCodeTypeCTL);
  39.    DDX_Text(pDX, IDD_TEXT, m_Text);
  40.    DDX_CBIndex(pDX, IDD_BARTYPE, m_BarCodeType);
  41.    DDX_CBIndex(pDX, IDD_RATIO, m_Ratio);
  42.    DDX_Text(pDX, IDD_WIDTH, m_Width);
  43.    DDX_Text(pDX, IDD_CHECKSUM, m_Checksum);
  44.    DDX_Text(pDX, IDD_CURCHECKSUM, m_CurrentChecksum);
  45.    //}}AFX_DATA_MAP
  46. }
  47.  
  48. BEGIN_MESSAGE_MAP(CSetProps, CDialog)
  49.    //{{AFX_MSG_MAP(CSetProps)
  50.    //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CSetProps message handlers
  55.  
  56. BOOL CSetProps::OnInitDialog()
  57. {  
  58.    long value;
  59.    char Buf[5];
  60.    CString Buf2;
  61.    
  62.    CDialog::OnInitDialog();
  63.    
  64.    CenterWindow();
  65.    
  66.    Buf2 = BarCodeVBX->GetStrProperty("Text");   
  67.    m_Text = Buf2;
  68.       
  69.    m_BarCodeType = (int)BarCodeVBX->GetNumProperty("BarCodeType");
  70.    
  71.    m_Ratio = (int)BarCodeVBX->GetNumProperty("Ratio");
  72.    
  73.    value = BarCodeVBX->GetNumProperty("NarrowBarWidth");
  74.    _ltoa(value,Buf,10);
  75.    m_Width = Buf; 
  76.                      
  77.    value = BarCodeVBX->GetNumProperty("Checksum");                     
  78.    _ltoa(value,Buf,10);
  79.    m_Checksum = Buf; 
  80.  
  81.    Buf2 = BarCodeVBX->GetStrProperty("ChecksumString");   
  82.    m_CurrentChecksum = Buf2; 
  83.   
  84.    UpdateData(FALSE);
  85.    
  86.    return TRUE;
  87. }
  88.  
  89.  
  90. void CSetProps::OnOK()
  91. {
  92.    UpdateData();
  93.    
  94.    BarCodeVBX->SetStrProperty("Text",m_Text);   
  95.    BarCodeVBX->SetNumProperty("BarCodeType",(long)m_BarCodeType);
  96.    m_Ratio = (int)BarCodeVBX->SetNumProperty("Ratio",(long)m_Ratio);
  97.    BarCodeVBX->SetNumProperty("NarrowBarWidth",atol(m_Width));
  98.    BarCodeVBX->SetNumProperty("Checksum",atol(m_Checksum));
  99.  
  100.    if(GetLastErrorCode())
  101.       AfxMessageBox(GetLastErrorString());
  102.       
  103.    CDialog::OnOK();
  104. }
  105.