Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. problem with drawing and mdiforms

problem with drawing and mdiforms

Scheduled Pinned Locked Moved Visual Basic
graphicshelpcsharpdata-structures
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shaahinm
    wrote on last edited by
    #1

    Hi, I have created a form which I need to draw a triangle in it. I found a block of code in internet like this:

    Dim Graph As Graphics
    Dim Ps() As Point
    Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
    ReDim Ps(2)
    Ps(0) = New Point(150, 25)
    Ps(1) = New Point(150, 125)
    Ps(2) = New Point(350, 125)
    Graph.DrawPolygon(pen:=New Pen(Color.Black, Width:=1), points:=Ps)

    it is in paint event of form, it works when I load it by itself, but when I try to load it in a mdiParent form the triangle doesn't show up, can any one help me? also I'm new to vb.net so if there is a better way to draw things please tell me Thanks in advance

    S 1 Reply Last reply
    0
    • S Shaahinm

      Hi, I have created a form which I need to draw a triangle in it. I found a block of code in internet like this:

      Dim Graph As Graphics
      Dim Ps() As Point
      Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
      ReDim Ps(2)
      Ps(0) = New Point(150, 25)
      Ps(1) = New Point(150, 125)
      Ps(2) = New Point(350, 125)
      Graph.DrawPolygon(pen:=New Pen(Color.Black, Width:=1), points:=Ps)

      it is in paint event of form, it works when I load it by itself, but when I try to load it in a mdiParent form the triangle doesn't show up, can any one help me? also I'm new to vb.net so if there is a better way to draw things please tell me Thanks in advance

      S Offline
      S Offline
      Shaahinm
      wrote on last edited by
      #2

      Actually I changed

      Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)

      to

      Graph = Graphics.FromHwnd(hwnd:=Me.Handle)

      and it works I just need to know what ' := ' does like

      Width := 1

      D 1 Reply Last reply
      0
      • S Shaahinm

        Actually I changed

        Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)

        to

        Graph = Graphics.FromHwnd(hwnd:=Me.Handle)

        and it works I just need to know what ' := ' does like

        Width := 1

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        ":=" sets parameters being passed to a method by name instead of relying on the order of parameters. You REALLY should be doing your form painting in its Paint event instead of creating your own Graphics object.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008
        But no longer in 2009...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups