Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

i dont understand these code!

Posted on 2003-12-03
4
Medium Priority
?
223 Views
Last Modified: 2013-11-20
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static BOOL    bCapturing, bBlocking ;
     static HBITMAP hBitmap ;
     static HWND    hwndScr ;
     static POINT   ptBeg, ptEnd ;
     BITMAP         bm ;
     HBITMAP        hBitmapClip ;
     HDC            hdc, hdcMem ;
     int            iEnable ;
     PAINTSTRUCT    ps ;
     RECT           rect ;

     switch (message)
     {
     case WM_LBUTTONDOWN:
          if(!bCapturing)
              {
                    if(LockWindowUpdate(hwndScr =GetDesktopWindow()))
                    {
                          bCapturing  =TRUE;
                          SetCapture(hwnd);
                          SetCursor(LoadCursor(NULL,IDC_CROSS));
                    }
                    else
                          MessageBeep(0);
              }
          return 0 ;

     case WM_RBUTTONDOWN:
         
             if(bCapturing)
             {
                   bBlocking =TRUE;
                   ptBeg.x =LOWORD(lParam);
                   ptBeg.y =HIWORD(lParam);
                   ptEnd =ptBeg;
             }

             return 0 ;

     case WM_MOUSEMOVE:
          if (bBlocking)
          {
               ptEnd.x = LOWORD (lParam) ;
               ptEnd.y = HIWORD (lParam) ;
          }
          return 0 ;

     case WM_LBUTTONUP:
     case WM_RBUTTONUP:
          if(bBlocking)
              {
                    ptEnd.x =LOWORD(lParam);
                    ptEnd.y =HIWORD(lParam);

                    if(hBitmap)
                    {
                          DeleteObject(hBitmap);
                          hBitmap =NULL;
                    }
                    hdc =GetDC(hwnd);
                    hdcMem =CreateCompatibleDC(hdc);
                    hBitmap =CreateCompatibleBitmap(hdc,abs(ptEnd.x -ptBeg.x),//?????attation: hdc belong to hwnd,but why create a bitmap about screen
                                                                          abs(ptEnd.y -ptBeg.y));
                    SelectObject(hdcMem,hBitmap);
                    StretchBlt(hdcMem,0,0,abs(ptEnd.x -ptBeg.x),abs(ptEnd.y -ptBeg.y),
                           hdc,ptBeg.x,ptBeg.y,ptEnd.x -ptBeg.x,ptEnd.y-ptBeg.y,SRCCOPY);
                    DeleteDC(hdcMem);
                    ReleaseDC(hwnd,hdc);
                    InvalidateRect(hwnd,NULL,TRUE);

              }
            
              if(bBlocking || bCapturing)
              {
                    bBlocking =bCapturing =FALSE;
                    SetCursor(LoadCursor(NULL,IDC_ARROW));
                    ReleaseCapture();
                    LockWindowUpdate(NULL);

              }
          return 0 ;

     
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          if (hBitmap)
          {
               GetClientRect (hwnd, &rect) ;

               hdcMem = CreateCompatibleDC (hdc) ;
               SelectObject (hdcMem, hBitmap) ;
               GetObject (hBitmap, sizeof (BITMAP), (PSTR) &bm) ;
               SetStretchBltMode (hdc, COLORONCOLOR) ;

               StretchBlt (hdc,    0, 0, rect.right, rect.bottom,
                           hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY) ;

               DeleteDC (hdcMem) ;
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;

    .......
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}


0
Comment
Question by:fyf7262284
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9872751
What is the question?
0
 
LVL 1

Author Comment

by:fyf7262284
ID: 9879042
question is inside the program!the place with "????" mark :
hBitmap =CreateCompatibleBitmap(hdc,abs(ptEnd.x -ptBeg.xabs(ptEnd.y -ptBeg.y));),
//?????attation: hdc belong to hwnd,but why create a bitmap about screen
                                                             
                 
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9881280
It looks like VNC code ;-)
0
 
LVL 6

Accepted Solution

by:
GloomyFriar earned 60 total points
ID: 9881308
As far as I understand there is supposed that the window
received WM _ RBUTTONUP or WM _ LBUTTONUP is foreground.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question