1

I need to create a windows application in C++ and it has to show just a TaskDialog (see http://msdn.microsoft.com/en-us/library/windows/desktop/bb760540(v=vs.85).aspx ). The TaskDialog should show a text passed as parameter to the command line.

I can make a "Win32 Console Application" and call TaskDialog but then I will see the black windows of the console.

I can make a "Windows Application" and just calling TaskDialog inside WinMain, is there any problem with this solution?

Any other idea?

Alessandro Jacopson
  • 18,047
  • 15
  • 98
  • 153
  • 1
    I'm assuming you are using Visual Studio. You don't want to make a console application if you intend to have windows and dialogs. You can use `TaskDialog` or `TaskDialogIndirect` but you also need to be on Vista or Windows 7. – AJG85 Jan 30 '12 at 20:39

2 Answers2

5

I can make a "Windows Application" and just calling TaskDialog inside WinMain, is there any problem with this solution?

That is the way to implement such an app. There is no problem with it all. Of course you don't create a window explicitly in your code and you don't run a message loop. Just call TaskDialog.

The main point is that you don't want a console app because, as you have discovered, a console window is shown by default. There are two main subsystems, the console subsystem and the GUI subsystem. The latter is somewhat confusingly named. You are not compelled to show GUI in a GUI subsystem app. It's up to you whether or not you choose to do so. Really the choice comes down to whether or not you want a console. So the subsystems could be better named as console and non-console!

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thank you. Yes, when I write "just calling TaskDialog" I mean I do not create windows and do not run the message loop. – Alessandro Jacopson Jan 30 '12 at 20:49
  • 1
    Be aware that `TaskDialog` will run a message loop for you: "The TaskDialog function creates, displays, and **operates** a task dialog.". Probably won't hurt you here, but's important to understand that some functions do this. (MessageBox does the same) – MSalters Jan 31 '12 at 00:55
  • @MSalters sure, all I meant is that you don't want an explicit loop in the program's WinMain, just a call to TaskDialog. – David Heffernan Jan 31 '12 at 07:41
1

You have to create a empty windows application.

The entry point of a windows application is calles WinMain and looks like this:

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
    //Place your code here
}

This means your solution is correct. You just have to make sure that your application uses version 6 of Comctl32.dll. Otherwise TaskDialog will fail.

Norbert Willhelm
  • 2,579
  • 1
  • 23
  • 33
  • 3
    Minor correction. `TaskDialog` works fine without visual styles. It just needs comctl v6. The two are not quite the same thing. For example consider Windows Classic theme. – David Heffernan Jan 30 '12 at 22:03