Stretched rounded buttons | CodeGuru

Stretched rounded buttons

  Download Source Code and Example. The code is basically an extension to the RoundButton class written by Chris Maunder. While his RoundButton is always circular, i have changed it such that it can have a flattened horizontal orientation. This combines Chris’ beautiful round shading with the more space-efficient appearance of an ordinary rectangle button. […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 24, 1998
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

 
Download Source Code and
Example.

The code is basically an extension to the
RoundButton
class written by Chris Maunder. While his RoundButton is
always circular, i have changed it such that it can have a flattened horizontal
orientation. This combines Chris’ beautiful round shading with the more
space-efficient appearance of an ordinary rectangle button.

I decided to keep the RoundButton class instead of deriving yet another
because i think that the added functionality is transparent enough. In
the sense that the button defaults to exactly Chris’ circular button
when the button is designed square or vertical (say portrait) in the
resources.

The only change applies to buttons that are designed non-square
horizontal (say landscape) in the resources. In that case the button is
stretched to fill the width of the button. And Chris’ circular fragments
are appended to the left and to the right sides.

In order to do this i split up Chris’ DrawCircle function into a
DrawCircleLeft and DrawCircleRight part. Each of which draws a shaded
180-degree angle. Then i added the functionality to draw horizontal
lines between the left and right arcs to combine the arcs.

A minor change is in the LIGHT_SOURCE_ANGLE constant. When Chris’ value
of -2.356 is applied, the color of the highlited line (top line) of the
stretched button is almost identical to the background color. And the
line appears to be missing. By changing the angle of incoming light to
-1.88 the top line has enough highlight to contrast with the background.

The new functionality has been added to both the 3d- and flat-type
buttons.

I have also changed the text-drawing functionality to give it more of a
3d-look.

I did not implement the dotted focus for this new button because i did
not need it myself. But it might be a good idea for another extension.

Chris’ button does not support acceleration-underline. Neither does
mine. This might also be a good extension.

I don’t regard my code addition as highly elegant or intelligent. But it
seems to work without problems in my application.

Last updated: 6 June 1998

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.