473,667 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using OpenFileDialog

I am new to VC++ and .NET, so this is a pretty basic question...

I want to use OpenFileDialog. Where is the header for it?

And in general, how do I find the right header to include in cases like this
within .NET? I would thought that

#include <OpenFileDialog .h>

would do the trick, but there ain't no such beast apparently.

Quite a few example programs I find on the net use

using namespace System::Windows ::Forms

but I am told that 'System' is not a namespace. This is unmanaged code, so
I don't think I can use namespace?
Nov 17 '05 #1
8 2238
"Burt" <bu**@mindsto rm-inc.com> wrote in message
news:ey******** *************@n ews.easynews.co m...
I want to use OpenFileDialog. Where is the header for it?
...
but I am told that 'System' is not a namespace. This is unmanaged code,
so ...


You are writing an unmanaged application and what to use .Net's
OpenFileDialog? Wouldn't you be better of with the likes of
GetOpenFileName () in an unmanaged code?

Regards,
Will
Nov 17 '05 #2
Apparently so, now that I know about it... :-)

Sure wish MSDN would provide pointers like that. This seems to do exactly
what I was looking for. thanks!

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"Burt" <bu**@mindsto rm-inc.com> wrote in message
news:ey******** *************@n ews.easynews.co m...
I want to use OpenFileDialog. Where is the header for it?
...
but I am told that 'System' is not a namespace. This is unmanaged code,
so ...


You are writing an unmanaged application and what to use .Net's
OpenFileDialog? Wouldn't you be better of with the likes of
GetOpenFileName () in an unmanaged code?

Regards,
Will

Nov 17 '05 #3
Burt wrote:
I am new to VC++ and .NET, so this is a pretty basic question...

I want to use OpenFileDialog. Where is the header for it?

And in general, how do I find the right header to include in cases like this
within .NET? I would thought that

#include <OpenFileDialog .h>

would do the trick, but there ain't no such beast apparently.

..NET facilities are not placed in headers/.cpp files but in dlls.

Quite a few example programs I find on the net use

using namespace System::Windows ::Forms

but I am told that 'System' is not a namespace. This is unmanaged code, so
I don't think I can use namespace?

namespaces can be used in both managed and unmanaged code (have you heard of namespace
std?), try placing:

#using <mscorlib.dll >
#using <System.dll>
#using <System.Data.dl l>
#using <System.Drawing .dll>
#using <System.Windows .Forms.dll>
#using <System.XML.dll >
Those will be sufficient for a typical GUI application. However VC++ should use them
implicitly for you.
You can compile unmanaged code together with managed code by using /clr.
Nov 17 '05 #4
"Burt" <bu**@mindsto rm-inc.com> wrote in message
news:cX******** **************@ news.easynews.c om...
Apparently so, now that I know about it... :-)
I'm glad you found what you need.
Sure wish MSDN would provide pointers like that. This seems to do exactly
what I was looking for. thanks!


You are welcome.

Some rambling ...

1) I think I heard that there are "millions" of pages on MSDN. Keeping it
straight in magnetic or gray matter is a huge undertaking. :-)

Google is good at that sort of thing so I tend to use it to find things on
MSDN. Just append

site:msdn.micro soft.com

to a google query.

2) If you don't find what you need, or if you don't go there first, come
back here. Chances are that someone will help you out.

3) It is usually best to describe _what_ you want to do and not _how_ you
want to do it. I was about to answer the question you asked when I realized
you probably didn't want to go down that path.

4) Due to personal bias and experience, I don't usually suggest MFC
solutions to problems. But _you_ might want to look at its CFileDialog class
as it probably best approximates the .Net class you happened on in the docs

Regards,
Will
Nov 17 '05 #5
William DePalo [MVP VC++] <wi***********@ mvps.org> wrote:
Some rambling ...

1) I think I heard that there are "millions" of pages on MSDN. Keeping it
straight in magnetic or gray matter is a huge undertaking. :-)

