Using Windows Control in ATL

How can i create and call a dialog box in ATL.
I found that the way i create & call a dialog box in ATL is different than in VC++. VC++ method doesn't work in ATL.
Anybody knows, help me.
Who is Participating?
mflamConnect With a Mentor Commented:
Microsoft has a "composite control" which takes from the dialog class.
Please see:

The follwing is a simple way to add an ATL dialog to a simple ATL object.
(RMB is Right Mouse Button):
Make ATL proj, add simple obj.

Now Add ATL Dialog
   (RMB on ClassView project,
     Add New ATL object,
Add a button, and double click it.
Choose IDC_BUTTON1 and press
  Add and Edit.
Now open the class view and notice the class for this object.

You start the dialog, just like you start any other ATL COM object.
Any of the following:
1. Using the C++ code, instantiating a CComObjectEx.
2. Using the #import directive and ATL smart pointers.
3. Using C calls (CoCreateInstance)
4. Using containers like VB or DHTML.

jojiAuthor Commented:
I manage to create the DialogBox, but my main intention is to create and display a progress bar, i did the following way , but doesn't recognise the CProgressBarCtrl Object.It gives an error gor that.

LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 CWindow wnd=GetDlgItem(IDC_PROGRESS1);
 CRect rect;
 CProgressBarCtrl myCtrl; //Gives an  
        error in this line saying, un
        recognised object
 myCtrl.Create( WS_VISIBLE | WS_CHILD |  PBS_SMOOTH, rect, this,  IDC_PROGRESS1);
 myCtrl.SetRange( static_cast<short>(0), static_cast<short>(100) );
for(int i=1; i<10; i++)
return 1;  

All Courses

From novice to tech pro — start learning today.