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. Mobile Development
  3. Mobile
  4. How to repaint the whole screen?

How to repaint the whole screen?

Scheduled Pinned Locked Moved Mobile
questiongraphicstutorial
7 Posts 4 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
    sushilange
    wrote on last edited by
    #1

    Hi, with:

    IntPtr deviceContext = GetDC(IntPtr.Zero);
    Graphics deviceGraphics = Graphics.FromHdc(deviceContext)

    it is possible to draw on the screen. But how can I delete the drawn objects from screen? It still appears until something changed on the screen so Windows Mobile repaint that area. I tried RedrawWindow() and also SendMessage(with WM_PAINT) to repaint the whole screen, but nothing works :(

    J P 2 Replies Last reply
    0
    • S sushilange

      Hi, with:

      IntPtr deviceContext = GetDC(IntPtr.Zero);
      Graphics deviceGraphics = Graphics.FromHdc(deviceContext)

      it is possible to draw on the screen. But how can I delete the drawn objects from screen? It still appears until something changed on the screen so Windows Mobile repaint that area. I tried RedrawWindow() and also SendMessage(with WM_PAINT) to repaint the whole screen, but nothing works :(

      J Offline
      J Offline
      Joel Ivory Johnson
      wrote on last edited by
      #2

      I you want to paint the full screen then why don't you run your application in full screen mode?

      Joel Ivory Johnson

      Meet my dev team: RDA Architecture Evangelist Team Blog

      My site: J2i.net

      Twitter: J2iNet

      S 1 Reply Last reply
      0
      • J Joel Ivory Johnson

        I you want to paint the full screen then why don't you run your application in full screen mode?

        Joel Ivory Johnson

        Meet my dev team: RDA Architecture Evangelist Team Blog

        My site: J2i.net

        Twitter: J2iNet

        S Offline
        S Offline
        sushilange
        wrote on last edited by
        #3

        I want to paint directly on the screen. No Form, no Control. A hidden application which paints directly on the screen. For example a text in the top bar where the start-button is. This works fine and is not the problem. The problem is, that i'm not able to delete the things I drawed on the screen. They will dissaper when Windows Mobile force the controls, forms, etc. to be repaint. For example if I draw text on the top bar the text still appears until I open the start menu, because then the bar will be repaint. After closing my hidden application I want to delete the text, which I drawed. So I have to force the whole desktop to repaint (because the text on top bar was only an example). But I tried RedrawWindow (with IntPtr.Zero) and also SendMessage (with WM_PAINT to IntPtr.Zero). This force Windows Mobile to repaint everything, but it doesnt work :(

        D 1 Reply Last reply
        0
        • S sushilange

          I want to paint directly on the screen. No Form, no Control. A hidden application which paints directly on the screen. For example a text in the top bar where the start-button is. This works fine and is not the problem. The problem is, that i'm not able to delete the things I drawed on the screen. They will dissaper when Windows Mobile force the controls, forms, etc. to be repaint. For example if I draw text on the top bar the text still appears until I open the start menu, because then the bar will be repaint. After closing my hidden application I want to delete the text, which I drawed. So I have to force the whole desktop to repaint (because the text on top bar was only an example). But I tried RedrawWindow (with IntPtr.Zero) and also SendMessage (with WM_PAINT to IntPtr.Zero). This force Windows Mobile to repaint everything, but it doesnt work :(

          D Offline
          D Offline
          Dr William J Blanke
          wrote on last edited by
          #4

          Use InvalidateRect() and then wait for the OS to send you a WM_PAINT in response so you can redraw.

          S 1 Reply Last reply
          0
          • D Dr William J Blanke

            Use InvalidateRect() and then wait for the OS to send you a WM_PAINT in response so you can redraw.

            S Offline
            S Offline
            sushilange
            wrote on last edited by
            #5

            Thanks, but it doesn't work, too :-(

            IntPtr deviceContext = GetDC(IntPtr.Zero);

                    Rectangle rectangle = Screen.PrimaryScreen.Bounds;
                    using (Bitmap capture = new Bitmap(rectangle.Width, rectangle.Height))
                    //Get screen context
                    using (Graphics deviceGraphics = Graphics.FromHdc(deviceContext))
                    //Get graphics from bitmap
                    using (Graphics captureGraphics = Graphics.FromImage(capture))
                    {
                        // Blit the image data
                        BitBlt(captureGraphics.GetHdc(), 0, 0,
                            rectangle.Width, rectangle.Height, deviceGraphics.GetHdc(),
                            rectangle.Left, rectangle.Top, SRCCOPY);
                                  
                        
                        deviceGraphics.DrawString("Hello", Font, new SolidBrush(Color.Black), 10, 10);                
                    }
                    // Doesn't work: InvalidateRect(deviceContext, IntPtr.Zero, true);
                    //Doesn't work: RedrawWindow(deviceContext, IntPtr.Zero, IntPtr.Zero, RDW\_ERASE | RDW\_INTERNALPAINT | RDW\_UPDATENOW | RDW\_INVALIDATE);
                    // Doesn't work: SendMessage(deviceContext, WM\_PAINT, 0, 0);
            
                    // I tried RedrawWindow with all possibile combinations of all parameters (RDW\_XXXX)!
                    // I also tried to add directly IntPtr.Zero as Handle parameter
                    // In all cases the text "Hello" is still drawn until I click on the start button
                    // I run the code on WM 6.1.4 Professional (Emulator)
            
            1 Reply Last reply
            0
            • S sushilange

              Hi, with:

              IntPtr deviceContext = GetDC(IntPtr.Zero);
              Graphics deviceGraphics = Graphics.FromHdc(deviceContext)

              it is possible to draw on the screen. But how can I delete the drawn objects from screen? It still appears until something changed on the screen so Windows Mobile repaint that area. I tried RedrawWindow() and also SendMessage(with WM_PAINT) to repaint the whole screen, but nothing works :(

              P Offline
              P Offline
              PavanPareta
              wrote on last edited by
              #6

              Hi sushilange, try this this.Refresh();

              Pavan Pareta

              S 1 Reply Last reply
              0
              • P PavanPareta

                Hi sushilange, try this this.Refresh();

                Pavan Pareta

                S Offline
                S Offline
                sushilange
                wrote on last edited by
                #7

                I want to repaint/refresh Windows Mobile! And not my own application, because my own application isn't shown on the screen. If I draw directly on the screen above EVERYTHING, I want to delete this after closing my app. So I have to inform Windows Mobile that it has to repaint EVERTHING displayed on the screen.

                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