Click here to Skip to main content
16,004,924 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionImplementing IDownloadManager & download() method.. Pin
p33ks3-Sep-07 3:54
p33ks3-Sep-07 3:54 
AnswerRe: Implementing IDownloadManager & download() method.. Pin
Michael Dunn3-Sep-07 22:14
sitebuilderMichael Dunn3-Sep-07 22:14 
AnswerRe: Implementing IDownloadManager & download() method.. Pin
myshketer4-Sep-07 4:08
myshketer4-Sep-07 4:08 
Answerread csExWBv2.0.0.2 and TrueDownloaderIE Pin
xinkmt11-Dec-11 21:20
xinkmt11-Dec-11 21:20 
QuestionHow to create a dynamic checkbox? Pin
AnnaWang2-Sep-07 1:55
AnnaWang2-Sep-07 1:55 
AnswerRe: How to create a dynamic checkbox? Pin
Dhiraj kumar Saini5-Sep-07 20:28
Dhiraj kumar Saini5-Sep-07 20:28 
GeneralRe: How to create a dynamic checkbox? Pin
AnnaWang9-Sep-07 3:03
AnnaWang9-Sep-07 3:03 
QuestionDisplay a CAxDialogImpl and a CWindowImpl at once. Pin
p_4731-Sep-07 5:22
p_4731-Sep-07 5:22 
Dear ATL people,

I have a maybe-newbie question, so sorry for that. I have a
CAtlExeModuleT (see code below) and want to adjust a sample that I
got. It started by creating a modal CAxDialogImpl object in the
PreMessageLoop of the CAtlExeModuleT. What I wanted to do is to make
the dialog modeless so that I can display additionally a CWindowImpl
(with the option to make it fullsceen later, to display jpegs).
So is it possible to create a CAxDialogImpl and a CWindowImpl which
both have the desktop as parent (giving NULL as first parameter in
the Create call)? Or do they have to be related to each other (forming
a chain of parent-child)? When I execute the code below the program
runs for short and then ends without displaying anything. I added
a Sleep(5000) after the window creation and the window was visible.
So it seems to be a matter of scope. But the dialog wasn't visible.
How could I get it work that the window AND the modeless dialog are
created correctly and do not go out of scope so that the event
handling works properly? Do I have to put them in PreMessageLoop
(I tried this, but the effect was the same; do I need
PreMessageLoop)? - I would prefer a solution with _tWinMain only to
get rid of the PreMessageLoop if possible.

Please help, I think it's not a hard problem for someone who has some
experience with the ATL. You would really help me greatly because I am
totally stuck despite two books on ATL and the web (I only found exam-
ples where they use the older CCom stuff with a main message loop in
_tWinMain and TranslateMessage(&msg) and DispatchMessage(&ms) into it)
but not how to use ATL windows in context of the CAtlExeModuleT like
I need in this case (ATL 8.0, Visual Studio 2005).

So with the hope on help I send you

Best regards,

Peter.


Here comes the code:
// Sample.cpp : Using _tWinMain to display a CAxDialogImpl<> and a CWindowImpl<>.

#include "stdafx.h"
#include "resource.h"
#include "mainDialog.h"

class CMyWindow : public CWindowImpl<CMyWindow>
{
public:
   // Optionally specify name of the new Windows class
   DECLARE_WND_CLASS("MyName") 
              // If this macro is not specified in your
              // class, ATL will generate a class name
   

   BEGIN_MSG_MAP(CMyWindow)
      MESSAGE_HANDLER(WM_PAINT, OnPaint)
   END_MSG_MAP()

   LRESULT OnPaint(UINT nMsg, WPARAM wParam, 
                   LPARAM lParam, BOOL& bHandled)
   {
      // Do some painting code
      return 0;
   }
};



class CSampleModule : public CAtlExeModuleT< CSampleModule >
{
public :
	HRESULT PreMessageLoop(int nShowCmd)
	{
		HRESULT hr = CAtlExeModuleT<SampleModule>::PreMessageLoop(nShowCmd);
		if (FAILED(hr))
			return hr;

	
		return S_FALSE;
	}
};

