Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > folderBrowserDialog как использовать?


Автор: Mr_Nuke 8.6.2012, 21:59
Всем привет! Столкнулся с проблемой, казалось бы на пустом месте! 

Пишу на C++, хочу вызвать folderBrowserDialog

Нашел такой примерчик, похожий на правдоподобный
Код

if (folderBrowserDialog1->ShowDialog() == DialogResult::OK){}

но вылетает ошибка:
'OK' : is not a member of 'System::Windows::Forms::Form::DialogResult'



Автор: Cheloveck 8.6.2012, 23:08
Учимся пользоваться гуглом!
http://msdn.microsoft.com/en-us/library/system.windows.forms.dialogresult.aspx#Y209
Код

         if ( result == ::DialogResult::Yes )
         {
            // Closes the parent form.
            this->Close();
         }


Добавлено через 1 минуту и 40 секунд
 smile 
Цитата(Mr_Nuke @  8.6.2012,  22:59 Найти цитируемый пост)
Пишу на C++

Не на C++ ты пишешь...

Автор: Mr_Nuke 8.6.2012, 23:22
Цитата(Cheloveck @ 8.6.2012,  23:08)
Не на C++ ты пишешь...

В каком это смысле??  smile 

Так, как ты написал, тоже пробовал - ошибка! Решение нашел все-же в гугле, но вот по этой ссылке: http://social.msdn.microsoft.com/Forums/eu/Vsexpressinstall/thread/c97c2d37-c56a-4213-a889-4cc9e2ca259c

Скопирую сюда, мало ли, кому понадобится:

Цитата

Hi I'm working with C++ Express, I'm new to Windows Forms and the namespaces used but not to C++. I'm having difficulties with DialogResults:

The MSDN documentation gives examples like this:

System::Windows::Forms::DialogResult result;
result = MessageBox::Show( this, message, caption, buttons );
if ( result == ::DialogResult::Yes )

Yet when I compile I get the following errors (for the if line) :


error C3083: 'DialogResult': the symbol to the left of a '::' must be a type
error C2039: 'Yes' : is not a member of '`global namespace''
error C2065: 'Yes' : undeclared identifier
So I also try without the leading :: and get:


error C2039: 'Yes' : is not a member of 'System::Windows::Forms::Form::DialogResult'
see declaration of 'System::Windows::Forms::Form::DialogResult'
error C2065: 'Yes' : undeclared identifier
Finally I try with the whole namespace (is that the right terminology ?) and it compiles:


if (result == System::Windows::Forms::DialogResult::Yes )


Answer:

Цитата

Make sure you have both the #using and the using namespace directives to ensure the compiler understands your references.

For example - 

#using <System.DLL>
#using <System.Drawing.DLL>
#using <System.Windows.Forms.DLL>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

Автор: volatile 8.6.2012, 23:28
Цитата(Mr_Nuke @  8.6.2012,  23:22 Найти цитируемый пост)
#using

В С/С++ нет таких директив.

Автор: Mr_Nuke 8.6.2012, 23:31
Ну второй вариант не пробовал, довольствуюсь вот этим:
Код

if (result == System::Windows::Forms::DialogResult::Yes )

Автор: Cheloveck 8.6.2012, 23:39
Цитата(Mr_Nuke @  9.6.2012,  00:22 Найти цитируемый пост)
В каком это смысле??  

Managed C++ != C++
 smile 

Автор: borisbn 9.6.2012, 10:31
Цитата(Cheloveck @  8.6.2012,  23:39 Найти цитируемый пост)
Managed C++ != C++


error: no match for 'operator!=' in expression: '.Net only M$ only language' != 'crosscompile, crossplatform the good old C++'
 smile 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)