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.
jojiAsked:
Who is Participating?
 
mflamConnect With a Mentor Commented:
Microsoft has a "composite control" which takes from the dialog class.
Please see:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcmfc/vcconcompositecontrolfundamentals.htm

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,
      Miscelanious
       Dialog)
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.

Moshe
0
 
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)
{
 USES_CONVERSION;
 CWindow wnd=GetDlgItem(IDC_PROGRESS1);
 CRect rect;
 wnd.GetWindowRect(&rect);
 ScreenToClient(&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) );
 myCtrl.StepIt();
for(int i=1; i<10; i++)
{
  myCtrl.SetStep(10);
  Sleep(200);
  myCtrl.StepIt();
}
return 1;  
}

0
All Courses

From novice to tech pro — start learning today.