Subclassing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Its Me Ernest T.

    #1

    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.



  • Chris Dunaway

    #2
    Re: Subclassing

    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.

    Comment

    • Mattias Sjögren

      #3
      Re: Subclassing

      >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.

      Comment

      • Dave Sexton

        #4
        Re: Subclassing

        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." <spam@myplacein space.comwrote in message
        news:C4t2h.1253 4$HD6.2732@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.
        >
        >
        >

        Comment

        • Chris Dunaway

          #5
          Re: Subclassing

          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.

          Comment

          • Dave Sexton

            #6
            Re: Subclassing

            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" <dunawayc@gmail .comwrote in message
            news:1162563866 .015162.282530@ 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.
            >

            Comment

            • Its me Earnest T.

              #7
              Re: Subclassing

              Yup, you got me looking in the right place though and I have about got
              exactly what I need. Thanks again.

              Bryan

              "Chris Dunaway" <dunawayc@gmail .comwrote in message
              news:1162563866 .015162.282530@ 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.
              >

              Comment

              Working...