|
Hi to all, I'm new to vc++ and I've read a bit on how to create a new form and load it (make it appear on screen). But i have this code and its corresponding error and would be glad if someone could point me in the right direction.
There's three forms, Form1 (login form) and gymMain a main interface. So what I tried to do is first load the application with gymMain and make its Visible state FALSE, next load Form1 (login) and upon confirmation of input, close Form1 and make gymMain visible. Now I try this with the below code and the erorr is shown below. All help/suggestions appreaciated.
regards
PS: I'm prety sure I used the header files appropriately but one never knows, ...
--------------------------
code for Main application:
--------------------------
// GymManager.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
#include "gymMain.h"
#include "NewMember.h"
#include "search.h"
using namespace GymManager;
//using namespace Form1;
//using namespace gymMain;
//using namespace NewMember;
//using namespace search;
[STAThreadAttribute]
int main(array<system::string ^=""> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew gymMain());
return 0;
}
----------------------------------------
code for gymMain:
----------------------------------
#pragma once
#include "NewMember.h"
#include "Form1.h"
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::Globalization;
using namespace GymManager;
namespace GymManager {
///
/// Summary for gymMain
///
/// 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.
///
public ref class gymMain : public System::Windows::Forms::Form
{
public:
gymMain(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///
~gymMain()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::MenuStrip^ menuStrip1;
protected:
private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ logOutToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ backupDBToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ backupNowToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ restoreToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ howToToolStripMenuItem;
private: System::Windows::Forms::Button^ btnNewM;
private: System::Windows::Forms::Button^ btnSearch;
private: System::Windows::Forms::Button^ btnViewH;
private: System::Windows::Forms::Button^ btnCancelM;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ lDateShow;
private: System::Windows::Forms::Button^ btnGymU;
private:
///
/// Required designer variable.
///
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->logOutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->backupDBToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->backupNowToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->restoreToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->howToToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->btnNewM = (gcnew System::Windows::Forms::Button());
this->btnSearch = (gcnew System::Windows::Forms::Button());
this->btnViewH = (gcnew System::Windows::Forms::Button());
this->btnCancelM = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->lDateShow = (gcnew System::Windows::Forms::Label());
this->btnGymU = (gcnew System::Windows::Forms::Button());
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->fileToolStripMenuItem,
this->backupDBToolStripMenuItem, this->helpToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(483, 24);
this->menuStrip1->TabIndex = 0;
this->menuStrip1->Text = L"menuStrip1";
//
// fileToolStripMenuItem
//
this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->logOutToolStripMenuItem,
this->exitToolStripMenuItem});
this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
this->fileToolStripMenuItem->Size = System::Drawing::Size(35, 20);
this->fileToolStripMenuItem->Text = L"&File";
//
// logOutToolStripMenuItem
//
this->logOutToolStripMenuItem->Name = L"logOutToolStripMenuItem";
this->logOutToolStripMenuItem->Size = System::Drawing::Size(132, 22);
this->logOutToolStripMenuItem->Text = L"&LogOut...";
//
// exitToolStripMenuItem
//
this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
this->exitToolStripMenuItem->Size = System::Drawing::Size(132, 22);
this->exitToolStripMenuItem->Text = L"E&xit";
//
// backupDBToolStripMenuItem
//
this->backupDBToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->backupNowToolStripMenuItem,
this->restoreToolStripMenuItem});
this->backupDBToolStripMenuItem->Name = L"backupDBToolStripMenuItem";
this->backupDBToolStripMenuItem->Size = System::Drawing::Size(69, 20);
this->backupDBToolStripMenuItem->Text = L"Backup &DB";
//
// backupNowToolStripMenuItem
//
this->backupNowToolStripMenuItem->Name = L"backupNowToolStripMenuItem";
this->backupNowToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->backupNowToolStripMenuItem->Text = L"&Backup Now...";
//
// restoreToolStripMenuItem
//
this->restoreToolStripMenuItem->Name = L"restoreToolStripMenuItem";
this->restoreToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->restoreToolStripMenuItem->Text = L"&Restore";
//
// helpToolStripMenuItem
//
this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->aboutToolStripMenuItem,
this->howToToolStripMenuItem});
this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";
this->helpToolStripMenuItem->Size = System::Drawing::Size(40, 20);
this->helpToolStripMenuItem->Text = L"&Help";
//
// aboutToolStripMenuItem
//
this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
this->aboutToolStripMenuItem->Size = System::Drawing::Size(131, 22);
this->aboutToolStripMenuItem->Text = L"&About...";
//
// howToToolStripMenuItem
//
this->howToToolStripMenuItem->Name = L"howToToolStripMenuItem";
this->howToToolStripMenuItem->Size = System::Drawing::Size(131, 22);
this->howToToolStripMenuItem->Text = L"Ho&w to...";
//
// btnNewM
//
this->btnNewM->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Center;
this->btnNewM->Location = System::Drawing::Point(15, 121);
this->btnNewM->Name = L"btnNewM";
this->btnNewM->Size = System::Drawing::Size(153, 57);
this->btnNewM->TabIndex = 2;
this->btnNewM->Text = L"New Member";
this->btnNewM->UseVisualStyleBackColor = true;
this->btnNewM->Click += gcnew System::EventHandler(this, &gymMain::btnNewM_Click);
//
// btnSearch
//
this->btnSearch->Location = System::Drawing::Point(188, 121);
this->btnSearch->Name = L"btnSearch";
this->btnSearch->Size = System::Drawing::Size(153, 57);
this->btnSearch->TabIndex = 3;
this->btnSearch->Text = L"Search Member";
this->btnSearch->UseVisualStyleBackColor = true;
//
// btnViewH
//
this->btnViewH->Location = System::Drawing::Point(15, 193);
this->btnViewH->Name = L"btnViewH";
this->btnViewH->Size = System::Drawing::Size(153, 57);
this->btnViewH->TabIndex = 4;
this->btnViewH->Text = L"View History";
this->btnViewH->UseVisualStyleBackColor = true;
//
// btnCancelM
//
this->btnCancelM->Location = System::Drawing::Point(188, 193);
this->btnCancelM->Name = L"btnCancelM";
this->btnCancelM->Size = System::Drawing::Size(153, 57);
this->btnCancelM->TabIndex = 5;
this->btnCancelM->Text = L"CancelMembership";
this->btnCancelM->UseVisualStyleBackColor = true;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"MS Reference Sans Serif", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<system::byte>(0)));
this->label2->Location = System::Drawing::Point(12, 54);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(389, 26);
this->label2->TabIndex = 6;
this->label2->Text = L"Welcome to Personal Gym Manager";
//
// lDateShow
//
this->lDateShow->AutoSize = true;
this->lDateShow->Location = System::Drawing::Point(323, 35);
this->lDateShow->Name = L"lDateShow";
this->lDateShow->Size = System::Drawing::Size(78, 13);
this->lDateShow->TabIndex = 7;
this->lDateShow->Text = L"Time and date:";
//
// btnGymU
//
this->btnGymU->Location = System::Drawing::Point(364, 122);
this->btnGymU->Name = L"btnGymU";
this->btnGymU->Size = System::Drawing::Size(86, 127);
this->btnGymU->TabIndex = 8;
this->btnGymU->Text = L"Gym Usage";
this->btnGymU->UseVisualStyleBackColor = true;
//
// gymMain
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->ClientSize = System::Drawing::Size(483, 266);
this->Controls->Add(this->btnGymU);
this->Controls->Add(this->lDateShow);
this->Controls->Add(this->label2);
this->Controls->Add(this->btnCancelM);
this->Controls->Add(this->btnViewH);
this->Controls->Add(this->btnSearch);
this->Controls->Add(this->btnNewM);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->MaximizeBox = false;
this->Name = L"gymMain";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Main Menu - Gym Manager";
this->Load += gcnew System::EventHandler(this, &gymMain::gymMain_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void btnNewM_Click(System::Object^ sender, System::EventArgs^ e) {
// gymMain::Visible = false;
// GymManager::NewMember ^newM = gcnew GymManager::NewMember;
// newM->Show();
}
private: System::Void gymMain_Load(System::Object^ sender, System::EventArgs^ e) {
//load login page and make main page invisible
this->Visible = false;
GymManager::Form1 ^login = gcnew GymManager::Form1;
login->Show();
//display clock
DateTime^ dt = DateTime::Now;
String^ date;
date = dt->ToString();
lDateShow->Text = date;
}
};
}
-------------------------------
error messages displayed:
-------------------------------
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2039: 'Form1' : is not a member of 'GymManager'
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2065: 'Form1' : undeclared identifier
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2065: 'login' : undeclared identifier
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2039: 'Form1' : is not a member of 'GymManager'
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2061: syntax error : identifier 'Form1'
c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(283) : error C2227: left of '->Show' must point to class/struct/union/generic type
type is ''unknown-type''
luhfluh
|
|
|
|
|
luhfluh wrote: c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2039: 'Form1' : is not a member of 'GymManager'
The compiler is telling you exactly what is wrong. C2039
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This question would be best answered MC++/CLI[^] forum.
luhfluh wrote: c:\documents and settings\and_one\my documents\visual studio 2005\cs208\gymmanager\gymmanager\gymMain.h(282) : error C2039: 'Form1' : is not a member of 'GymManager'
Your problem is not about headers, but I think you are relating Form1 with wrong namespace.
|
|
|
|
|
tks for ur help. bt I tried using something like below (without the GymManager namespace) and it still provded an error that said "undeclared identifier Form1"
alternative code tried:
-----------------------
Form1 ^login= gcnew Form1();
login->Show();
|
|
|
|
|
You need to use name of namespace Form1 is member of, clearly I could not see class Form1's definition in your code.
|
|
|
|
|
tks for ur reply. bt i'm still lost if u know wat i mean, If u can provide a sample code of how to use wat u r talking about it would be very helpful...
I dont know where exactly in Form1's definition i would need to put the namespace (besides I'm new to this managed c++ stuff - work better with Java)
Tks for ur help once again.
|
|
|
|
|
luhfluh wrote: tks for ur reply. bt i'm still lost if u know wat i mean, If u can provide a sample code of how to use wat u r talking about it would be very helpful...
Just take a simple form application
namespace TestForm {
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 Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
};
}
In above example TestForm is a namespace and Form1 is class.
luhfluh wrote: I dont know where exactly in Form1's definition i would need to put the namespace
You are getting it wrong. Class will be member of namespace.
luhfluh wrote: (besides I'm new to this managed c++ stuff - work better with Java)
I'm there is similar concept in Java.
|
|
|
|
|
tks, bt i think i'm just in the right frame of mind to grasp where to include it...The namespace GymManager is already defined in Form1's header, and within it there is the
prasad_som wrote: public ref class Form1 : public System::Windows::Forms::Form
details and so it is for all the other forms. So with what I understand from ur explaination the class within the namespace should be called without problems if only it is within the namespace.
prasad_som wrote: I'm there is similar concept in Java.
interfaces or abstract classes are there yes, and are similarly defined and used. but I cant get ma head around this.
tks anyway.
|
|
|
|
|
Yep - comparing that code to the stuff I have had to write in the past to do something similar with good old MFC, I can see the improvement...
Yep! Gotta love progress...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
What happens to your problem here[^] . Interesting to see, does your prblem was same as guessed
|
|
|
|
|
I want to override the cursor icon globally. My application captures the mouse input and I track mouse movements. I also set a new icon image. When the mouse icon leaves the boundaries of my application window, the cursor changes back to the default. I want to have control over the icon globally for a short period in my program. Is this possible?
http://www.asura.co.uk
|
|
|
|
|
Hello
I have an application running in XP win32 version, and I have built it for XP64, somethings work fine, but other windows shutdown the application suddenly in release but if I try to use it in debug mode always redirect me to msvcrt.dll,
The version of the dll that the application is using (is located in its bin) is 6.0.8397, but when it stops in debug the version is the one of Microsoft ..\WINDOWS\system32\msvcrt.dll 7.0.2600.2180
Has anybody the same problem?
Thanks in advance
|
|
|
|
|
I have to create a line graph on a tabbed dialog. I am a beginner. I have searched the Internet, but I am not sure how to start. Can someone direct me in the right direction?
Thanks
Trevy
|
|
|
|
|
You can take a look at the link in my signature. This is a chart control that I developped and maybe it will be helpfull for you.
|
|
|
|
|
Hi!
I've created a single dialog based application using MFC application wizard.
I am using a textbox in that dialogbox now i want to trap when Enter key pressed
in textbox,but when i pressed enter key the application ends.why? and what is the
solution?
Viral Joshi
|
|
|
|
|
viral_umang@hotmail.com wrote: I am using a textbox in that dialogbox now i want to trap when Enter key pressed
in textbox...
Does the edit control have the ES_WANTRETURN style?
viral_umang@hotmail.com wrote: ...but when i pressed enter key the application ends.why?
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David.
This is working fine.Thank you for coordination.
Viral Joshi.
|
|
|
|
|
viral_umang@hotmail.com wrote: Thank you for coordination.
You're welcome. I'm glad I could cooperate with you.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I need copy an exe file when a button on my application is pressed.
I have created a resource by importing that exe.
insert->resource->import...
Now how can i get that file from the resource id and copy that into another location?
Is there a way?
Thank u.
KIRAN PINJARLA
|
|
|
|
|
Something like this, perhaps?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
struck here.
hResource = FindResource(NULL, MAKEINTRESOURCE(IDR_EXE1), RT_RCDATA);
if (NULL != hResource)
{
hResourceLoaded = LoadResource(NULL, hResource);
if (NULL != hResourceLoaded)
{
lpBuffer = (LPBYTE) LockResource(hResourceLoaded);
if (NULL != lpBuffer)
{
}
}
}
I have loaded my one.exe into a resource with id IDR_EXE1 using wizard. now when im trying it with FindResource() it returning NULL. where is the problem?
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: ...FindResource() it returning NULL. where is the problem?
If the function fails, the return value is NULL . To get extended error information, call GetLastError() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You don't create the resource of that file.
The problem is solved with the file reading and writing in binary mode.
as the path of your source exe file and destination file is fixed.
Just open the file in binary mode using ifstream and read it byte by byte
after reading flush the byte array to destination file using ofstream.
|
|
|
|
|
I dont want to take that exe every time with my project exe. I want to integrate that exe with the project exe.
KIRAN PINJARLA
|
|
|
|