Labels:

We can access the MYSQL in vc++ . For that we have to download the MYSQL Client Library for c.

Steps To Install the MYSQL Connector C

1. Click Next in the Setup Wizard.
2. Select the Custom tag and click Next
3. Make C Include Files and Lib Files installed on local drive.
4. If you Want to change the installation path, click the change button and select the path. else click Next.
5.Then Click Install Button.
6. After Installation a window will appear with Next option. Click Next and Finally click finish.

Steps To Configure MYSQL

1. Click Next in the Configure Wizard.
2. Select Reconfigure Instance and click Next.
3. Select Detailed Configuration and click Next.
4. Select Developer Machine and click Next.
5. Select Multi functional Database and click Next.
6. If you Want to Modify the path click modify and change the pah, else click Next.
7. Select Decision Support(DSS)/OLAP and click Next
8. Tick the Enable TCP/IP Networking and Enable Strict Mode , then click Next.
9. Select the Standard Character Set and click Next.
10. Tick the Include Bin directory in windows path an click Next.
11. Now Security Settings window will be shown.
->Make the Current root password as empty. Because by default the root password will be null.
->Create a new password.
->Tick the Create an Anonymous Account and click next.
12.Now click the Execute Button
13.After the execution completed , click the Finish button.


Labels:

The Following is an example program is to load and show an Image using CImage.

First Create a new MFC Application and name it as MyCImage. Then Follow the below steps,

1. Add the the following header files in the CMyCImage.h ,

#include "atlimage.h"
#include "atltypes.h"

2. Create the CImage object by the following code in CMyCImage.h ,

CImage img;

3.Create the FileOpen function and make that like below,

void CMyCImageView::OnFileOpen()
{
CFileDialog FileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY,"All Files(*.*)|*.*|");
if(FileDialog.DoModal() == IDOK)
{
CString PathName = FileDialog.GetPathName();
img.Load(PathName);
}
Invalidate();
}

4.Edit the OnDraw function and make it like below,

void CMyCImageView::OnDraw(CDC* pDC)
{
CMyCImageDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;

CRect m_ShowDRect;
m_ShowDRect=CRect(0,0,img.GetWidth(),img.GetHeight());
SetScrollSizes(MM_TEXT,CSize(img.GetWidth(),img.GetHeight()));
img.Draw(pDC->m_hDC,CRect(&m_ShowDRect));
}

5.Change the executable mode into Release mode and also change the Character set into Multi-Byte Character Set in the project settings.

6.Now Compile and Run.





Labels:

CImage is a class provides enhanced bitmap support, including the ability to load and save images in JPEG, GIF, BMP, PNG, TIFF and some other formats. CImage is part of the ATL. But we can share it in MFC.

For Sharing the CImage With MFC, We need to include the header file,

#include "atlimage.h"
#include "atltypes.h" (Optional)

Load Image in to CImage

To load an image to the CImage two formats are available,

1.HRESULT Load(LPCTSTR pszFileName);

Where,
pszFileName -- A pointer to a string containing the name of the image file to load.

2.HRESULT Load(IStream* pStream);

Where,
pStream -- A pointer to a stream containing the name of the image file to load.

Example:

CImage img;
img.Load("C:\images\sample.tiff");


Save Image From CImage

To Save an image in CImage two formats available,

1.HRESULT Save(IStream* pStream,REFGUID guidFileType);

2.HRESULT Save(LPCTSTR pszFileName,REFGUID guidFileType= GUID_NULL);

where,
pStream -- A pointer to a COM IStream object containing the file image data.
pszFileName -- A pointer to the file name for the image.
guidFileType -- The file type to save the image .

Example:

img.Save("D:\\images.bmp");