getopenfilename

How to prevent GetOpenFileName from changing the current directory while the dialog is shown?

为君一笑 提交于 2021-02-20 04:26:06
问题 GetOpenFileName (for questionable reasons) changes the current directory of an application while the dialog is shown. This can be reset on dialog closure by specifying OFN_NOCHANGEDIR as dialog initialization flag: OFN_NOCHANGEDIR Restores the current directory to its original value if the user changed the directory while searching for files. Setting this flag, however, doesn't prevent the function from changing the current directory while the explorer dialog is shown . This is an issue in

C++ LPSTR and string trouble with zero-terminated strings

人盡茶涼 提交于 2019-12-25 18:37:08
问题 I'm using GetOpenFileName function from Winapi , and I'm applying filter to the select file dialog. THIS works perfectly: LPSTR mfilter = "Filter\0*.PDF\0"; ofn.lpstrFilter = mfilter; if(GetOpenFileName(&ofn)){ ... THIS fails (dialog opens but no filters apply): string mfilter = "Filter\0*.PDF\0"; ofn.lpstrFilter = mfilter.c_str(); if(GetOpenFileName(&ofn)){ ... I need to use std:string because I'm getting the file extension via parameters and this type facilitates the concatenation but I'm

QFileDialog::getOpenFileName crashes when debugging, apparently caused by project name?

一世执手 提交于 2019-12-22 09:56:04
问题 I've run into a problem that's really confusing me. I'm using Qt Creator 3.1.2, with Qt 5.3 on Windows 7, using the MSVC 10.0 compiler and CDB from Debugging Tools for Windows 8.1. (Not sure if I should be looking for a Windows 7-specific debugger, but I haven't had any issues until now). The problem: when I try to use QFileDialog::getOpenFileName() while debugging, the program throws an exception. The inferior stopped because it triggered an exception. Stopped in thread 0 by: Exception at

C++ Simple IF clause changes value of a static const char variable

拜拜、爱过 提交于 2019-12-13 07:46:42
问题 Okay, I've been dealing with this for two days now, and I can't find a solution. Problem: I'm trying to set a filter to a File Selection Dialog using Winapi. I'm using GetOpenFileName function to do this. This function uses a structure to set options such as file extension filters. This structure's member called lpstrFilter needs a certain string format. I'm setting that string exactly as Winapi indicates, but for some reason, this string's value changes. I've got this static const char * : /

QFileDialog::getOpenFileName in console application

安稳与你 提交于 2019-12-12 05:27:23
问题 This is a question first posted on qtforum.org where I've got no answer: I have trouble hiding the Open dialog in a console application after it has been used. Here is the content of main.cc file used to test this behaviour: #include <QApplication> #include <QFile> #include <QFileDialog> #include <QString> bool b_closing = false; static QString gofn ( void ) { QString s_file; s_file = QFileDialog::getOpenFileName( qApp->activeWindow(), QObject::tr( "Select the file to open:" ) ); if ( !s_file

Winapi GetOpenFileName Extension Filter not working

可紊 提交于 2019-12-11 17:58:12
问题 I'm trying to apply file's extension filters to the file's selection dialog. This way works: ofn.lpstrFilter = "(*.exe) Windows Executable\0*.exe\0" "(*.ini) Windows Initialization file \0*.ini\0" "(*.dll) Dynamic Link Library \0*.dll\0" "(*.lib) Windows Library file \0*.lib\0" "(*.conf) Windows Configuration file \0*.conf\0"; But when I'm assigning extension filters dynamically, via parameters, it fails, filters don't appear in the combo box: LPCSTR filter = (LPCSTR)extFilter; //Contains

semi colons in Windows filenames?

喜你入骨 提交于 2019-12-10 16:06:07
问题 One of my users asked why my app does not support semi-colons in filenames. I stepped through my code, seems Windows function GetOpenFileName truncates any filename containing a semi-colon. e.g. "one;two.wav" -> "one". Microsoft says colons are not allowed, but don't mention semi-colons... http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx Are they legal or not? EDIT: ..and how to GetOpenFileName() to work with semi-colons in filename? OH!, Weird - Filename is correct, except

OFN_ENABLEHOOK modifies the look of GetOpenFileName()

拥有回忆 提交于 2019-12-07 21:47:30
问题 Why does adding a hook procedure (with the OFN_ENABLEHOOK and OFN_EXPLORER flags) to GetOpenFileName() causes a different dialog to be displayed in Windows 7, if the hook procedure just returns FALSE without doing anything? Update: Apparently getting the Vista/Windows 7 look with a hook is impossible... can someone confirm or counter this? 回答1: The reason for this is that MS completely re-organised the file dialogs for Vista. Hooks are used to extend a file dialog by supplying a resource file

OFN_ENABLEHOOK modifies the look of GetOpenFileName()

佐手、 提交于 2019-12-06 07:13:14
Why does adding a hook procedure (with the OFN_ENABLEHOOK and OFN_EXPLORER flags) to GetOpenFileName() causes a different dialog to be displayed in Windows 7, if the hook procedure just returns FALSE without doing anything? Update: Apparently getting the Vista/Windows 7 look with a hook is impossible... can someone confirm or counter this? The reason for this is that MS completely re-organised the file dialogs for Vista. Hooks are used to extend a file dialog by supplying a resource file. This gives the customiser too much power. They can all too easily modify standard elements of the dialog

QFileDialog::getOpenFileName crashes when debugging, apparently caused by project name?

与世无争的帅哥 提交于 2019-12-06 03:08:19
I've run into a problem that's really confusing me. I'm using Qt Creator 3.1.2, with Qt 5.3 on Windows 7, using the MSVC 10.0 compiler and CDB from Debugging Tools for Windows 8.1. (Not sure if I should be looking for a Windows 7-specific debugger, but I haven't had any issues until now). The problem: when I try to use QFileDialog::getOpenFileName() while debugging, the program throws an exception. The inferior stopped because it triggered an exception. Stopped in thread 0 by: Exception at 0x745f7736, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance). Release/debug