473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Class

GTi
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Nov 17 '05 #1
3 4095
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Nov 17 '05 #2
GTi
"Ernst Kuschke (C# MVP)" <Er**************@discussions.microsoft.com> wrote
in message news:06**********************************@microsof t.com...
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Ernst,
Thanks for the example.
But do U know how I can define my class name for the window application ?
Nov 17 '05 #3

"GTi" <gt*@gti.com> wrote in message news:42********@news.wineasy.se...
"Ernst Kuschke (C# MVP)" <Er**************@discussions.microsoft.com>
wrote in message
news:06**********************************@microsof t.com...
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Ernst,
Thanks for the example.
But do U know how I can define my class name for the window application ?

You can't change the class name, this name is assigned to by the framework
class that creates the window.
Use a named mutex if you want to prevent multiple instances to run.
Something like this will do:

....
bool freeToRun;
string safeName = "Global\\StringUniquelyIdentifyingThisApplication" ;
// wrap the Mutex in a using block to prevent early clean-up of the OS mutex
handle.
using(System.Threading.Mutex m = new System.Threading.Mutex(true, safeName
, out freeToRun))
{
if (freeToRun)
{
Application.Run (new YourForm());
}
MessageBox.Show("Already running...");
}

Willy.
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
18
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
13
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes....
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
8
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.