473,699 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subclassing

I am looking for any information about how I could subcass a form I don't
own and resize some buttons.

We run a application which is extreamly legacy and the company has long
since went out of business. This application will install on WinXP but the
buttons on the form are smaller than they should be. I would like to hook
into this form and resize the buttons. I remember working on things like
this a few years back with VB but its been a while so any help or sites
would be appreciated.

Nov 2 '06 #1
6 1399
Its Me Ernest T. wrote:
I am looking for any information about how I could subcass a form I don't
own and resize some buttons.

We run a application which is extreamly legacy and the company has long
since went out of business. This application will install on WinXP but the
buttons on the form are smaller than they should be. I would like to hook
into this form and resize the buttons. I remember working on things like
this a few years back with VB but its been a while so any help or sites
would be appreciated.
I don't know of any sites, but what you might try is to use FindWindow
to find the window handle of the control in question such as a button.
Then use SendWindowPos api to change its size.

I'm not sure this will work and after you resize the button, if that
form is ever repainted, the button may go back to its former size.

Hope this helps a little.

Good Luck.

Nov 2 '06 #2
>I am looking for any information about how I could subcass a form I don't
>own and resize some buttons.
You probably don't need to do any subclassing just to resize controls.
You should be able to do that with the FindWindow(Ex) and MoveWindow
Win32 APIs.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 2 '06 #3
Hi,

If you want to stay in the managed arena you can get the control references by
doing the following:

class DerivedForm : ParentForm
{
public DerivedForm()
{
// assuming that one Button.Name is "button1":

Button button1 = (Button) Controls["button1"];

// and just use the reference like normal
button1.Locatio n = new System.Drawing. Point(0, 0);
}
}

If you are unsure of the names of the buttons then place a break point on the
first line and exam the Controls collection in a watch window.

Of course, I'm assuming with this code that the base constructor will have
initialized the Buttons already, which is probably good since the designer
serializes initialization into an InitializeCompo nents method that will have
executed already in common scenarios.

--
Dave Sexton

"Its Me Ernest T." <sp**@myplacein space.comwrote in message
news:C4******** **********@torn ado.southeast.r r.com...
>I am looking for any information about how I could subcass a form I don't own
and resize some buttons.

We run a application which is extreamly legacy and the company has long
since went out of business. This application will install on WinXP but the
buttons on the form are smaller than they should be. I would like to hook
into this form and resize the buttons. I remember working on things like
this a few years back with VB but its been a while so any help or sites
would be appreciated.

Nov 2 '06 #4
Dave Sexton wrote:
Hi,

If you want to stay in the managed arena you can get the control references by
doing the following:
That probably won't help the OP since he was specifically asking about
a form in another app, not created by him.

Nov 3 '06 #5
Hi Chris,

Yes, it seems that way now. I assumed that the OP might be using a Form from
a third-party assembly. "a form I don't own" is a bit vague and I read the
remainder of the post as referencing this third-party Form - a bit strange, I
know :)

--
Dave Sexton

"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Dave Sexton wrote:
>Hi,

If you want to stay in the managed arena you can get the control references
by
doing the following:

That probably won't help the OP since he was specifically asking about
a form in another app, not created by him.

Nov 3 '06 #6
Yup, you got me looking in the right place though and I have about got
exactly what I need. Thanks again.

Bryan

"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Dave Sexton wrote:
>Hi,

If you want to stay in the managed arena you can get the control
references by
doing the following:

That probably won't help the OP since he was specifically asking about
a form in another app, not created by him.

Nov 3 '06 #7

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

Similar topics

6
2730
by: WhiteRavenEye | last post by:
Why can't I subclass any window except mine in VB? Do I have to write dll for this? I've tried to subclass it with SetWindowLong but without success... Does anyone know how to subclass window ANY window in VB? Thanks...
4
1847
by: GrelEns | last post by:
hello, i wonder if this possible to subclass a list or a tuple and add more attributes ? also does someone have a link to how well define is own iterable object ? what i was expecting was something like : >>> t = Test('anAttributeValue', ) >>> t.anAttribute
2
1506
by: David Vaughan | last post by:
I'm using v2.3, and trying to write to text files, but with a maximum line length. So, if a line is getting too long, a suitable ' ' character is replaced by a new line. I'm subclassing the file class, and, as long as I just use the write method, this works fine. But "print >>" doesn't behave as I want: class max_width_file(file): def write(self, txt): print "In max_width_file's write method." fout = max_width_file('foo.txt', 'w')
2
5156
by: BJörn Lindqvist | last post by:
A problem I have occured recently is that I want to subclass builtin types. Especially subclassing list is very troublesome to me. But I can't find the right syntax to use. Take for example this class which is supposed to be a representation of a genome: class Genome(list): def __init__(self): list.__init__(self) self = ....
3
1692
by: Peter Olsen | last post by:
I want to define a class "point" as a subclass of complex. When I create an instance sample = point(<arglist>) I want "sample" to "be" a complex number, but with its real and imaginary parts computed in point()'s __init__ function with their values based on the arglist. I want to compute with point instances as though they were native complex numbers, but I want to be able to
11
3472
by: Brent | last post by:
I'd like to subclass the built-in str type. For example: -- class MyString(str): def __init__(self, txt, data): super(MyString,self).__init__(txt) self.data = data
3
1542
by: alotcode | last post by:
Hello: What is 'interprocess subclassing'? To give more context, I am writing in reference to the following remark: With the advent of the Microsoft Win32 API, interprocess subclassing was discouraged and made it a bit harder to code (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/bho.asp) Thank you for your help.
5
6487
by: Pieter Linden | last post by:
Hi, This question refers sort of to Rebecca Riordan's article on Access web about subclassing entities: http://www.mvps.org/access/tables/tbl0013.htm How practical is this? I am writing a database to track Computer equipment/inventory as well as other devices. Computers, of course, have software installed, so I want to keep track of that. I was
16
2070
by: manatlan | last post by:
I've got an instance of a class, ex : b=gtk.Button() I'd like to add methods and attributes to my instance "b". I know it's possible by hacking "b" with setattr() methods. But i'd like to do it with inheritance, a kind of "dynamic subclassing", without subclassing the class, only this instance "b" ! In fact, i've got my instance "b", and another class "MoreMethods"
5
2528
by: Ray | last post by:
Hi all, I am thinking of subclassing the standard string class so I can do something like: mystring str; .... str.toLower (); A quick search on this newsgroup has found messages by others
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.