473,396 Members | 2,109 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,396 software developers and data experts.

VS2005 DialogResult

rk
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog1->ShowDialog()==
DialogResult::OK)

However, this does not work, and I have to use:

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

Did I miss anything, or is this a bug?

Thanks
Richard
Feb 28 '06 #1
11 2626
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog1->ShowDialog()==
DialogResult::OK)

However, this does not work, and I have to use:

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows::Forms;

at the top (or at least before you use the above code).
Or did I miss something in your post?

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #2
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog1->ShowDialog()==
DialogResult::OK)

However, this does not work, and I have to use:

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows::Forms;


using namespace System::Windows::Forms;

that is...

-cd
Feb 28 '06 #3
rk
Hi Jochen,

I had added

using namespace System::Windows::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

and

using namespace System::Windows::Forms;
if (openFileDialog1->ShowDialog()==DialogResult::OK)

should be equivalent. So I would expect it to be a bug if they are not.

Or not?

Richard
Jochen Kalmbach [MVP] schrieb:
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog1->ShowDialog()==
DialogResult::OK)

However, this does not work, and I have to use:

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows::Forms;

at the top (or at least before you use the above code).
Or did I miss something in your post?

Feb 28 '06 #4
Hi rk!
using namespace System::Windows::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

and

using namespace System::Windows::Forms;
if (openFileDialog1->ShowDialog()==DialogResult::OK)

should be equivalent. So I would expect it to be a bug if they are not.


What prolems do you get???
For me it works without any problems in VS2003 and VS2005...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #5
Hi Jochen,

strange. When compiling

private: System::Void openToolStripMenuItem_Click(System::Object^
sender, System::EventArgs^ e) {

if (openFileDialog1->ShowDialog()== DialogResult::OK)
//System::Windows::Forms::DialogResult::OK) // this works
{
richTextBox1->LoadFile(openFileDialog1->FileName);
}
}
I get

1>c:\vs2005\projekt1\projekt1\Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Windows::Forms::Form::DialogResult'
1> c:\vs2005\projekt1\projekt1\Form1.h(23): Siehe Deklaration
von 'System::Windows::Forms::Form::DialogResult'
1>c:\vs2005\projekt1\projekt1\Form1.h(156) : error C2065: 'OK':
nichtdeklarierter Bezeichner
1>Das Buildprotokoll wurde unter
"file://c:\VS2005\Projekt1\Projekt1\Debug\BuildLog.htm" gespeichert.
1>Projekt1 - 2 Fehler, 0 Warnung(en)

If this works for you - what could I have done wrong?

I am using

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installierte Edition: Professional

Thanks
Richard

Jochen Kalmbach [MVP] schrieb:
Hi rk!
using namespace System::Windows::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

and

using namespace System::Windows::Forms;
if (openFileDialog1->ShowDialog()==DialogResult::OK)

should be equivalent. So I would expect it to be a bug if they are not.


What prolems do you get???
For me it works without any problems in VS2003 and VS2005...

Feb 28 '06 #6
Hallo R!

private: System::Void openToolStripMenuItem_Click(System::Object^
sender, System::EventArgs^ e) {

if (openFileDialog1->ShowDialog()== DialogResult::OK)
{
richTextBox1->LoadFile(openFileDialog1->FileName);
}
}
I get

1>c:\vs2005\projekt1\projekt1\Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Windows::Forms::Form::DialogResult'
1> c:\vs2005\projekt1\projekt1\Form1.h(23): Siehe Deklaration
von 'System::Windows::Forms::Form::DialogResult'


Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResult".
The compiler is using this member instead of the enum...

Also if you enter "::" after "DialogResult" you get the "correct" hint
(you have only "get" or "set" and no values of the enum!).

AFAIK the shortest version is:
Windows::Forms::DialogResult::OK

Inside a Form...

By the way: Es gibt auch eine deutschsprachige newsgroup für managed C++
/ C++/CLI:
microsoft.public.de.german.entwickler.dotnet.vc

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #7
Jochen Kalmbach [MVP] schrieb:
Hallo R!

private: System::Void openToolStripMenuItem_Click(System::Object^
sender, System::EventArgs^ e) {

if (openFileDialog1->ShowDialog()== DialogResult::OK)
{
richTextBox1->LoadFile(openFileDialog1->FileName);
}
}
I get

