Results 1 to 2 of 2

Thread: this code is not working

  1. #1

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

    this code is not working

    I am trying to take a screenshot of my desktop (as you do with the printscreen button) but it is not working
    I am trying to copy each pixel from the desktop onto a memory DC and then copy the bitmap from memory DC onto my window.
    Here is the code:

    Code:
    PAINTSTRUCT ps, ps1;
    	int x, y;
    	HDC parenthdc, winhdc;
    	HWND parenthwnd;
    	HDC  memhdc;
    	HBITMAP hbmp;
    	BITMAP bm;
    
    	//Create the bitmap
    	winhdc = GetDC(hwnd);
    	memhdc = CreateCompatibleDC(winhdc);
    	hbmp = CreateCompatibleBitmap(memhdc, 1000,1000);
    	ReleaseDC(hwnd, winhdc);
    
       switch(Message)
       {
       
       case WM_PAINT:
    	   parenthwnd = GetParent(hwnd);
    	   parenthdc = BeginPaint(parenthwnd, &ps);
    	   //-----------------------
    	   for(x=0;x<1000;x++)
    	   {
    		   for(y=0;y<1000;y++)
    		   {
    			   SetPixel(memhdc, x,y,GetPixel(parenthdc, x,y));
    		   }
    	   }
    	   winhdc = BeginPaint(hwnd, &ps1);
    	   BitBlt(winhdc, 0,0,1000,1000,memhdc,0,0,SRCCOPY);
    	   EndPaint(hwnd, &ps1);
    	   EndPaint(parenthwnd, &ps);
    	   return 0;
    Do you know why it is not putting the picture of desktop or is there any other method to get a screenshot of my desktop/
    Baaaaaaaaah

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Have a look in the other post.
    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