473,405 Members | 2,279 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,405 software developers and data experts.

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 1114
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.Location = 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 InitializeComponents method that will have
executed already in common scenarios.

--
Dave Sexton

"Its Me Ernest T." <sp**@myplaceinspace.comwrote in message
news:C4******************@tornado.southeast.rr.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.googlegr oups.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.googlegr oups.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
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...
4
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...
2
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...
2
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...
3
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...
11
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
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...
5
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...
16
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...
5
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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
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...
0
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,...
0
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...

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.