473,748 Members | 7,377 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 1403
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
2732
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
1849
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
1509
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
5160
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
1693
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
3478
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
1546
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
6489
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
2077
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
2531
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
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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
9367
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...
0
9243
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
8241
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...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.