473,835 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Nov 16 '05 #1
2 1761
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]
- mv*@spam.guard. caspershouse.co m

"Zoury" <ya************ *@hotmail.com> wrote in message
news:%2******** *********@TK2MS FTNGP12.phx.gbl ...
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

Nov 16 '05 #2
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]
- mv*@spam.guard. caspershouse.co m

"Zoury" <ya************ *@hotmail.com> wrote in message
news:uV******** ******@TK2MSFTN GP12.phx.gbl...
Hi Nicholas! :O)
Can you show the code that is placing the image on the button


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


aahh! that's true.. :O)

Thanks for your time!

--
Best Regards
Yanick Lefebvre

Nov 16 '05 #3

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

Similar topics

2
1903
by: Greg Shannan | last post by:
I normally centre an image using a <p align="center"> ... </p> format, but I understand that this is "deprecated" in the latest standard in favour of styles. The problem is that I cannot find a style that will centre an image, "text-align" doesn't work and probably shouldn't. So what is the "standards-correct" method of centering an image? TIA .... Greg Shannan
3
29409
by: steven | last post by:
Hi, I'm trying to center an image in a div, both horizontally and vertically. (Each div holds a thumbnail image.) Here's the HTML: <div class="thumb"> <div> <img src="tn_02-2022.jpg" /> </div> <p>
10
10706
by: Florian Brucker | last post by:
There are several tutorials on the net showing you how to create a thumbnail gallery with floating thumbails which automagically uses all horizontal space available (e.g. http://css.maxdesign.com.au/floatutorial/tutorial0407.htm). However all of them use images which are all equal in size - and that's not the case with my thumbnails. The method itself still works, however I want to center all the images in a row vertically with the highest...
13
31770
by: Mike | last post by:
We are using: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> Using CSS (not html since align=center and <center> are deprecated) I can get it to work in IE6 (but not NS 7 or Firefox) with. <div style="text-align:center; display:block; "><img src="myimg.gif"
2
2150
by: cjl | last post by:
Hey all: I have a div of a known size, 672px X 672px. In it I will display images that are of unknown size. I have two simple functions that shrink and center the image: function shrink() { if (document.getElementById('right').height >= document.getElementById('right').width)
6
2326
by: Jerry Camel | last post by:
I want to center an image on the screen and have text centered over the image. What's the best way to do this? I've been playing with style tags and I can get the stuff to center automatically OR have the text appear on top of the image. But in the second case, the image and text aren't centered properly. Any help is appreciated... Jerry
3
2088
by: The New iSoftware Company | last post by:
Any one know how to center a control like the image editors on the market (fireworks/photoshop/etc)? This way should support scrolling and zoom. Is there a way to draw overlays that is inverted from an image with out going pixel by pixel? LIke the title safe areas in premiere?
0
1087
by: gerstla | last post by:
hi I am building a simple control to view images with zooming capabilities. i want the image to zoom when it is clicked on and try to center the point clicked .the code I am using know for centering isnt working correctly. AutoScrollPosition = new Point((int)(currentPoint.X * _zoom), (int)(currentPoint.Y * _zoom)); currentPoint is the last place I clicked. thanks
16
4948
by: stevedude | last post by:
CSS newbie again. I have a problem trying to get coffee mug images within anchor tags to center with my link text for a vertical list menu. If I use the horizontal/vertical properties of "background" or "background-image", the positioning only works with specifying pixels. If I specify the vertical position in pixels, the image gets cut-off at the bottom. I don't know what to do and would appreciate anyone's help. Specifically the code...
8
609
by: CJM | last post by:
I've inserted a new banner in an existing page and I want the banner image to be centered (horizontally) within its container. I'm not bothered whether the accompanying line of text is restricted to the width of the image and centered, or whether is simply fills the width of the container. I've tried various things to achieve this (e.g setting margins to auto) but I'm not having much luck. The URL for the page is: http://www.eminox.es
0
9802
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
9652
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
10804
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
10517
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
10558
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
10226
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
9343
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
4430
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
3
3086
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.