Candidate Functions not availible error

Hi All,

Basically what I'm trying to do here is to make a customizable message box form that is contained within a header. For ease, I designed and tested the form using the VC++.net form templates and then and then ported the code into its own specially designed header, except this time, its giving the error:

Custom.h(278): error C3767: 'Custom::MsgBoxUI::MsgBoxUI': candidate function(s) not accessible

The form class is shown below (Most of the components have not been coded in yet)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;		
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	
	public ref class MsgBoxUI : public System::Windows::Forms::Form {		
		System::Windows::Forms::Label^ label;
		System::Windows::Forms::Button^ button1;
		System::Windows::Forms::Button^ button2;
		System::Windows::Forms::Button^ button3;
		System::ComponentModel::Container^ components;

		MsgBoxUI(std::string title, std::string caption, std::string b1txt, std::string b2txt, std::string b3txt, char icon){
			initComponents(title,caption,b1txt,b2txt,b3txt,icon);
		};
		~MsgBoxUI(){			
			if (components){
				delete components;
			}
		}
		void initComponents(std::string title, std::string caption, std::string b1txt, std::string b2txt, std::string b3txt, char icon){
			//
			// System
			//
			this->label = (gcnew System::Windows::Forms::Label());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// label
			// 
			this->label->AutoSize = true;
			this->label->Location = System::Drawing::Point(12, 9);
			this->label->Name = L"label";
			this->label->Size = System::Drawing::Size(30, 13);
			this->label->TabIndex = 1;
			this->label->Text = Custom::ConvertString(caption);
			// 
			// InputBox
			// 
			//this->AcceptButton = this->bOk;
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			//this->CancelButton = this->bCancel;
			this->ClientSize = System::Drawing::Size(284, 101);
			this->Controls->Add(this->label);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
			//this->MaximizeBox = false;
			this->Name = L"MsgBoxUI";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = Custom::ConvertString(title);
			this->TopMost = true;
			this->ResumeLayout(false);
			this->PerformLayout();
		}
		int returnValue(){
			return 0;
		}
	};


Then the form is called from the code;
1
2
3
4
5
6
	int MsgBox(System::Windows::Forms::Form^ parentForm){
		parentForm->Enabled = false;
		Custom::MsgBoxUI^ msgbox = gcnew Custom::MsgBoxUI("Title","Caption","Ok",NULL,NULL,NULL);
		msgbox->ShowDialog(); // Line 278
		parentForm->Enabled = true;
	}


Thanks for any help!
It looks like you are passing the last three parameters as NULL, which doesn't make an sense as two of the three are supposed to be std::strings.
Unfortunately, calling the function with actual values still gives the same error.
Ah, got my answer: I didn't realise that when definising a public class, the constructors and functions aren't automatically declared as public. So;
1
2
3
4
5
6
7
8
                MsgBoxUI(std::string title, std::string caption, std::string b1txt, std::string b2txt, std::string b3txt, char icon){
			initComponents(title,caption,b1txt,b2txt,b3txt,icon);
		};
		~MsgBoxUI(){			
			if (components){
				delete components;
			}
		}

Was changed to;
1
2
3
4
5
6
7
8
9
10
        Public:
                MsgBoxUI(std::string title, std::string caption, std::string b1txt, std::string b2txt, std::string b3txt, char icon){
			initComponents(title,caption,b1txt,b2txt,b3txt,icon);
		};
        Protected:
		~MsgBoxUI(){			
			if (components){
				delete components;
			}
		}


The only remaining issue is that its thrown a few LNK2005 errors to fix
*Edit* These issues churned up because in the int MsgBox(){} function declared and defined a variable in the header, which is not allowed. I just moved the content of the function to the relevant Cpp file and it worked fine.
Last edited on
Topic archived. No new replies allowed.