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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Mscomm and draw chart

Mscomm and draw chart

Scheduled Pinned Locked Moved Visual Basic
helpcomdebuggingquestion
13 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.
  • C codeadair

    Thank you for your reply. Do you think the issue is on the "drawing"???? I think it is on the reading data from test equipment. when i moving(or other actions) form.at the time i am releasing left mouse,the data readed from test equipment is null. So i think the issue is between timer_elapsed event and communicating between pc and test equipment. when i am doing form events,the communication will not happen.but the timer is going on. So the fucntion tesle() returns value 0.Here the problem is. and also,i have a test.i set the timer.interval to 300 or more.the problem will not happen. And now if it as i am saying.How can i resolve it. Best gardness! ICQ:258-235-734 MSN:msnadair@hotmail.com -- modified at 21:07 Thursday 29th June, 2006

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

    First, you're doing some drawing in a Timer event. Don't! Any drawing you do to the screen should be done only in the Paint event. Second, you're using a Timer out of the ToolBox?? This passes its Timer Tick as an event, which is routed through the app's message pump. This means that other events can pile up VERY rapidly before the Timer Tick event, such as moving the form. Using an event based Timer isn't really a good idea. Also, 100ms doesn't leave your code very much time to do anything. Painting can take an eternity (>100ms) if not done correctly. While you're collecting data, draw to a Bitmap. Then you don't have to worry about painting, and repainting, old data continously. You paint your data once on the Bitmap and it'll be persisted between Paint events. Dave Kreskowiak Microsoft MVP - Visual Basic

    C 1 Reply Last reply
    0
    • D Dave Kreskowiak

      First, you're doing some drawing in a Timer event. Don't! Any drawing you do to the screen should be done only in the Paint event. Second, you're using a Timer out of the ToolBox?? This passes its Timer Tick as an event, which is routed through the app's message pump. This means that other events can pile up VERY rapidly before the Timer Tick event, such as moving the form. Using an event based Timer isn't really a good idea. Also, 100ms doesn't leave your code very much time to do anything. Painting can take an eternity (>100ms) if not done correctly. While you're collecting data, draw to a Bitmap. Then you don't have to worry about painting, and repainting, old data continously. You paint your data once on the Bitmap and it'll be persisted between Paint events. Dave Kreskowiak Microsoft MVP - Visual Basic

      C Offline
      C Offline
      codeadair
      wrote on last edited by
      #5

      Thank you for your reply heartly! Well.i will try to do some changes as follow: 1> take the drawing action out of timer event 2> I havn't drawn graphics to bitmap before.but i will try. By the way.what does this sentence mean?

      Dave Kreskowiak wrote:

      you're using a Timer out of the ToolBox??

      I am using the timer control from toolbox.it is a system.timer but windows.forms.timer. ICQ:258-235-734 MSN:msnadair@hotmail.com

      D 1 Reply Last reply
      0
      • C codeadair

        Thank you for your reply heartly! Well.i will try to do some changes as follow: 1> take the drawing action out of timer event 2> I havn't drawn graphics to bitmap before.but i will try. By the way.what does this sentence mean?

        Dave Kreskowiak wrote:

        you're using a Timer out of the ToolBox??

        I am using the timer control from toolbox.it is a system.timer but windows.forms.timer. ICQ:258-235-734 MSN:msnadair@hotmail.com

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

        codeadair wrote:

        I am using the timer control from toolbox.it is a system.timer but windows.forms.timer.

        This is the Timer I was asking about. It's not the most accurate and it's event can be bogged down by other events the form has to process. Dave Kreskowiak Microsoft MVP - Visual Basic

        C 1 Reply Last reply
        0
        • D Dave Kreskowiak

          codeadair wrote:

          I am using the timer control from toolbox.it is a system.timer but windows.forms.timer.

          This is the Timer I was asking about. It's not the most accurate and it's event can be bogged down by other events the form has to process. Dave Kreskowiak Microsoft MVP - Visual Basic

          C Offline
          C Offline
          codeadair
          wrote on last edited by
          #7

          I agree with you. And now i am using doublebuffer method.It is really very useful . But it is going on.and now i have to work off. I believe i could do well to resolve the problem with your help. Thank you very much for you help.Please follow the problem. By the way.what's your time now? ICQ:258-235-734 MSN:msnadair@hotmail.com

          D 1 Reply Last reply
          0
          • C codeadair

            I agree with you. And now i am using doublebuffer method.It is really very useful . But it is going on.and now i have to work off. I believe i could do well to resolve the problem with your help. Thank you very much for you help.Please follow the problem. By the way.what's your time now? ICQ:258-235-734 MSN:msnadair@hotmail.com

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

            codeadair wrote:

            By the way.what's your time now?

            To you, it's comming up on Saturday. I'm still on Friday morning. Dave Kreskowiak Microsoft MVP - Visual Basic -- modified at 9:51 Friday 30th June, 2006

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              The solution is surprisingly simple. Don't draw on the Panel surface. Draw to a Bitmap object that same size as the panel. Set the BackgroundImage property of the panel to the Bitmap. now, when you draw on the Bitmap, just call Refresh on the Panel. Dave Kreskowiak Microsoft MVP - Visual Basic

              C Offline
              C Offline
              codeadair
              wrote on last edited by
              #9

              Dave Kreskowiak wrote:

              Draw to a Bitmap object that same size as the panel. Set the BackgroundImage property of the panel to the Bitmap. now, when you draw on the Bitmap, just call Refresh on the Panel.

              Yes.I just do as you day. But i find a problem.when i use g.ScaleTransform(xscaletran, yscaletran) method.And then refresh the panel:me.panel1.refresh. it will take no effect.why?Have i need to redraw all datas? ICQ:258-235-734 MSN:msnadair@hotmail.com

              D 1 Reply Last reply
              0
              • C codeadair

                Dave Kreskowiak wrote:

                Draw to a Bitmap object that same size as the panel. Set the BackgroundImage property of the panel to the Bitmap. now, when you draw on the Bitmap, just call Refresh on the Panel.

                Yes.I just do as you day. But i find a problem.when i use g.ScaleTransform(xscaletran, yscaletran) method.And then refresh the panel:me.panel1.refresh. it will take no effect.why?Have i need to redraw all datas? ICQ:258-235-734 MSN:msnadair@hotmail.com

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

                Where did the Graphics object (g) come from?? Dave Kreskowiak Microsoft MVP - Visual Basic

                C 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Where did the Graphics object (g) come from?? Dave Kreskowiak Microsoft MVP - Visual Basic

                  C Offline
                  C Offline
                  codeadair
                  wrote on last edited by
                  #11

                  Dave Kreskowiak wrote:

                  Where did the Graphics object (g) come from??

                  Graphics object (g) is a form variant.look here: dim bmp as bitmap=new bitmap(800,600) dim g as graphics=graphics.fromimage(bmp) Maybe you could read my another forum question named "graphics.scaletransform() method".it describes the question clearly. Thank you for you reply heartly! ICQ:258-235-734 MSN:msnadair@hotmail.com -- modified at 23:47 Monday 3rd July, 2006

                  D 1 Reply Last reply
                  0
                  • C codeadair

                    Dave Kreskowiak wrote:

                    Where did the Graphics object (g) come from??

                    Graphics object (g) is a form variant.look here: dim bmp as bitmap=new bitmap(800,600) dim g as graphics=graphics.fromimage(bmp) Maybe you could read my another forum question named "graphics.scaletransform() method".it describes the question clearly. Thank you for you reply heartly! ICQ:258-235-734 MSN:msnadair@hotmail.com -- modified at 23:47 Monday 3rd July, 2006

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

                    ScaleTransform doesn't do anything until you draw something. It sets up a transform for any drawing done to the surface after the call the ScaleTransform. Dave Kreskowiak Microsoft MVP - Visual Basic

                    C 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      ScaleTransform doesn't do anything until you draw something. It sets up a transform for any drawing done to the surface after the call the ScaleTransform. Dave Kreskowiak Microsoft MVP - Visual Basic

                      C Offline
                      C Offline
                      codeadair
                      wrote on last edited by
                      #13

                      Dave Kreskowiak wrote:

                      ScaleTransform doesn't do anything until you draw something. It sets up a transform for any drawing done to the surface after the call the ScaleTransform.

                      Yes.I think so. And i have to redraw bitmap if i want to transform the graphic.So bitmap doesn't look very useful this time. ICQ:258-235-734 MSN:msnadair@hotmail.com

                      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