I had the following lines of C++ code in my program
CFileDialog dialog(true);
CString strFileName=L"";
INT_PTR nResult = dialog.DoModal();
if(nResult == IDOK)
// Exception spotted here
// Debug information gives me --> dialog = {CFileDialog hWnd=0x00000000}
// What's the heck?
strFileName=dialog.GetFolderPath();
The problem is: When I execute the program on a PC running Windows XP, there always have an ugly exception which I don't know why it happened. But everything's fine when I copied it to another PC running Windows 7.
I'm desperate. Would you guy please tell me why?
You need to call
DWORD WINAPI CommDlgExtendedError(void);
after the instantiation of CFileDialog to check that it is instantiated OK and if not why not.
Edit:
You are not able to call GetFolderPath after the dialog is closed which it is when DoModal() returns. Look at this MSDN page under remarks on how to pass a buffer to hold the file names.
The fun of building on a Window7 machine, and deploying to XP.
If you trace through the MFC code:
::GetVersion() is called and executes all kinds of different code for Windows Visa and above. i.e. It behaves differently.
So this means that if you called GetPathName, GetFileName, or GetFolderPath after a DoModal in WIN7 it works as you'd expected (like Java). For Windows XP you would be incorrect, and the software crashes.
I could not use GetFolderPath on XP, but GetPathName was ok.
Related
I am creating a Win32 application, I have followed some setup code for creating a Win32 window without the need for a WinMain which can be found here. The code builds just fine and if I run the application by opening it in a file browser it runs no problem. However, if I run it via the command line it only outputs the console logs and doesn't create a window. I assume that this is also why if I run it via VSCode's debugger it also doesn't launch a window. Has anyone come across this issue before and found a fix for it? It would be pretty had to debug a GUI application if you can't use the debugger and see it at the same time.
This bit of code contains a mistake:
STARTUPINFO si;
GetStartupInfo(&si);
int nCmdShow = si.wShowWindow;
You forgot to check si.dwFlags, as indicated in the documentation for wShowWindow:
If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the values that can be specified in the nCmdShow parameter for the ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this member is ignored.
I am upgrading from Windows 7 to Windows 10. I tried to use activex (ocx) in Windows 10, but the program did not start and ended. I got the source and checked it, but compiling is not a problem, but when I make ocx and load it in another program and use it, "Warning: Creating dialog from within a COleControlModule application is not a supported scenario." is a debug message. Even if it is compiled and used in Release version, it does not run. The activeX program structure in question is used by creating CDialog inside.
Can this situation be solved simply?
//code
m_CamDlg.Create( IDD_CAMDIALOG, this); // <= There is a problem here
TRACE("CLiveViewCtrl OnCreate 3\n");
m_CamDlg.ShowWindow(1);
Using mixed managed/unmanaged C++ (Visual Studio 2008) I'm opening a windows form child window from a DirectX application. Weird stuff indeed, but it works, mostly. If I use showDialog() the child window works perfectly, but obviously the main app stops running (until the child is closed). If I use show() life is good, but the child has subtle issues. A textbox works and accepts input for example, but you can no longer use the Tab key to move to different controls. Mnemonics (Alt+hotkey) have stopped working as well.
I'm a huge keyboard shortcut fan, so this is very annoying. To make it worse, I'm not even sure how to Google this issue. Any help would be greatly appreciated.
To resolve the tabbing problem either use a separate thread to create the dialog and call showDialog(), or call IsDialogMessage in your main message loop.
I maintain an application written using visual studio 2010 and wxWidgets version 2.8.10. It has been reported to me that, under windows vista, the application will crash when displaying a wxFileDialog that is viewing a network drive and being resized. The dialogue is invoked with the following code:
wxFileDialog file_chooser(
this,
make_wxString(my_strings[strid_file_choose_caption]),
make_wxString(frame->get_config()->get_last_os_dir()),
wxT(""), // default file
make_wxString(loader->get_file_extension()),
wxOPEN);
int rcd = file_chooser.ShowModal();
Has anybody seen anything similar?
Crashes inside the standard file dialog are almost invariably due to the presence of some buggy shell extension on the system. To say anything more you'd need to get the minidump (or at least a stack trace) at the moment of crash and debug it.
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?
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!
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.