1>c:\vs2005\projekt1\projekt1\Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Windows::Forms::Form::DialogResult'
1> c:\vs2005\projekt1\projekt1\Form1.h(23): Siehe Deklaration
von 'System::Windows::Forms::Form::DialogResult'
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResult".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.
The compiler is using this member instead of the enum...

Also if you enter "::" after "DialogResult" you get the "correct" hint
(you have only "get" or "set" and no values of the enum!).

AFAIK the shortest version is:
Windows::Forms::DialogResult::OK

Inside a Form...

By the way: Es gibt auch eine deutschsprachige newsgroup für managed C++
/ C++/CLI:
microsoft.public.de.german.entwickler.dotnet.vc
Vielen Dank

Richard Kaiser

Feb 28 '06 #8
Hallo R!
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResult".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.


It is a member of the "Form"-class:
http://msdn2.microsoft.com/en-us/lib...logresult.aspx

Also in the example they use
::DialogResult::OK
as a shortcut... but it does not compile...

Maybe there is a shorted way; but I do not know it currently...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #9
Jochen Kalmbach [MVP] schrieb:
Hallo R!
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResult".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.


It is a member of the "Form"-class:
http://msdn2.microsoft.com/en-us/lib...logresult.aspx
Also in the example they use
::DialogResult::OK
as a shortcut... but it does not compile...

Maybe there is a shorted way; but I do not know it currently...


Vielen Dank
Richard Kaiser
Feb 28 '06 #10
Regarding the scope of identifiers, C++/CLI is very picky. You are probably
facing a problem related to this. Check if you have defined something (e. g.
a member of your class) "DialogResult". This can easily cause such a
problem.

Here is another example:

#using "System.Drawing.dll"
using namespace System::Drawing;
ref struct X
{
property Size Size
{
// the line below fails even though the namespace System::Drawing is
opened
Size get() // type name Size conficts with property name Size
{
return Size();
}
// workaround
// System::Drawing::Size get() // type name Size conficts with property
name Size
// {
// return System::Drawing::Size();
// }
}
};

Marcus Heege

This code is untested. Please test it

"rk" <rk@invalid.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Jochen,

I had added

using namespace System::Windows::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

and

using namespace System::Windows::Forms;
if (openFileDialog1->ShowDialog()==DialogResult::OK)

should be equivalent. So I would expect it to be a bug if they are not.

Or not?

Richard
Jochen Kalmbach [MVP] schrieb:
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog1->ShowDialog()==
DialogResult::OK)

However, this does not work, and I have to use:

if (openFileDialog1->ShowDialog()==
System::Windows::Forms::DialogResult::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows::Forms;

at the top (or at least before you use the above code).
Or did I miss something in your post?

Feb 28 '06 #11
Hi Marcus!
Regarding the scope of identifiers, C++/CLI is very picky. You are probably
facing a problem related to this. Check if you have defined something (e. g.
a member of your class) "DialogResult". This can easily cause such a
problem.


Have you a pointer to the docu???
Because the same code works perfectly in VS2003...

By the way: The member "DialgResult" is defined in
"System::Windows::Forms::Form"... so the problem occurs in *every*
Form-derived class.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Mar 1 '06 #12

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

Similar topics

5
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
2
by: steve bull | last post by:
I have built what I think should be a dialog box. It contains 4 tabbed panes for generating a range of colors. Each tabbed pane consists of a panel with all the widgets on them including the OK and...
7
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In...
2
by: dm1608 | last post by:
I'm opening my own form and doing something like: If dlgDirectory.ShowDialog() = DialogResult.OK Then .... End If When I compile the project, I can a warning for the line saying: Access of...
8
by: BK | last post by:
Converting a rather large solution from 2003 to 2005. All the errors are worked out, but I'm trying to clean up the warnings as best I can. The good news is that the application and it's...
1
by: Bill Cart | last post by:
I am trying to work with 2 forms. If I set the ModalResult of a button on the 2nd form it works OK. If I try to assign the result and then return it does not return the value I set. 1st Form...
7
by: Masterfrier | last post by:
Hi there! in my app, i open a Dialog, in this dialog i use the FileOpenDialog, when i click on 'Ok' or 'Cancel' in my FileOpenDialog, it automatically closes the parent dialog, with a...
2
by: WP | last post by:
Hello, I making and Windows Forms program and I have a dialog with two buttons. I have set the DialogResult property for these buttons to DialogResult.OK and DialogResult.No, respectively (however,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.