Google is good at that sort of thing so I tend to use it to find things on
MSDN. Just append

site:msdn.micro soft.com

to a google query.
Good suggestion. I'll keep it in mind. I often find references to MSDN
in my Google searches even without adding the site though.

2) If you don't find what you need, or if you don't go there first, come
back here. Chances are that someone will help you out.
I was delighted to have the answer in under an hour. :-)

I used to frequent the programming lounges that related to my work (Mac
for 15 years, Java for 7 years, etc). I have been pretty much out of
the game for the past 3 years though (dot-bomb bit me, and suddenly my
35 years of experience was a liability rather than an asset), and am
just getting back into it. This is my first foray into Windows
programming via C++. I've written several Java apps for Windows though.

3) It is usually best to describe _what_ you want to do and not _how_ you
want to do it. I was about to answer the question you asked when I realized
you probably didn't want to go down that path.
I didn't even realize there were separate frameworks for managed and
unmanaged code until this thread. I thought that was just a compiler
flag that redefined Object constructors/destructors to manage memory for
me. Shows how little I know about this new game... I've only been in it
for 2 weeks. :-)

In this case, I knew I wanted to open a file, so I Googled and found
OpenFileDialog. Looked reasonable, so I went to use it and hit a
completely unexpected wall. I never even thought that might not be the
right Class for unmanaged code.

4) Due to personal bias and experience, I don't usually suggest MFC
solutions to problems. But _you_ might want to look at its CFileDialog class
as it probably best approximates the .Net class you happened on in the docs


I have no choice in the matter. The client has almost 10 years of
legacy code that is being enhanced for version 10. There is some C#
work being done on new subsystems, but the section I am in uses VC++
MFC, so that is what I need to learn quickly.

--
- Burt Johnson
MindStorm, Inc.
http://www.mindstorm-inc.com/software.html
Nov 17 '05 #6
Burt Johnson wrote:
I have no choice in the matter. The client has almost 10 years of
legacy code that is being enhanced for version 10. There is some C#
work being done on new subsystems, but the section I am in uses VC++
MFC, so that is what I need to learn quickly.


In case you are interested in .NET C++ programming by using VC++ 2003, a very nice book is
http://vig.prenhall.com/catalog/acad...373774,00.html
It is basic to intermediate level and covers all/most .NET features, including multithreading.
If you can wait for VC++ 2005 though, my suggestion is wait and learn about that (of
course the .NET knowledge migration from VC++ 2003 to 2005 is easy, but if you can wait
for about 6 months and are permitted to use 2005 in your job, then why not learning about
2005 directly and its new features).
Nov 17 '05 #7
Ioannis Vranos <iv*@remove.thi s.grad.com> wrote:
In case you are interested in .NET C++ programming by using VC++ 2003, a
very nice book is
http://vig.prenhall.com/catalog/acad...373774,00.html
It is basic to intermediate level and covers all/most .NET features,
including multithreading.
If you can wait for VC++ 2005 though, my suggestion is wait and learn
about that (of course the .NET knowledge migration from VC++ 2003 to 2005
is easy, but if you can wait for about 6 months and are permitted to use
2005 in your job, then why not learning about 2005 directly and its new
features).


Our product will be shipping before VC++ 2005 is out, so I can't wait.
I will likely make that migration when the time comes, but I need to get
up to speed fast now.

What I really miss is the equivalent of "The Java Developer's Almanac"

http://www.amazon.com/exec/obidos/AS...285237/sr=2-1/
ref=pd_bbs_b_2_ 1/002-0551388-0066406

I wore my copy out so badly the pages were falling out, and i had to buy
a new copy -- and that one is pretty ragged now too. A simple,
small-type condensed listing of every Class and every method in Java
Swing. The parameters are listed, but no statement of what the Class or
method does or how to use it.

I find that I often turn to it to see the methods that are available.
They are so intuitively named that I rarely have to look up how to use
them or what they do. Just the name and parameter list is enough.

I had expected MSDN to be able to fill that role Online, but it takes an
exorbitant amount of time to reach such a simple list of methods in many
cases.

This new wrinkle of managed vs unmanaged code frameworks now has to be
absorbed by my tired brain too. The client had tried managed code, but
found it was so massively slow that the developers couldn't stand it,
let alone what customers would have said. They then changed to
unmanaged code, and performance is quite acceptable.

That was all done prior to my arrival though. I only hear of it as
"lessons learned" over the past few months.

--
- Burt Johnson
MindStorm, Inc.
http://www.mindstorm-inc.com/software.html
Nov 17 '05 #8
Burt Johnson wrote:
This new wrinkle of managed vs unmanaged code frameworks now has to be
absorbed by my tired brain too. The client had tried managed code, but
found it was so massively slow that the developers couldn't stand it,
let alone what customers would have said. They then changed to
unmanaged code, and performance is quite acceptable.

That was all done prior to my arrival though. I only hear of it as
"lessons learned" over the past few months.

I am not sure there is so much penalty of managed vs unmanaged code, especially with C++.
Managed DirectX vs unmanaged has a time-cost of about 2% (that is, it has 98% of the
efficiency of the unmanaged DirectX).
In regular applications personally I do not see any difference at all.

Nov 17 '05 #9

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

Similar topics

3
1567
by: violin wang | last post by:
hi I wrote a windows based program.The main UI named form_base has a button "btn1".In btn1`s click event handler I used ShowDialog(this) to show another form named form_test.form_test also has a button btn2 and I added a openfiledialog in form_test.In btn2 click event handler I used ShowDialog(this) to show openfiledialog. When I ran the program, I found that when the openfiledialog returned, the form_test would close automatically and...
2
5726
by: Bonzo | last post by:
Hi, How do I simply open a text file into a textbox? I know that in C++ I'd use something like: if(OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1->FileName); How can I do it in vsnet c#? THX
2
3076
by: don | last post by:
has anyone experienced problems with interactions between OpenFileDialog and FileStream? When I select "open" from an OpenFileDialog the subsequent calls to FileStream do not create a file. If I do anything else, eg, navigate to other folders, and then press "cancel" the file is created. This occurrs just with the simple code below. Any ideas private void button1_Click(object sender, System.EventArgs e // open the common dialog bo...
8
6037
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
1
4942
by: Austin Jan | last post by:
Hi all, In this code snip try { using(OpenFileDialog dlg = new OpenFileDialog()) { //do something }
2
1753
by: Willem | last post by:
Hi, I am creating a web application in asp.net in which I have to show an openfiledialog box to select the file and display the selected file with its path in a text box. I try to solve this problem with the System.Windows.Forms.OpenFileFialog. I use Imports System.Windows.Forms
8
6080
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and only the files I want to see appear in the file list box. When I change the filter to one of the other filters, all the files in the list disappear. If I then manually type a filter into the "Filename" textbox, then the files appear and the filter...
0
1181
by: Gregaz | last post by:
I have a form in my project, which I open as a DialogBox. On that that form there are 3 TextBoxes. To one of them I want to write in a file path. To have it easier I have an OpenFileDialog control on my form. Selected file path is written in to th TextBox. OpenFileDialog is open by click on a Button. There is other Button on the form run the code which save every form field to a file. When I manualy fill all fields in form everything...
3
3253
by: Martijn Mulder | last post by:
It strikes me that System.Windows.Forms.OpenFileDialog seems te 'remember' which directory it was in last, even when a new OpenFileDialog-object is created for every access to the file system. This 'persistence' also holds between different invocations of the same program. Even when the .cs file is re-compiled, the OpenFileDialog again opens in the directory where it was directed to the previous time. 1. Is this a 'feature' of...
0
8458
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.