Author Topic: DrawFocusRect Demo  (Read 211 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7608
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
DrawFocusRect Demo
« on: June 29, 2020, 10:32:43 PM »
This is a demo of mouse selection of a rectangular area in a client area of a Window. Currently it just draws a 1 pixel wide rectangle but its a test of copying a cropped area using BitBlt saved to a bitmap. The action part of the demo is below. Note that this demo only works with top left to bottom right co-ordinated, I have not done the rest yet. Click in the client area and drag the mouse down and right and you will get the focus rectangle, release the button and it will draw a single line rectangle on the screen.

      ; ----------------------------------------------------------------

      .case WM_LBUTTONDOWN
        mov rDC, rvcall(GetDC,hWin)
        GetClientCursorPos hWin,rrct            ; set the top X,Y
        .return 0

      ; ----------------------------------------------------------------

      .case WM_MOUSEMOVE

      .If wParam eq MK_LBUTTON
        rcall DrawFocusRect,rDC,ptr$(rrct)      ; cancels current rct

        GetClientCursorPos hWin,pt              ; get the new lower X Y
        mrmd rrct.right, pt.x                   ; copy to lower X Y struct
        mrmd rrct.bottom, pt.y

        rcall DrawFocusRect,rDC,ptr$(rrct)      ; draw new rct
        rcall SleepEx,20,0                      ; set display delay
      .EndIf

      ; ----------------------------------------------------------------

      .case WM_LBUTTONUP
        rcall DrawFocusRect,rDC,ptr$(rrct)      ; remove the focus rectangle

        rcall FrameRect,rDC,ptr$(rrct),Brush2   ; draw the rct to remain

        mov rrct.left,   0                      ; clear the global rect structure
        mov rrct.top,    0
        mov rrct.right,  0
        mov rrct.bottom, 0

        rcall ReleaseDC,hWin,rDC
        .return 0

      ; ----------------------------------------------------------------
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: