X

Barcode EAN 8 and 13 Source Code

The class that I’m going to describe is the one we use in RGPSoft to create and print barcodes, in particular for the EAN 13 and EAN 8, the most commonly used. This class written in C++ was built with MFC, because the base class is a CStatic, but obviously a good programmer will certainly turn for the SDK for Windows, or Linux or Visual Basic or PHP, or Java, or C# or create a ActiveX component with ATL or MFC. Let’s say that you want to use MFC, you have to enter into a dialog, for example, a static control and then go through DoDataExchange subclassing of the control. To insert the code within the control you must use the SetCodix (bar code) will be drawn when the window will show the design of the bar code, the same attention as it is the control that automatically calculates the check code and then the final code to enter letters will be respectively 12 and 7 points.

class CBarCodeWnd : public CStatic
{
 DECLARE_DYNAMIC(CBarCodeWnd)

public:
 CBarCodeWnd();
 virtual ~CBarCodeWnd();

 char CharControl(CString strValue);
 bool SetCodix(CString strValue);
 bool SetStep(short nVal);
 void DrawNumber(CDC* pDC, CRect rc, wchar_t val);
 bool GetA(int number, int index);
 bool GetB(int number, int index);
 bool GetC(int number, int index);
 bool GetType(int number, int index);
protected:
 CString m_strCodix;
 short m_nStep;

protected:
 afx_msg void OnPaint();
 DECLARE_MESSAGE_MAP()
};

The complete source code of this control for draw barcode EAN 8 or 13 can be found in our download page.

Categories: Programming
giampy107:
X

Cookies Policy

We use cookies to personalize content and ads, provide social media features and analyze our traffic. We also share information about your use of our site with our web analytics, advertising and social media partners who may combine it with other information you have provided to them or that they have collected based on your use of theirs. services.

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings