Image centering..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zoury

    Image centering..

    Hi there! :O)

    I'm trying to stick a 16x16 pixels image on a 24x24 pixels button. The image
    is never centered properly no matter what alignment i sets. there is always
    a little margin or something.. any thoughts ? I've tried to override the
    OnPaint() events without any success (probably due to a lack of knowlegde in
    owner drawn controls.. :O)

    btw, is there a way to "subclass" or override a method without having to
    create a new inherited class ? if so, would that be programmaticaly correct
    or would it break some OO concepts ?

    Thanks a lot!

    --
    Best Regards
    Yanick Lefebvre


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Image centering..

    Zoury,

    Can you show the code that is placing the image on the button (as well
    as provide the image)?

    Also, there is no way to subclass just a method. You have to create a
    type that derives from the original type. If you could do that, then anyone
    could just say "I want to override that method" at which point, the base
    object has to ask, "which override do I use?"

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Zoury" <yanick_lefebvr e@hotmail.com> wrote in message
    news:%23r72c%23 QiEHA.632@TK2MS FTNGP12.phx.gbl ...[color=blue]
    > Hi there! :O)
    >
    > I'm trying to stick a 16x16 pixels image on a 24x24 pixels button. The
    > image
    > is never centered properly no matter what alignment i sets. there is
    > always
    > a little margin or something.. any thoughts ? I've tried to override the
    > OnPaint() events without any success (probably due to a lack of knowlegde
    > in
    > owner drawn controls.. :O)
    >
    > btw, is there a way to "subclass" or override a method without having to
    > create a new inherited class ? if so, would that be programmaticaly
    > correct
    > or would it break some OO concepts ?
    >
    > Thanks a lot!
    >
    > --
    > Best Regards
    > Yanick Lefebvre
    >
    >[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Image centering..

      Zoury,

      I'm running this on VS.NET 2005 Beta, and from what I can tell, it
      centers fine. I can't try it on VS.NET 2003. Perhaps someone else can test
      it?

      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "Zoury" <yanick_lefebvr e@hotmail.com> wrote in message
      news:uVyrwuRiEH A.3664@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi Nicholas! :O)
      >[color=green]
      >> Can you show the code that is placing the image on the button[/color]
      >
      > I've selected the image directly from the button's property page (Image
      > property)... but i've got the same result if i load it manually..
      >
      > sample :
      > //***
      > // declared somewhere..
      > private System.Windows. Forms.Button _btn;
      >
      > // in form_load
      > _btn = new System.Windows. Forms.Button();
      > _btn.Location = new Point(330, 210);
      > _btn.Size = new Size(24, 24);
      > _btn.Image = Image.FromFile( "c:\\small_plus .bmp");
      > this.Controls.A dd(_btn);
      > //***
      >
      > I've tried to play with the ImageAlign and TextAlign property (just in
      > case)
      > and i've got a little difference when ImageAlign is set to BottomRight..
      > but
      > it is not centered anyway.
      >[color=green]
      >> Also, there is no way to subclass just a method. You have to create
      >> a
      >> type that derives from the original type. If you could do that, then[/color]
      > anyone[color=green]
      >> could just say "I want to override that method" at which point, the base
      >> object has to ask, "which override do I use?"[/color]
      >
      > aahh! that's true.. :O)
      >
      > Thanks for your time!
      >
      > --
      > Best Regards
      > Yanick Lefebvre
      >
      >
      >[/color]


      Comment

      Working...