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. Drawing disappears on modal form

Drawing disappears on modal form

Scheduled Pinned Locked Moved Visual Basic
graphics
2 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    I have:

       For i = 0 To 100
                 'TextOut GetWindowDC(GetActiveWindow), 50 + 10 * i, 50, str, Len(str)
                     RetVal = Rectangle(GetWindowDC(GetActiveWindow), 20 + 10 * i, 40, 30 + 10 * i, 50)
                '   ProgressBar1.Value = i
                 Next
    

    on a modal form. Works ok. But, if you cover the running app with another screen and then show the app again, the rectangles have vanished! I tried

    '      Form1.AutoRedraw = True
    

    , but this makes the form come up with no rectangles, and when you close the app, task manager says its still running. (I call that a 'crash' I dont know what that situation is called'. Thanks, ns

    N 1 Reply Last reply
    0
    • N ns

      I have:

         For i = 0 To 100
                   'TextOut GetWindowDC(GetActiveWindow), 50 + 10 * i, 50, str, Len(str)
                       RetVal = Rectangle(GetWindowDC(GetActiveWindow), 20 + 10 * i, 40, 30 + 10 * i, 50)
                  '   ProgressBar1.Value = i
                   Next
      

      on a modal form. Works ok. But, if you cover the running app with another screen and then show the app again, the rectangles have vanished! I tried

      '      Form1.AutoRedraw = True
      

      , but this makes the form come up with no rectangles, and when you close the app, task manager says its still running. (I call that a 'crash' I dont know what that situation is called'. Thanks, ns

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      If you add your code to the subroutine Form_Paint() I think you should be able to see your rectangles when redisplaying your form. This worked for me.

      Private Sub Form_Paint()

      For i = 0 To 100
      'TextOut GetWindowDC(GetActiveWindow), 50 + 10 * i, 50, str, Len(str)
      RetVal = Rectangle(GetWindowDC(GetActiveWindow), 20 + 10 * i, 40, 30 + 10 * i, 50)
      'ProgressBar1.Value = i
      Next

      End Sub

      Nick Parker
      **So like children pointers should be left to grown ups. - Norm Alomond


      **

      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