473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

GetSaveFileName problem: can't get selected filter and put default name

Leo
I am using OPENFILENAME and GetSaveFileName to let user save a
document out. However, the default name won't show up in the dialog and
the selected filter can't be obtained (always got the default one)
after the dialog is dismissed. Any hint is highly appreciated!

Leo

OPENFILENAME ofn;
TCHAR defDir[MAX_PATH];
TCHAR filePath[MAX_PATH];
TCHAR* title = _T("Save");

ZeroMemory(&ofn, sizeof(OPENFILENAME));

filePath[0] = _T('\0');
DWORD len = MAX_PATH;

DWORD flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADON LY;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFilter = _T("Text file (*.txt)\0*.txt\0Excel file
(*.xls)\0*.xls\0XML file (*.xml)\0*.xml\0\0");
ofn.lpstrFile = filePath;
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = defDir;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = title;
ofn.Flags = flags;
ofn.hwndOwner = hWnd; // make it modal

if (::GetSaveFileName(&ofn) && ipChildren)
{
string filter(ofn.lpstrFilter);
string fileName(ofn.lpstrFile);

if (filter == _T("Text file (*.txt)"))
return SaveAsText(fileName, ipChildren);
else if (filte == _T("Excel file (*.xls)"))
return SaveAsExcel(fileName, ipChildren);
else if (filter == _T("XML file (*.xml)"))
return SaveAsXML(fileName, ipChildren);
else
{
Cout << "Wrong input!";
return E_FAIL;
}

Jan 7 '06 #1
2 3546
Leo wrote:
I am using OPENFILENAME and GetSaveFileName to let user save a
document out. However, the default name won't show up in the dialog and
the selected filter can't be obtained (always got the default one)
after the dialog is dismissed. Any hint is highly appreciated!

Leo


Hello, You may recieve better answers if you ask your question in a
newsgroup dedicated to the platform specific code you are using (windows?).

Regards,
Peter Jansson
Jan 7 '06 #2
"Leo" <pk*******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I am using OPENFILENAME and GetSaveFileName to let user save a
document out. However, the default name won't show up in the dialog and
the selected filter can't be obtained (always got the default one)
after the dialog is dismissed. Any hint is highly appreciated!

Leo

OPENFILENAME ofn;
TCHAR defDir[MAX_PATH];
TCHAR filePath[MAX_PATH];
TCHAR* title = _T("Save");

ZeroMemory(&ofn, sizeof(OPENFILENAME));

filePath[0] = _T('\0');
DWORD len = MAX_PATH;

DWORD flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADON LY;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFilter = _T("Text file (*.txt)\0*.txt\0Excel file
(*.xls)\0*.xls\0XML file (*.xml)\0*.xml\0\0");
ofn.lpstrFile = filePath;
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = defDir;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = title;
ofn.Flags = flags;
ofn.hwndOwner = hWnd; // make it modal

if (::GetSaveFileName(&ofn) && ipChildren)
{
string filter(ofn.lpstrFilter);
string fileName(ofn.lpstrFile);

if (filter == _T("Text file (*.txt)"))
return SaveAsText(fileName, ipChildren);
else if (filte == _T("Excel file (*.xls)"))
return SaveAsExcel(fileName, ipChildren);
else if (filter == _T("XML file (*.xml)"))
return SaveAsXML(fileName, ipChildren);
else
{
Cout << "Wrong input!";
return E_FAIL;
}


Looks like windows code. Try microsoft.public.vc.language
Jan 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matthew Robinson | last post by:
Can anybody see what is wrong with this code? apparently i have an 'empty delimiter' on the line that sets $pos - can anybody see what is wrong with it? $search_for = $_GET;...
6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
2
by: Phong Pham | last post by:
Hi! I need to search an xml file for a <symbol>FO</symbol> being passed from a query string. here's my sample xml file (original xml file is generated from a mainframe): <stock> <Filter>...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
4
osward
by: osward | last post by:
I had made a table colum sortable and paging the table, following are the code // Display Event List echo "<center>"._EVENTLIST."</center><br>"; $now = Date(Y-m-d); // sort table...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
1
by: Brian McLaughlin | last post by:
Hi. Probably a simple problem but i'm pulling my hair out! I have 3 tables(Consultant name, hospital and medical department). Consultant name is joined to the other two by their primary key. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.