Announcement

Collapse
No announcement yet.

Region inside a rect or: "Selfmade frame and region-handling for beginners"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Region inside a rect or: "Selfmade frame and region-handling for beginners"

    Hi again!

    This doesn't seem to be hard, maybe I'm am too tired to see the quick solution...

    I've got a window with a subclassed GRAPHIC CONTROL on it- they've got the same size. So I draw something like a frame on it with the PB GRAPHIC functions, and now I want to make everything transparent, which is IN the frame.

    Code:
    FUNCTION DRAW_TRANSPARENT_BOX(BYVAL hWND AS DWORD, BYVAL lCTRLID AS LONG) AS LONG
       TRY      
          LOCAL lSTRENGHT AS LONG
          lSTRENGHT = 3              'This is how thick the line should be
    
          LOCAL lWidth, lHeight AS LONG
          CONTROL GET SIZE hWND, lCTRLID TO lWidth,lHeight 'The dimensions are already "pixels" so no conversion needed...!
          
          'Draw everything I want (the "selfmade frame" in this case)
          GRAPHIC ATTACH hWND,lCTRLID
          GRAPHIC CLEAR %WHITE
          GRAPHIC WIDTH lStrenght
          GRAPHIC BOX (0,0)-(lWidth,lHeight),0,%BLACK,%WHITE
          
          'So far so good, now the hard(?) part
          LOCAL QDRRect AS RECT
          GetWindowRect(hWND, QDRRect)
          
          'Now substract the line from my RECT
          QDRRect.nLEFT   = QDRRect.nLEFT     + lSTRENGHT
          QDRRect.nRIGHT  = QDRRect.nRIGHT    - lSTRENGHT
          QDRRect.nTOP    = QDRRect.nTOP      - lSTRENGHT
          QDRRect.nBOTTOM = QDRRect.nBOTTOM   + lSTRENGHT
          
          LOCAL hRGNQDR AS DWORD
          hRGNQDR = CreateRectRgnIndirect(QDRRect)
          
          IF hRGNQDR THEN                           
             SetWindowRgn(hWnd , hRGNQDR, %FALSE)   'Everything IN the frame should be invisible
          ELSE
             MSGBOX STR$(GetLastError())
          END IF
          
        CATCH
          MSGBOX "Error #" + STR$(ERR) + " in " + FUNCNAME$, %MB_OK OR %MB_ICONERROR, "Internal Error ("+FUNCNAME$+")!"
        END TRY
    
    END FUNCTION
    Whats wrong here?

    Thanks again, best regards from a tired and frustrated
    Marc Giesmann
Working...
X