|
If you derive xyz from save, and save is a form, then xyz is a form too.
Is that really what you want?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
savitri wrote: they wrote like this. partial class save: public xyz{ //code here}.
Is this C#? If yes, it is not valid/ Like c++, you don't specify access modifiers when inheriting.
savitri wrote: Like this how can i write in vc.net
AFAIK, C++/CLI doesn't support partial classes.
You said XYZ is a normal class and Save is a windows form. If yes, how can Save derive from XYZ ? It has to derive from System::Windows::Forms::Form or it's children.
savitri wrote: is der another way to access one class into other class. Please help me out.
You have to include classes header file and use it. What is the confusion here? Your question is not clear enough to answer.
|
|
|
|
|
Hi,
Ya i have to include header files to access the functions and variables of that class. thanks for ur guidance. I got the soft copy of that book what u specified in previous reply.
In VC.NET i have 2 windows forms Called Form1 and Form2.
I am including form2.h in form1 and accessing all the functions of form2.
But when i am including form1.h in form2 then i am getting error and not able to access the functions.
After that i did like this.
ref class form1;and created object of form1 in form2 constructor and when i called form2 frm=gcnew form2(this);
and also i am getting error like base class undefined for this code public ref class form2: form1
{//code here
}
Sorry if i written something wrong.I am new to this .net.Please help me to learn this.
Thanks in advance.
Regards,
Savitri P
|
|
|
|
|
Can you post code for Form1 and Form2?
|
|
|
|
|
Hi Navaneeth,
I am writing here code of form1 and form2.
form1.h
#pragma once
#include "AboutApp.h"
#include "LoginForm.h"
#using <mscorlib.dll>
namespace NewMDIApp {
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::Runtime::InteropServices;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->AccessibleRole = System::Windows::Forms::AccessibleRole::MenuBar;
this->AllowDrop = true;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(1017, 700);
this->Controls->Add(this->statusBar1);
this->Controls->Add(this->statusStrip1);
}
#pragma endregion
public:
[DllImport("user32.dll",EntryPoint="GetKeyState")]
static int GetKeyState(int keyCode);
[DllImport("user32.dll",EntryPoint="keybd_event")]
static void keybd_event(Byte bVk, Byte bScan, UInt16 dwFlags, int dwExtraInfo);
public: static LoginForm^ lgFrm=gcnew LoginForm;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->UpdateKey();
AboutApp^ app=gcnew AboutApp(this);
app->txtUsr->Text="Savitri";
app->Show();
}
AboutApp.h(Form2)
#pragma once
#using <mscorlib.dll>
namespace NewMDIApp {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
ref class Form1;
public ref class AboutApp : public System::Windows::Forms::Form
{
public:
AboutApp(Form1^ frm)
{
InitializeComponent();
frm1=frm;
}
protected:
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
}
#pragma endregion
private:
System::Void textBox1_TextChanged();
public:
Form1^ frm1;
private: System::Void btnLogin_Click(System::Object^ sender, System::EventArgs^ e) {
String ^username,^password;
username=txtUsr->Text->ToString();
password=txtPwd->Text->ToString();
MessageBox::Show(username);
MessageBox::Show(password);
if(username->Equals("Savitri") && password->Equals("Pramod"))
{
MessageBox::Show("SuccessFully Logged in");
textBox1_TextChanged();
}
else
{
MessageBox::Show("Not valid UserName and Password");
}
}
AboutApp.Cpp
#include "StdAfx.h"
#include "AboutApp.h"
#include "Form1.h"
System::Void NewMDIApp::AboutApp::textBox1_TextChanged(){
if(frm1 != nullptr)
frm1->GetValues(txtUsr->Text,txtPwd->Text);
}
Please give me some hints to solve this problems.
Thanks in advance.
Regards,
Savitri P
|
|
|
|
|
I am using unmanaged VC++ 6.0 console application which uses managed dlls written in C#. The VC++ application access managed dll through a interop layer written in C++/CLI. The functions in interop layer are exposed to VC++ 6.0 application by using 'extern "C"' as function library.
Everything works fine with the console application.
However when I convert the same console application to windows service using Win32 APIs StartServiceCtrlDispatcher() and RegisterServiceCtrlHandler() and ServiceMain() functions. The service created and started successfully, however when I stop the service, the application gives following error in event viewer.
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event ID: 1000
Description:
Faulting application ivrs.exe, version 0.0.0.0, stamp 4a07da05, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x00000000.
Could anybody help me in this?
|
|
|
|
|
Thanks for looking at my question!
I am trying to figure out how to determine if a user-inputted file name exists, and I am completely unsure how to do this in .net C++.
I have tried just using the C fopen code:
if (fopen(String::Concat(room, ".txt"), "r") == 0)
(room is the inputted variable name, and .txt is obviously the file extension)
But I get a "cannot convert System::String ^ to const char *" error. I am assuming this is because fopen requires a constant name like "Bedroom.txt" and wont accept a variable as part of the name, so I need help determining another way to see if a file exists.
Any help would be greatly appreciated. Thanks!
|
|
|
|
|
Try Google.[^] For this method, I believe you'll need the full path. I would also recommend reading up on the System.IO namespace.
Dybs
|
|
|
|
|
Lol thanks! I actually just did this right before you linked me.
But um, since I'm here. You wouldn't happen to know how to get the string value of a selected item in a list box would you?
|
|
|
|
|
listBox1.SelectedItem.ToString()
Dybs
|
|
|
|
|
Hmm I must be doing something wrong with a different part of my code then.
I am trying to delete a file (in the same directory as the application) with a name that is respective to whats in a list box.
For example there is a "doom.txt" file and the word "doom" in my list box. I select doom and hit the delete button and the "doom.txt" file should disappear. (what I'm doing is actually more complicated, but this is the part I'm having trouble with)
Here is what my code looks like:
if (roomList->SelectedIndex != -1 && delCheck->Checked)
{
roomList->Items->RemoveAt(roomList->SelectedItem);
File::Delete(String::Concat(Convert::ToString(roomList->SelectedValue), ".txt"));
}
Any idea what I did wrong?
Thanks for all the help
|
|
|
|
|
you're removing the selected item from the list box. Then the next line you're trying to get the selected value (which will be null because you removed it already!). String::Concat will then create a string as ".txt". Now you're trying to delete a file called ".txt" which probably doesn't exist. It probably seems like nothing is happening because from MSDN[^] it says: Deletes the specified file. An exception is not thrown if the specified file does not exist.
You could do something like this:
if (roomList->SelectedIndex > -1 && delCheck->Checked)
{
int nIndex = roomList->SelectedIndex;
String ^sFileName = (String^)roomList->Items[nIndex];
if (!File::Exists(sFileName))
throw gcnew Exception("File does not exist!");
File::Delete(sFileName);
roomList->Items->RemoveAt(nIndex);
}
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Aha I see the logic in this now. It's funny how something so fundamentally obvious can completely escape my thought process haha.
Anyway, thank you very much It appears to work now
|
|
|
|
|
I'm trying to control a website through the WebBrowser control and have the scraping and navigation sorted but have one issue to resolve.
There are radio buttons that have to be clicked on, does anyone have a suggestion on how to do this?
Thanks.
Elaine
|
|
|
|
|
Trollslayer wrote: There are radio buttons that have to be clicked on, does anyone have a suggestion on how to do this?
Do you mean you need to POST to the server? Also you are using C++/CLI for this?
|
|
|
|
|
It is to control a normal web page which has some text boxes, radio buttons and a submit button.
I'm using manged code for this.
|
|
|
|
|
|
You didn't state what you're using for UI, but if you Google
"master detail" along with your UI technology (Windows forms,
WPF, etc.) that should get you many examples...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Anybody has idea how to start specific service in remote machine using WMI C++ API.
|
|
|
|
|
|
|
Hi There.
I am not able to use C# Managed DLL into my VC++ Application (DLL).
Below are the steps I am doing but with no success.
1. Copied C# DLL into the folder where all my lib files reside.
2. Included #using :GT:JPEGMaker.dll:LT: statement into stdafx.h file
3. After this I got an error message regarding CLR Support, so I enabled the same in project settings.
4. After this I got a linking error...
:GT: Greater Then Sign
:LT: Less Then Sign
Please provide details or Do I need to convert C# DLL into Native DLL?
Thanks
PanB
|
|
|
|
|
|
I have a VC++ application(say MathApp) that does some mathematical calculations using some U/I inputs, and gives the results. I have a C# application(say ManagedApp) that wants to interact with MathApp. ManangedApp has to pass the inputs to MathApp, MathApp should perform the calculations, and give back the results to ManagedApp.
Can someone suggest different ways to accomplish the above task?
|
|
|
|
|
Rinnu Mary wrote: I have a VC++ application(say MathApp)
communicating between processes is a well known topic called Inter-Process Communication[^]
However if the MathApp code is designed well the math routines would be separated from the user interface code and they can be built into a library that can then be used by other applications at compile time. This eliminates the need to have two processes involved at runtime and therefore eliminates the IPC scenario.
After that it is a matter of dealing with the Native code to Managed code problem. This is where C++/CLI comes in. You can develop a .NET assembly (library) using C++/CLI that contains the C++ MathApp code as well as a managed class of your own design that encapsulates the native code. Once done C# projects can reference this assembly and use the managed class from it to execute the native code contained within the DLL (assembly).
|
|
|
|