Results 1 to 5 of 5

Thread: why is not it so

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    why is not it so

    Again, I want to take a screenshot of my desktop and then put that on my window but you can look at the attachment and it is all messed up

    Here is the code I am using:
    Code:
    case WM_PAINT:
    	   	   parenthwnd = GetParent(hwnd);
    	   winhdc = BeginPaint(hwnd, &ps);
    	   parenthdc = GetDC(parenthwnd);
    	   //-----------------------
    	   for(x=0;x<GetSystemMetrics(SM_CXSCREEN);x++)
    	   {
    		   for(y=0;y<GetSystemMetrics(SM_CYSCREEN);y++)
    		   {
    			   SetPixel(winhdc, x,y, GetPixel(parenthdc, x,y));
    		   }
    	   }
    	   
    	   EndPaint(hwnd, &ps);
    	   ReleaseDC(parenthwnd, parenthdc);
    	   return 0;

    It also takes about 3 to 5 seconds to paint the messed up desktop picture onto the window. What is wrong with that?


    I could not post the whole picture because it was too big but I am getting the same thing on the whole window
    Attached Images Attached Images  
    Baaaaaaaaah

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I've an app like thet some 2 months ago but i used
    GetDesktopWIndow to get the hwnd then GetDC to get the dc of the desktop window. Why are you using GetParent, BeginPaint or SetPixel. Just use BitBlt to copy the contents of the dc to your window or image box.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    ok, I did what you said using this code:

    Code:
    parenthwnd = GetDesktopWindow();
    	   winhdc = GetDC(hwnd);
    	   parenthdc = GetDC(parenthwnd);
    	   
    	   BitBlt(winhdc, 0,0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), parenthdc, 0,0, SRCCOPY);
    	   
    	   ReleaseDC(parenthwnd, parenthdc);
    	   ReleaseDC(hwnd, winhdc);

    This code just gives the same result as the above code and it also freezes. How can I get the exact picture of the desktop?
    Baaaaaaaaah

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Never mind, I just got it working but I have problem keeping the picture visible because whenever I recieve a WM_PAINT message it just erases the picture on my window so... do I use a static picture box control and put the picture in there. Will this method work?
    Baaaaaaaaah

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Yes putting it in a picture box would solve the problem.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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