|
How can i limit my app to one instance?
|
|
|
|
|
Search for "single instance" or "one instance" on this site. You will get lots of results.
|
|
|
|
|
Thanks, Found with mutex method.
ps: I did search, but with wrong keywords
|
|
|
|
|
hi,
i would like to hide(or rather, to have the form disappear) after a new form has been created after clicking on "new" in the menustrip.
please help!
my codes thus far:
private: System::Void newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Form1^ newForm = gcnew Form1();
newForm->ShowDialog();
|
|
|
|
|
mactick wrote: i would like to hide(or rather, to have the form disappear) after a new form has been created after clicking on "new" in the menustrip.
Prety easy:
mactick wrote: Form1^ newForm = gcnew Form1();
this->Visible = false; // Hide current form
newForm->ShowDialog();
this->Visible = true; // show current form
|
|
|
|
|
if i wish to close the old form instead of hiding it after a new one has been created, how do i do that? 
|
|
|
|
|
Form1^ newForm = gcnew Form1();
newForm->Show(); //ShowDialog is opening modal window, It won't contiune execution Unless it isn't modal.
this->Close();
|
|
|
|
|
|
Hi all,
I have a form called: Form1 (Form1.h) and another form called: add_key_Value (add_key_Value.h)
Now I want to show the form add_key_Value:
So I include the header file add_key_Value.h in the Form1.h
And perform the following code:
add_Key_Value^ form2 = gcnew add_key_Value;
form2->Show();
Now in the add_key_value form I want to access the members of Form1:
So I include the header file Form1.h in the add_key_Value.h
And perform the following code: (ERRORS)
Form1^ mainform = gcnew Form1;
mainform->edtTextBox->Text = "Just testing";
Errors:
Error 3 error C2065: 'Form1' : undeclared identifier c:\documents and settings\qx55246\my documents\visual studio 2005\projects\cnfedtctrl\cnfedtctrl\add_key_Value.h 231
Error 4 error C2065: 'mainform' : undeclared identifier c:\documents and settings\qx55246\my documents\visual studio 2005\projects\cnfedtctrl\cnfedtctrl\add_key_Value.h 231
Error 6 error C2227: left of '->edtTextBox' must point to class/struct/union/generic type c:\documents and settings\qx55246\my documents\visual studio 2005\projects\cnfedtctrl\cnfedtctrl\add_key_Value.h 232
Can anyone please help ???
Many Thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
You have a circular reference of header files
Form1.h includes add_key_value.h which includes Form1.h which includes add_key_value.h etc etc etc
Split your implementation into .h and .cpp files and use a forward declaration so you can use typename^ in the header file
Form1.h
#include "add_key_value.h"
...
add_Key_Value^ form2 = gcnew add_key_Value(this);
form2->Show();
add_key_value.h
class Form1;
public ref class add_key_value.....
{
public:
add_key_value(Form1^ mainForm);
private:
Form1^ mainForm;
}
add_key_value.cpp
#include "Form1.h"
add_key_value::add_key_value(Form1 ^ mainForm)
{
this.mainForm = mainForm;
}
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
You can't do it in that way.
in add_keyValue.h:
you have Form1 ^mainForm;
but to able to declare that, you have to use #Inlcude "Form1.h"
but in Form1.h you must have #include "add_keyValue.h". So you woud have compile error. If in theorey, compiler coud run to infinitive loop
|
|
|
|
|
|
First Thing, it shoud be:
add_Key_Value^ form2 = gcnew add_key_Value();
Form1^ mainform = gcnew Form1();
Second, you can't create a new instance of a parrent form. With an include, it coud get theoretical to infinitive loop.
Consider the folowing example:
core.h
#ifndef _CORE_H_
#define _CORE_H_
public ref class Core
{
public:
Core()
{
test = gcnew String("");
}
public: String ^test;
};
#endif //_CORE_H_
Form1.h
#include "core.h"
public: Core ^core;
core = gcnew Core();
add_Key_Value^ form2 = gcnew add_key_Value();
form2->core = this->core;
form2->Show();
MessageBox::Show(core->test);
add_key_Value.h
#include "core.h"
public: Core ^core;
core->test = "Just testing";
|
|
|
|
|
Thanx for the help.... I'll try it ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
Hello,
I have a native MFC dll which I need to access from the C# application.
I have written a managed C++ wrapper for this dll.My wrapper is a class library project.
The native dll(MFC dll) basically opens a MFC CArchive serialized file and deserializes it.
My c# app needs to access the data in this MFC CArchive.
I pass the filename as parameter to the native Dll member function which should open it and deserialize it.
However,when ever I try to call this function from the C# app -> managed c++ wrapper,the "CFile.Open' fails.On the other hand,the same file is successfully opened when other MFC apps call this native dll.
I have checked if the filename(parameter for the Load function in the native dll) is correctly received in the native dll and it is correct.
Any suggestions/pointers on what the problem mite be would be really appreciated.
Thanks
Madhuchhanda
|
|
|
|
|
G'Day to all,
I am in the process of creating a console application using Visual C++ 2005. This application will start NOTEPAD.EXE then will need to simulate keyboard strokes to access the menu options.
I have been able to create the process and run NOTEPAD from my console app but unsure how I now access the menu options.
I have started the process by:
Process^ p = gcnew Process();
p->StartInfo->FileName = "NOTEPAD.EXE";
p->StartInfo->UseShellExecute = true;
p->Start();
I would now assume I would have to use the following namespace:
using namespace System::Windows::Forms;
But come compile time the above namespace is rejected: error C3083: 'Windows': the symbol to the left of a '::' must be a type
Am I on the right track here or is there a better way to achieve what I am trying to do to access an applications menus ?
|
|
|
|
|
G'day mate
you need to add a reference to System.Windows.Forms to your project
Right click the project in VS and select References....
Like I said to you the other day, you can get a HWND from the process object and use Win32 or MFC to send WM_* messages to the notepad window
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
[^]
After reading the link above I created a Bridge to be able to call a .NET
assembly and it worked with a unmanged tesp app. But when I try to use the bridge via an Unmanaged dll the dll will not load giving the error loadLibrary(): "Invalid access to memory location". What do I need to do to make this bridge work with my DLL as it works w/ my test app.
Jose Viveiros
|
|
|
|
|
I woud like to know how to focus on the specific tab?
Thanks in advance
|
|
|
|
|
Already found it:
tabControl->SelectedTab = tabPage;
|
|
|
|
|
1. I have a mixed mode program (managed + unmanaged). Some where in the program i do this to get the HWND of a picture box which is passed to an unmanaged function.
HWND hwnd = (HWND) pbSurfaceLeft->Handle.ToPointer();
Do i have to release the HWND when i'm done using it? If so, how to do in C++/CLI?
2. This is not a C++/CLI question, but it is related anyway, so i'll post it here.
Imagine i have a function
void Draw (CDC *pDC);
and i call it this way
Draw(this->GetDC());
Do i have to call ReleaseDC after that? If so how? I didnt save the pointer of GetDC(), as it was only passed directly.
3. When compiling with warning level 4, all unreferenced formal parameters are warned. How can i avoid that by adding code rather than using #pragma disable?
eg.
System::Void pbSurfaceRight_MouseLeave(System::Object^ sender, System::EventArgs^ e)<br />
Thanks
|
|
|
|
|
Hi,
Looks like don’t create those window and device context. Don’t delete them.
Regrads
|
|
|
|
|
uus831 wrote: 1. I have a mixed mode program
(managed + unmanaged). Some where in the program i do this to get the HWND of a picture box which
is passed to an unmanaged function.
HWND hwnd = (HWND) pbSurfaceLeft->Handle.ToPointer();
Do i have to release the HWND when i'm done using it? If so, how to do in C++/CLI?
Probably not. The HWND is managed by the pbSurfaceLeft object.
uus831 wrote: 2. This is not a C++/CLI question, but
it is related anyway, so i'll post it here.
Imagine i have a function
void Draw (CDC *pDC);
and i call it this way
Draw(this->GetDC());
Do i have to call ReleaseDC after that? If so how? I didnt save the pointer of GetDC(), as it was
only passed directly.
Yes you do have to call ReleaseDC, since the CDC destructor uses ::DeleteDC() which is not
correct for HDCs obtained with GetDC:
CDC *pDC = GetDC();
Draw(pDC);
ReleaseDC(pDC);
uus831 wrote: 3. When compiling with warning level
4, all unreferenced formal parameters are warned. How can i avoid that by adding code rather than
using #pragma disable?
Here's one way:
System::Void pbSurfaceRight_MouseLeave(System::Object^ sender, System::EventArgs^ /*e*/)
and another
System::Void pbSurfaceRight_MouseLeave(System::Object^ sender, System::EventArgs^)
|
|
|
|
|
Thanks, that helped! 
|
|
|
|