Results 1 to 5 of 5

Thread: painting problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163

    painting problem

    what is difference between

    BeginPaint()
    EndPaint()

    and

    GetDC()
    ReleaseDC()

    I am getting problem with this.
    While using beginpaint and end paint is works well but in another
    the objects drawn are flicker.
    Purushottam

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    BeginPaint() -- Start Painting To An Object
    EndPaint() -- Stop Painting To An Object

    and

    GetDC() -- Get Device Context (The Device To Paint To)
    ReleaseDC() -- Release Device Context (The Device To Paint To)


    If you zip up your code (Or if you dont want to do that you can post your problem code) I will take a look at it if you want. With out it I can't really tell you what your problem is
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163
    PAINTSTRUCT pc;
    hDc=BeginPaint(hwnd,&pc);
    //hDc=GetDC(hwnd);
    Rectangle(hDc,10,10,30,40);

    Ellipse(hDc,10,10,30,40);

    MoveToEx(hDc,20,40,NULL);
    LineTo(hDc,100,100);


    Polygon(hDc,A,4);

    RECT R;
    R.top =50;
    R.left =50;
    R.right =100;
    R.bottom=100;
    InvertRect(hDc,&R);
    //ReleaseDC(hwnd,hDc);
    EndPaint(hwnd,&pc);
    Purushottam

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Well I dont see anything that jumps out at me. One thing you might try is to do:

    BeginPaint(hwnd,&pc);
    EndPaint(hwnd,&pc);

    Before the rest of your paint code. Don't ask me why but it seems to take care of the flicker.

    Also you need to put back in the ReleaseDC, because if you don't then you have a memory leak. If you are still having problems, then I am going to need to see your whole code.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Never use the *Paint and the *DC functions together. Use the *Paint functions ONLY in response to the WM_PAINT message, and *DC in all other situations. Then you shouldn't have problems.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width