Thursday, April 29, 2010

Diffrence Between MFC and ATL projects

Microsoft Foundation Classes (MFC)
The C++ class library that Microsoft provides with its C++ compiler to assist programmers in creating Windows-based applications. MFC hides the fundamental Windows API in class hierarchies so that programmers can write a Windows-based application without needing to know the details of the native Windows API.
Microsoft created MFC to make the development of applications for Windows much easier than it was using the SDK.

Active Template Library (ATL)
A C++ template library used to create ActiveX servers and other Component Object Model (COM) objects. ActiveX controls created with ATL are generally smaller and faster than those created with the Microsoft Foundation Classes.
ATL provides a framework to implement the code necessary to create
COM clients and servers. The two frameworks overlap in their usefulness for
developing ActiveX controls.
ATL's purpose in is to save developers from having to rewrite IUnknown,
IDispatch, IClassFactory, and all the hooks for turning regular DLLs and EXEs into
COM-based DLLs and EXEs. In this respect, ATL is a much lighter framework than MFC,
and ATL was designed and built with COM support in mind.

The differences between the two architectures are fairly stark. Generally, MFC enables you to get your project up and running more quickly, but sacrifices flexibility. ATL isn't quite as quick and easy to use, but it is COM-friendly. In addition, ATL appears to be getting easier to use as it matures.

Thanks.

About Active X and COM

ActiveX
A set of technologies that enable software components to interact with one another in a networked environment, regardless of the language in which the components were created. ActiveX, which was developed as a proposed standard by Microsoft in the mid 1990s and is currently administered by the Open Group, is built on Microsoft's Component Object Model (COM). Currently, ActiveX is used primarily to develop interactive content for the World Wide Web, although it can be used in desktop applications and other applications. ActiveX controls can be embedded in Web pages to produce animation and other multimedia effects, interactive objects, and sophisticated applications. See also COM.

ActiveX client
An application or tool that calls an ActiveX object.

ActiveX object
An exposed object of the Component Object Model (COM).

Component Object Model (COM)
An open architecture for cross-platform development of client/server applications. It is based on object-oriented technology as agreed upon by Digital Equipment Corporation and Microsoft Corporation. COM defines the interface, similar to an abstract base class, IUnknown, from which all COM-compatible classes are derived.

Thanks.

Diffrence between Strcpy(), Strncpy() and strcpy_s() Functions

Consider the code snippet:

char str[5];
strcpy (str, "Hello");

This will copy the word “Hello” to the character buffer ‘str’, but if i write ,

strcpy (str, "Hello world");

it will corrupt the memory in adjacent locations to str because the buffer str is only 5 bytes long and the source string is

11 bytes. The safe way is use the strncpy() function that takes the size of the destination buffer also as an argument.

strncpy (str, "Hello", 5);

or

strncpy (str, "Hello world",5);

Now, irrespective of the size of the source string, only 5 bytes will be copied to str.

Taking one step ahead, Microsoft released a set of more secure versions of these functions in Visual C++ 2005. This enhanced

set includes secure versions of functions like strcpy, ctime, fopen, scanf and many more.

The newer functions have the same function name appended by the “_s” suffix. e.g. the secure version for strcpy() is

strcpy_s(). Of course, there are differences in function prototypes. In the case of strcpy() and strcpy_s() they are:

char *strcpy( char *strDest, const char *strSrc );
errno_t strcpy_s( char *strDest, size_t nSize, const char *strSrc );

You will notice that strcpy_s() takes size of the destination buffer also, as an input parameter.

Thursday, April 22, 2010

New Visual Studio 2010 and .NET Framework 4.0

After a very long changes, Visual Studio is available within its development interface, which now uses WPF(Windows Presentation Foundation). In this new VS the IDE of new VS now supports the use of multiple monitors, that means code can appear in more than one monitor like one monitor use code while another is used to display the database structure or etc. It also provide the all known look of "ribbon" interface that first came in Office 2007.

The Programmer or Developers will be happy with the new toolbox that can be used to target multiple platforms, ranging from standard binaries, to developing Silverlight apps.

It also provides a platform with which developers can build apps for Windows Phone 7.

New ASP.NET features
* Static IDs for ASP.NET Controls
* The Chart control
* Web.config transformation

New VB.NET features
* Auto Implemented Properties for VB.NET
* Collection Initializers
* Implicit Line Continuations
* Statements in Lambda Expressions

New C# features
* Dynamic Types
* Optional parameters
* Named and Optional Arguments

-------------------------------------------------------
posted by:Anil Jain

Thursday, April 8, 2010

How to show OpenFileDialogBox in VC++

CFileDialog *CommDlg;
char Filetype[] = "All Files (*.EXE)|*.EXE||";
CommDlg = new CFileDialog(TRUE, NULL, NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filetype,this);
CommDlg->DoModal();

UpdateData(TRUE);
CString Filename;
CString m_AppPath = CommDlg->GetPathName();
if(m_AppPath.IsEmpty())
{
delete CommDlg;
return;
}
Filename = CommDlg->GetFileName();
int Filesize = Filename.GetLength();