Painting Lines

This is a discussion on Painting Lines within the Windows Programming forums, part of the Platform Specific Boards category; What I'm trying to do here is make a program that draws lines. I'm trying to program a Microsoft Paint ...

  1. #1
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176

    Painting Lines

    What I'm trying to do here is make a program that draws lines. I'm trying to program a Microsoft Paint clone and am working on just drawing lines right now. When I compile and run it (in a standard Win32 program) it works perfectly--except it draws the lines in apparently random places!
    Code:
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int i=0;i<arraycount+1;i++){
                      MoveToEx(hDC,mousex1[i],mousey1[i],NULL);
                      LineTo(hDC,mousex2[i],mousey2[1]);
                        }
                EndPaint(hwnd, &ps);
                break;
            case WM_LBUTTONDOWN:
                      if(toggle==1){
                                    //next two lines set x and y for start of line
                                    mousey1[arraycount]=LOWORD(lParam);//x
                                    mousex1[arraycount]=HIWORD(lParam);//y
                                    toggle=2;  /Next click sets end of line
                                    }
                      else{
                                    //next two lines set x and y for end of line
                                    mousex2[arraycount]=LOWORD(lParam);//x
                                    mousey2[arraycount]=HIWORD(lParam);//y
                                    toggle=1;  //Next click sets beginning of line
                                    arraycount+=1;  //Add to the number of lines
                                    InvalidateRect(hwnd,NULL,false);  //Force a repaint
                           }
                 break;
    BTW: I'm back! Anyone who remembers me, I was a little annoying/stupid/rude/just plain weird, so try to forgive me and remember I'm trying to be better.
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  2. #2
    Registered User
    Join Date
    Dec 2004
    Posts
    73
    After if toggle=1 you set the initial x and y positions of the line. I think you have the x and y mixed up. You comment that you are setting the x and the variable name is mousey1 and the other way around. Maybe that is the problem?
    Code:
    case WM_LBUTTONDOWN:
                      if(toggle==1){
                                    //next two lines set x and y for start of line
                                    mousex1[arraycount]=LOWORD(lParam);// <---- Here is the fixed mistake
                                    mousey1[arraycount]=HIWORD(lParam);// <---- And here
                                    toggle=2;  /Next click sets end of line
                                    }
                      else{
                                    //next two lines set x and y for end of line
                                    mousex2[arraycount]=LOWORD(lParam);//x
                                    mousey2[arraycount]=HIWORD(lParam);//y
                                    toggle=1;  //Next click sets beginning of line
                                    arraycount+=1;  //Add to the number of lines
                                    InvalidateRect(hwnd,NULL,false);  //Force a repaint
                           }
                 break;
    Hopefully that works.
    Last edited by ElWhapo; 01-22-2005 at 10:02 PM.

  3. #3
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    It's not working! I'm trying everything. I've switched and swapped x and y in WM_PAINT and WM_LBUTTONDOWN more times than you could count. If you need to know I'm using Dev-C++. I can't figure out what's wrong.
    Thanks in advance,
    fuh
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  4. #4
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    can you post your whole wndproc?
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  5. #5
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    can you post your whole wndproc?
    Your wish is my command:
    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {            
            HDC hDC;
            PAINTSTRUCT ps;
            int mousex1[100];
            int mousey1[100];
            int mousex2[100];
            int mousey2[100];
        switch (message)
        {
            case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            }
        break;
    
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int i=0;i<=arraycount;i++){
                      MoveToEx(hDC,mousex1[i],mousey1[i],NULL);
                      LineTo(hDC,mousey2[i],mousex2[1]);
                        }
                EndPaint(hwnd, &ps);
                break;
            case WM_DESTROY:
                PostQuitMessage (0);
                break;
            case WM_LBUTTONDOWN:
                      if(toggle==1){
                                    //next two lines set x and y for start of line
                                    mousex1[arraycount]=LOWORD(lParam);
                                    mousey1[arraycount]=HIWORD(lParam);                                
                                    toggle=2;  //Next click sets end of line
                                    }
                      else{
                                    //next two lines set x and y for end of line
                                    mousex2[arraycount]=LOWORD(lParam);//x
                                    mousey2[arraycount]=HIWORD(lParam);//y
                                    toggle=1;  //Next click sets beginning of line
                                    arraycount+=1;  //Add to the number of lines
                                    InvalidateRect(hwnd,NULL,false);  //Force a repaint
                           }
                      break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    There you go. toggle and arraycount are global variables, assigned the values 1 and 0 respectively.
    Last edited by fuh; 01-23-2005 at 10:26 AM. Reason: Poorly formatted code
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  6. #6
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    try making your array declarations static so they retain their value inbetween function calls. aka
    Code:
            static int mousex1[100];
            static int mousey1[100];
            static int mousex2[100];
            static int mousey2[100];
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  7. #7
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    Still a no-go. Has anyone else compiled and run this? Is it just me that's having problems? I still can't think of anything else that would make it run the way it does.
    Last edited by fuh; 01-23-2005 at 10:44 AM. Reason: Bad Grammar: cant'
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    One problem could be that the LBUTTONDOWN is in screen coods and LineTo() is in client coods.

    I also process Mouse move msgs
    case WM_MOUSEMOVE:
    if(wParam & MK_LBUTTON)//mouse button is held down

    and stop on an LBUTTONUP msg.

    I also suggest you add a FillRect to your paint to clear the screen

    hDC=BeginPaint(hwnd, &ps);
    FillRect(ps.hdc, ps.rcPaint, GetStockObject(WHITE_BRUSH) );

    And a call to UpdateWindow() (to post msg directly to your apps msg que rather than the oS que) after each of your InvalidateRect() calls.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  9. #9
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    Quote Originally Posted by novacain
    One problem could be that the LBUTTONDOWN is in screen coods and LineTo() is in client coods.
    Is there any way to convert one set of coordinates to the other? I followed your other advice accept for the redrawing the screen white (passing true as the last arguement for InvalidateRect() erases the screen) so now you can see its "messed-uppedness" in action.
    NOTE: There is a flicker problem because I don't use double buffering.
    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {            
            HDC hDC;
            PAINTSTRUCT ps;
            static int mousex1[100];
            static int mousey1[100];
            static int mousex2[100];
            static int mousey2[100];
        switch (message)                  /* handle the messages */
        {
            case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            }
        break;
    
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int i=0;i<=arraycount;i++){
                      MoveToEx(hDC,mousex1[i],mousey1[i],NULL);
                      LineTo(hDC,mousey2[i],mousex2[1]);
                        }
                EndPaint(hwnd, &ps);
                break;
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            case WM_LBUTTONDOWN:
                 mousex1[arraycount]=LOWORD(lParam);
                 mousey1[arraycount]=HIWORD(lParam);
            case WM_LBUTTONUP:
                 mousex2[arraycount]=LOWORD(lParam);
                 mousey2[arraycount]=HIWORD(lParam);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 arraycount++;
                 break;
            case WM_MOUSEMOVE:
                 if(wParam & MK_LBUTTON){
                 mousex2[arraycount]=LOWORD(lParam);
                 mousey2[arraycount]=HIWORD(lParam);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 }
                 break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Last edited by fuh; 01-23-2005 at 11:45 AM.
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  10. #10
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Code:
    BOOL ScreenToClient(
      HWND hWnd,        // handle to window
      LPPOINT lpPoint   // screen coordinates
    );
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  11. #11
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    This works better, but the lines all start at the upper left corner and end a bit above the cursor.
    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {            
            HDC hDC;
            PAINTSTRUCT ps;
            static POINT mouse1[100];
            static POINT mouse2[100];
        switch (message)                  /* handle the messages */
        {
            case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            }
        break;
    
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int i=0;i<=arraycount;i++){
                      MoveToEx(hDC,mouse1[i].x,mouse1[i].y,NULL);
                      LineTo(hDC,mouse2[i].x,mouse2[i].y);
                        }
                EndPaint(hwnd, &ps);
                break;
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            case WM_LBUTTONDOWN:
                 mouse1[arraycount].x=LOWORD(lParam);
                 mouse1[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse1[arraycount]);
            case WM_LBUTTONUP:
                 mouse2[arraycount].x=LOWORD(lParam);
                 mouse2[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse2[arraycount]);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 arraycount++;
                 break;
            case WM_MOUSEMOVE:
                 if(wParam & MK_LBUTTON){
                 mouse2[arraycount].x=LOWORD(lParam);
                 mouse2[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse2[arraycount]);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 }
                 break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    I am still confused! I don't know what the heck is going on.
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  12. #12
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    I got it to work! Here is the finished source code for my WindowProcedure:
    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {            
            HDC hDC;
            PAINTSTRUCT ps;
            static POINT mouse1[100];
            static POINT mouse2[100];
        switch (message)                  /* handle the messages */
        {
            case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            }
        break;
    
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int i=0;i<=arraycount;i++){
                      MoveToEx(hDC,mouse1[i].x+5,mouse1[i].y+44,NULL);
                      LineTo(hDC,mouse2[i].x+5,mouse2[i].y+44);
                        }
                EndPaint(hwnd, &ps);
                break;
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            case WM_LBUTTONDOWN:
                 mouse1[arraycount].x=LOWORD(lParam);
                 mouse1[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse1[arraycount]);
                 break;
            case WM_LBUTTONUP:
                 mouse2[arraycount].x=LOWORD(lParam);
                 mouse2[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse2[arraycount]);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 arraycount++;
                 break;
            case WM_MOUSEMOVE:
                 if(wParam & MK_LBUTTON){
                 mouse2[arraycount].x=LOWORD(lParam);
                 mouse2[arraycount].y=HIWORD(lParam);
                 ScreenToClient(hwnd, &mouse2[arraycount]);
                 InvalidateRect(hwnd,NULL,true);  //Force a repaint
                 UpdateWindow(hwnd);
                 }
                 break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Turns out I forgot a break in WM_LBUTTONDOWN and didn't account for the caption and menu.
    I still have a problem with moving the window around the screen, though. Could somebody tell me how to fix that?
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  13. #13
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176

    Problem with rectangles and ellipses

    When I added rectangle and ellipse support the shapes all start with their first X and Y at 0, 0. I don't know why. Also, the rectangles and ellipses disapear after you let the mouse button up. Could someone please help me figure out what's going on?
    Some things about this program that might be helpful:
    • shape is a global int
    • LINE, ELLIPSE, and RECTANGLE are defined at the top of the file
    • All the "arraycount"s are set to 0 initially
    • shape is set to LINE initially
    • In WM_COMMAND the ID_SHAPE_... refers to a menu Shape->... with both "..."s in this bullet referring to one of the shape names
    • In WM_COMMAND the clear function draws extra lines (drawn before the clear)

    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {            
            HDC hDC;
            PAINTSTRUCT ps;
            static POINT mouse1L[100];
            static POINT mouse2L[100];
            
            static POINT mouse1E[100];
            static POINT mouse2E[100];
            
            static POINT mouse1R[100];
            static POINT mouse2R[100];        
        switch (message)                  /* handle the messages */
        {
            case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
                case ID_FILE_CLEAR:
                    arraycountL=0;
                    arraycountE=0;
                    arraycountR=0;
                    
                    mouse1L[0].x=-1;        
                    mouse1L[0].y=-1;
                    mouse2L[0].x=-1;
                    mouse2L[0].y=-1;
                    
                    mouse1R[0].x=-1;        
                    mouse1R[0].y=-1;
                    mouse2R[0].x=-1;
                    mouse2R[0].y=-1;
                    
                    mouse1E[0].x=-1;        
                    mouse1E[0].y=-1;
                    mouse2E[0].x=-1;
                    mouse2E[0].y=-1;
                    InvalidateRect(hwnd,NULL,true);  //Force a repaint
                    UpdateWindow(hwnd);
                    break;
                case ID_SHAPE_LINE:
                     shape=LINE;
                     break;
                case ID_SHAPE_ELLIPSE:
                     shape=ELLIPSE;
                     break;
                case ID_SHAPE_RECT:
                     shape=RECTANGLE;
                     break;
                     
            }
        break;
    
            case WM_PAINT:
                hDC=BeginPaint(hwnd, &ps);
                for(int l=0;l<=arraycountL;l++){
                      MoveToEx(hDC,mouse1L[l].x,mouse1L[l].y,NULL);
                      LineTo(hDC,mouse2L[l].x,mouse2L[l].y);}
                for(int e=0;e<=arraycountE;e++){     
                     Ellipse(hDC, mouse1E[e].x, mouse1E[e].y, mouse2E[e].x, mouse2E[e].y+);
                     }
                for(int r=0;r<=arraycountR;r++){     
                     Rectangle(hDC, mouse1R[r].x, mouse1R[r].y, mouse2R[r].x, mouse2R[r].y);
                     }
                EndPaint(hwnd, &ps);
                break;
            
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            case WM_LBUTTONDOWN:
                 if(shape==LINE){
                       mouse1L[arraycountL].x=LOWORD(lParam);
                       mouse1L[arraycountL].y=HIWORD(lParam);
                       }
                 
                 else if(shape==ELLIPSE){
                       mouse1E[arraycountE].x=LOWORD(lParam);
                       mouse1E[arraycountE].y=HIWORD(lParam);
                       }
                       
                 else if(shape==RECTANGLE){
                       mouse1R[arraycountR].x=LOWORD(lParam);
                       mouse1R[arraycountR].y=HIWORD(lParam);
                       }
                 break;
            case WM_LBUTTONUP:
                 if(shape==LINE){
                      mouse2L[arraycountL].x=LOWORD(lParam);
                      mouse2L[arraycountL].y=HIWORD(lParam);
                      
                      arraycountL++;
                      InvalidateRect(hwnd,NULL,true);  //Force a repaint
                      UpdateWindow(hwnd);}
                 
                 if(shape==ELLIPSE){
                      mouse2E[arraycountE].x=LOWORD(lParam);
                      mouse2E[arraycountE].y=HIWORD(lParam);
                      arraycountE+=1;}
                      
                      if(shape==RECTANGLE){
                      mouse2R[arraycountR].x=LOWORD(lParam);
                      mouse2R[arraycountE].y=HIWORD(lParam);
                      arraycountR+=1;}
                      
                      InvalidateRect(hwnd,NULL,true);  //Force a repaint
                      UpdateWindow(hwnd);
                 break;
            case WM_MOUSEMOVE:
                 if(wParam & MK_LBUTTON){
                   if(shape==LINE){
                      mouse2L[arraycountL].x=LOWORD(lParam);
                      mouse2L[arraycountL].y=HIWORD(lParam);}
                 
                   if(shape==ELLIPSE){
                      mouse1E[arraycountE].x=LOWORD(lParam);
                      mouse1E[arraycountE].y=HIWORD(lParam);}
                      
                   if(shape==RECTANGLE){
                      mouse1R[arraycountR].x=LOWORD(lParam);
                      mouse1R[arraycountR].y=HIWORD(lParam);}
                      
                      InvalidateRect(hwnd,NULL,true);  //Force a repaint
                      UpdateWindow(hwnd);
                 }
                 break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

  14. #14
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Getting very close on what can be very frustrating to code/debug. gw!

    At a quick glance......

    there is no conversion from screen to client here?

    couple of typos.
    under the 'UP' command

    in 'LINE' there is an extra paint msg

    in 'RECTANGLE' there is a typo (should be arraycountR )

    >>mouse2R[arraycountE].y=HIWORD(lParam);

    >>the shapes all start with their first X and Y at 0, 0.

    or at -1,-1? (I think you have array index issues)








    The way I do this is;

    the 'start' the line on a DOWN msg (record its position in temp)

    As the mouse moves I update the 'end' position and 'DRAW'(record its position in temp).

    On UP I copy the start and end positions to an array (I use RECTs, a struct of two POINTs), increment array index and 'DRAW'.

    I have a command to clear the screen (using FillRect())

    The 'DRAW' function has params inc. the type of shape, coods and DC to draw on (and colour, pattern ect) so it can be used one-off or in a loop using the arrays.



    Before you go much further you will hit problems with speed, flicker or shearing.
    the answer is 'Double Buffering'. There was a thread in the last week. Plenty of code posted here.

    Basically I would start with single buffering ...

    I use a buffer by creating a compatible DC and compatible bitmap (on WM_CREATE/INIT and cleaned up on close). Use GetDC() and ReleaseDC()

    Then when I call a 'DRAW' all the lines ect are drawn to this compatible DC and I send a paint msg. In the Paint I BitBlt() the buffer (compat DC) to the paint DC.

    This is fast and smooth and will help with the disappearing drawing and moves.

    With double buffering you create two compat DCs.
    One has all the drawing done on it (backbuffer).
    Then the backbuffer is copied to the other compat DC (front buffer). Here is where you do resizes using the slow StretchBlt().
    Then a paint is called.
    In the paint the front buffer is BitBlt()ed to the screen/paint DC.

    This allows multi-threaded apps to draw the next frame (on the backbuffer) while the app updates the screen (using the front buffer).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  15. #15
    fuh
    fuh is offline
    Attack hamster fuh's Avatar
    Join Date
    Dec 2002
    Posts
    176
    Quote Originally Posted by novacain

    there is no conversion from screen to client here?
    I found that it works fine without it.
    I'm fixing the other things you commented on and trying to implement double buffering. I'll try to do what you said. I get what you're saying, though.
    Thanks for the help,
    fuh
    Stupid things pop singers say

    "I get to go to lots of overseas places, like Canada."
    - Britney Spears

    "I love what you've done with the place!"
    -Jessica Simpson upon meeting the Secretary of Interior during tour of the White House

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 07:19 PM
  2. Print out first N lines
    By YoYayYo in forum C Programming
    Replies: 1
    Last Post: 02-21-2008, 12:58 AM
  3. Reading lines from a file
    By blackswan in forum C Programming
    Replies: 9
    Last Post: 04-26-2005, 05:29 PM
  4. count only lines of code...
    By flightsimdude in forum C Programming
    Replies: 13
    Last Post: 09-23-2003, 08:08 PM
  5. Painting lines without libraries..possible??
    By DaNo in forum C Programming
    Replies: 2
    Last Post: 06-19-2002, 12:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21