Skip to main content

Round your corners

Many people face a problem when it comes to drawing the controls with rounded corners. So I got down and dirty with some simple drawing and came up with this. All you have to do is to call this Sub Procedure with the parameters passed to it and you are done. Enjoy!
   1:    Public Sub DrawRoundedRectangle(ByVal objGraphics As Graphics, _
   2:                                 ByVal m_intxAxis As Integer, _
   3:                                 ByVal m_intyAxis As Integer, _
   4:                                 ByVal m_intWidth As Integer, _
   5:                                 ByVal m_intHeight As Integer, _
   6:                                 ByVal m_diameter As Integer, _
   7:                                 ByVal g As Graphics)
  10:          Dim path As New GraphicsPath()
  11:          'Dim g As Graphics
  12:          Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth,
  13:                                        m_intHeight)
  14:          Dim ArcRect As New RectangleF(BaseRect.Location,
  15:                                    New SizeF(m_diameter, m_diameter))
  16:          'top left Arc
  17:          path.AddArc(ArcRect, 180, 90)
  18:          path.AddLine(m_intxAxis + CInt(m_diameter / 2),
  19:                               m_intyAxis,
  20:                               m_intxAxis + m_intWidth - CInt(m_diameter / 2),
  21:                               m_intyAxis)
  23:          ' top right arc
  24:          ArcRect.X = BaseRect.Right - m_diameter
  25:          path.AddArc(ArcRect, 270, 90)
  26:          path.AddLine(m_intxAxis + m_intWidth,
  27:                               m_intyAxis + CInt(m_diameter / 2),
  28:                               m_intxAxis + m_intWidth,
  29:                               m_intyAxis + m_intHeight - CInt(m_diameter / 2))
  31:          ' bottom right arc
  32:          ArcRect.Y = BaseRect.Bottom - m_diameter
  33:          path.AddArc(ArcRect, 0, 90)
  34:          path.AddLine(m_intxAxis + CInt(m_diameter / 2),
  35:                               m_intyAxis + m_intHeight,
  36:                               m_intxAxis + m_intWidth - CInt(m_diameter / 2),
  37:                               m_intyAxis + m_intHeight)
  39:          ' bottom left arc
  40:          ArcRect.X = BaseRect.Left
  41:          path.AddArc(ArcRect, 90, 90)
  42:          path.AddLine(
  43:                               m_intxAxis, m_intyAxis + CInt(m_diameter / 2),
  44:                               m_intxAxis,
  45:                               m_intyAxis + m_intHeight - CInt(m_diameter / 2))
  46:          g.CompositingQuality = CompositingQuality.HighQuality
  47:          g.SmoothingMode = SmoothingMode.AntiAlias
  48:          g.DrawPath(Pens.Black, path)
  49:      End Sub


Post a Comment

No spam please :)

Popular posts from this blog

How To: Change Fonts On The 5800, 5233 etc

The font that comes with Nokia is nice. But after six months you are bound to crave for a new look to your phone. Now changing fonts on a phone is usually not an easy task, I mean that was how you must have thought. But you know what you can use custom fonts, yes any font of your choice on your Nokia phone without any software. All you need to do is copy and paste a bunch of files. No replacing of system resources necessary! First to increase your greed, I will post some screenshots, Screenshot Gallery o   Font Style Download o Another Font Style Now let me tell you how I did it. Procedure to apply new Fonts Connect the phone in the ‘Mass Storage’ profile to the computer. Alternatively, you can use the memory card reader. Goto the Memory Card, it shows up as a Removable Disk. Navigate to the ‘resource’ folder and open it. Copy the ‘Fonts’ folder into in. Eject the device and restart. You should see the new fonts applied. Procedure to apply your Fonts Ma

Sri Sri & Homosexuality – Another media hit job in the making

Sri Sri Ravi Shankar (henceforth named as Mr. Shankar) is not new to controversy. Not even with topics like homosexuality. What the event was At an event in the Jawaharlal Nehru University, Ravi Shankar gave a talk on the occasion of the Nehru Memorial lecture on 13 th November, 2017. One among the audience lamented that he was ill-treated since he was known to be a homosexual. Then Mr. Shankar stated that he needed to accept himself as he was and love knew no boundaries. Let’s see and hear what he said… Let’s quote Mr. Shankar verbatim as reported by some of the newspapers . ‘ You treat yourself better, doesn’t matter how others treat you. You don’t think you are sick or something’s wrong with you. If you stand up, nobody can insult you… But if you feel weak and meek, and if you feel bad about yourself, nobody can make you feel better.’ Indian Express reported this in addition as well. Let me quote it directly here as well. ‘ This is your tendency now. Just ack

Operation Situation Report Summary - Ukraine 4 March

 Defense Without Strategy Ukraine seems to be hell bent on fighting a static war without almost any flexibility. Their forces may be valiant and defiant, but without a coherent strategy, the best they can hope for is to prolong their own suffering WITHOUT significantly hurting the enemy. Here is how the situation stands as of now. Kherson has fallen. The front in the South was decisively broken day before yesterday with the capture of the railway station and port. Naturally, the Russian forces did not wait and moved straight North to Mykolaiv. All UA forces on the Dnepr facing South are likely to be outflanked. Unless the Russian spearheads are cut off and destroyed in a day or two, it will be too late. The fall of the entire South seems to be inevitable.  To extricate the forces, UA should have withdrawn forces from other sectors (including far away Donetsk front). Now, the best they can try is to win time to reinforce Kyiv. Kharkov is almost surrounded. This battle seems to be fought