CSampleModule _AtlModule;

//
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, 
                                LPTSTR /*lpCmdLine*/, int nShowCmd)
{
	//LPSTR szTitle = "";

	//LoadString( hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);


	CMainDialog* mainDlg = new CMainDialog();//CMainDialog is a subclass of CAxDialogImpl<>
	//mainDlg->DoModal();
	mainDlg->Create(NULL);//Possible like this, using NULL as parent,
                              //so that desktop is parent window, and omitting
                              //second parameter, the client rect?

	//Sleep(10000);//To see whether the dialog is visible before it gets out of scope.

	CMyWindow* myWnd = new CMyWindow();

	myWnd->Create( 0, CWindow::rcDefault, "Image Test",
	WS_OVERLAPPEDWINDOW, WS_EX_CLIENTEDGE ); //Parent 0, i.e. desktop.

	if( !myWnd ) {
		return FALSE;
	}

	myWnd->CenterWindow();
	myWnd->ShowWindow( nShowCmd );
	myWnd->UpdateWindow();

	//Sleep(5000);

	return _AtlModule.WinMain(nShowCmd);

}

QuestionBSTR Pin
anithavikram(manisha)30-Aug-07 17:50
anithavikram(manisha)30-Aug-07 17:50 
AnswerRe: BSTR Pin
prasad_som30-Aug-07 18:48
prasad_som30-Aug-07 18:48 
Questioncreate a custome right click custom menu for Internet Explorer in vc++ Pin
Dhiraj kumar Saini28-Aug-07 0:37
Dhiraj kumar Saini28-Aug-07 0:37 
AnswerRe: create a custome right click custom menu for Internet Explorer in vc++ Pin
Michael Dunn28-Aug-07 7:54
sitebuilderMichael Dunn28-Aug-07 7:54 
QuestionATL owner-draw button problem Pin
WarCraft III27-Aug-07 21:04
WarCraft III27-Aug-07 21:04 
Questionadding menu item to right click context menu Pin
Dhiraj kumar Saini27-Aug-07 1:58
Dhiraj kumar Saini27-Aug-07 1:58 
AnswerRe: adding menu item to right click context menu Pin
Michael Dunn27-Aug-07 6:53
sitebuilderMichael Dunn27-Aug-07 6:53 
GeneralRe: adding menu item to right click context menu Pin
Stephen Hewitt27-Aug-07 22:15
Stephen Hewitt27-Aug-07 22:15 
QuestionUsing QueryInterface inside a COM Pin
donguy7625-Aug-07 5:56
donguy7625-Aug-07 5:56 
AnswerRe: Using QueryInterface inside a COM Pin
Dennis Gourjii29-Aug-07 9:23
Dennis Gourjii29-Aug-07 9:23 
QuestionADODB Rowset vs Stream Arbitration [modified] Pin
Nonpareil23-Aug-07 6:56
Nonpareil23-Aug-07 6:56 
QuestionHow to get IE main menu hwnd? Pin
gzcjun22-Aug-07 22:43
gzcjun22-Aug-07 22:43 
AnswerRe: How to get IE main menu hwnd? Pin
Dennis Gourjii29-Aug-07 9:27
Dennis Gourjii29-Aug-07 9:27 
AnswerRe: converting VT_DISPATCH into CString Pin
prasad_som20-Aug-07 21:22
prasad_som20-Aug-07 21:22 
QuestionSubclass Window Pin
baerten19-Aug-07 22:32
baerten19-Aug-07 22:32 
AnswerRe: Subclass Window Pin
Dennis Gourjii29-Aug-07 9:31
Dennis Gourjii29-Aug-07 9:31 
QuestionActiveX control in popup browser window crashes when closed Pin
Abu Mami19-Aug-07 4:55
Abu Mami19-Aug-07 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.