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

Popular posts from this blog

Burhan Wani – The man and his mission

Burhan Wani – The man and his mission The death of a young ‘hero’? On the 8th of July, Burhan Muzaffar Wani died in the Valley of Kashmir. Thousands poured out on the streets to commemorate his services to the movement that he had come to symbolize of late. The relative calm of the region was shattered with curfews, killings and allegations of human rights abuses. His father was proud for the services his son had offered in the name of their faith, convinced that he would go to Heaven. Amidst all this, the romantic ideals of a young boy, just off his teens began to shake up the youth of the entire country, both in and beyond India. There is a lot of unrest in the Kashmir Valley recently, especially in the aftermath of the death, nay execution of Burhan. All of this is not unexpected in any way. In fact, this was foreseen. Even his glorification, his elevation to the status of a martyr in the service of Islam does not come as a surprise to me.
There is a section of the media and a sig…

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 wasAt an event in the Jawaharlal Nehru University, Ravi Shankar gave a talk on the occasion of the Nehru Memorial lecture on 13th 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 acknowledge it and accept it, and kno…

Lets just stop insulting Biharis

Introduction It is the land of enlightenment, the land of higher education, of spirituality. It is the land of immense wealth, great architecture, the birthplace of several faiths, the land where research on astronomy, literature, math, general sciences and philosophy flourished. The land is not Greece. It is not ancient Rome, Egypt, Sumer, Mesopotamia, or even the Central Americas. The land rests today between two states in the Indian Union - between Uttar Pradesh and West Bengal; the Indian state of Bihar.
This is a referenced article. For list of references, please check this link. Bihar has since earned a terrible reputation. No amount of whitewashing will remove that stain. It is now known as the dacoits’ paradise, the land of hooligans, bad roads, caste and religious strife, rampant crimes against women and almost all the social evils that one can probably think of. However, Bihar was nothing like this. Or at least it was not supposed to be like this. I will give a very brief introd…