Embedding bmp resource into program

Hello I seem to be having some problems with my program I am attempting to build.I have been searching for roughly 2 days now and to no avail I am trying to embed a .bmp file into a program so that a login button will change when clicked and hovered over.Keep in mind the fact that I am a novice programmer so the code may be a bit messy also I have using the .net framework windows form template.
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
	#include "resource.h"



namespace Green {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Reflection;
	using namespace System::Resources;
	using namespace System::IO;



	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  Login;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Label^  Error;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->Login = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->Error = (gcnew System::Windows::Forms::Label());
			this->SuspendLayout();
			// 
			// Login
			// 
			this->Login->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"Login.BackgroundImage")));
			this->Login->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
			this->Login->Location = System::Drawing::Point(102, 227);
			this->Login->Name = L"Login";
			this->Login->Size = System::Drawing::Size(75, 23);
			this->Login->TabIndex = 0;
			this->Login->UseVisualStyleBackColor = true;
			this->Login->MouseLeave += gcnew System::EventHandler(this, &Form1::M1Leave_login);
			this->Login->Click += gcnew System::EventHandler(this, &Form1::Login_Click);
			this->Login->MouseEnter += gcnew System::EventHandler(this, &Form1::M1Enter_login);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(1, 9);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(64, 13);
			this->label1->TabIndex = 1;
			this->label1->Text = L"Error Report";
			// 
			// Error
			// 
			this->Error->AutoSize = true;
			this->Error->BackColor = System::Drawing::SystemColors::Control;
			this->Error->ForeColor = System::Drawing::Color::Red;
			this->Error->Location = System::Drawing::Point(1, 32);
			this->Error->Name = L"Error";
			this->Error->Size = System::Drawing::Size(33, 13);
			this->Error->TabIndex = 2;
			this->Error->Text = L"None";

			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Controls->Add(this->Error);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->Login);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void Login_Click(System::Object^  sender, System::EventArgs^  e) { 


				

				 try
				 {
					 Green::Form1::Login->BackgroundImage = Image::FromFile("Res\\LoginC.bmp");
				 }
				 catch(Exception ^e)
				 {
					 ::Green::Form1::Error->Text = "FILE NOT FOUND ERROR,CATCH ACTIVATED";
				 }
				 

			 }
			 
	private: System::Void M1Enter_login(System::Object^  sender, System::EventArgs^  e) {
			 
			 }
	private: System::Void M1Leave_login(System::Object^  sender, System::EventArgs^  e) {
			 
			 }
};
}

Here is my app.rc
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
63
64
65
66
67
68
69
70
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
1                       ICON                    "app.ico"

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
    "\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

IDB_BITMAP1             BITMAP                  "C:\\Users\\Inferno\\Pictures\\LoginNC.bmp"
IDB_BITMAP2             BITMAP                  "C:\\Users\\Inferno\\Pictures\\LoginH.bmp"
IDB_BITMAP3             BITMAP                  "C:\\Users\\Inferno\\Pictures\\LoginC.bmp"
#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////





And my resource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc
//
#define IDB_BITMAP1                     108  
#define IDB_BITMAP2                     109
#define IDB_BITMAP3                     110

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        111
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif 







If anyone could help me that would be great.
Thank you
In c++ you just need to call LoadBitmap() api using MAKEINTRESOURCE(IDB_BITMAP1) as second argument. Dont forget to call DeleteObject() on the resulting handle to free it after you using.
I am not familiar with .net framework crap and this is a c++ forum after all.
I was under the impression the .net was a framework or template for C++,C# or VB either way I did what you said and I am still getting an error
Error	1	error C2664: 'System::Windows::Forms::Control::BackgroundImage::set' : cannot convert parameter 1 from 'HBITMAP' to 'System::Drawing::Image ^'	c:\users\inferno\documents\visual studio 2008\projects\green\green\Form1.h	133	Green
Topic archived. No new replies allowed.