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. Handling System.Runtime.InteropServices.ExternalException] {System.Runtime.InteropServices.ExternalException} System.Runtime.InteropServices.ExternalException in .Net

Handling System.Runtime.InteropServices.ExternalException] {System.Runtime.InteropServices.ExternalException} System.Runtime.InteropServices.ExternalException in .Net

Scheduled Pinned Locked Moved Visual Basic
graphicshelpcsharpwinformstutorial
1 Posts 1 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.
  • P Offline
    P Offline
    psmukil
    wrote on last edited by
    #1

    Hi all, Im using a windows form and on mouse down on a label i want to draw an rectangle on the label. Its working fine when the label without border. But When i have the label with border, after clicking the label for the fisrt time its throwing "System.Runtime.InteropServices.ExternalException" . and an Generic GDI+ Error. In DrawRectangle function i removed the border of the control by converting the control to a label inroder to have that BorderStyle Property. I think problem might have occured in this line of code. and its not drawing the rectangle, for the second time mouse down, its working fine and draws the rectangle properly. Whats could be the problem, Please guide me. I was struggling with this error for the past two days. Code is given below. Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown If CInt(Label1.Tag) = 0 Then Label1.Tag = 1 DrawRectAngle(Label1) ElseIf CInt(Label1.Tag) = 1 Then Label1.Tag = 2 Label1.Refresh() DrawCrossLine(Label1) Else Label1.Tag = 0 Label1.Refresh() End If End Sub Private Sub DrawRectAngle(ByVal ControlName As Control) Dim RectPen As New Pen(Color.Lime) RectPen.Width = 6 g = ControlName.CreateGraphics() Try If TypeOf ControlName Is System.Windows.Forms.Label Then CType(ControlName, Label).BorderStyle = BorderStyle.None End If Dim rect As Rectangle rect = New Rectangle(1, 1, ControlName.Width, ControlName.Height) g.DrawRectangle(RectPen, rect) Catch ex As Exception End Try End Sub Regards Mukilan.

    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