// Moving a window, with the mouse, without a caption
#include "FiveWin.ch"
function Main()
local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand
DEFINE CURSOR oCrsHand HAND
DEFINE WINDOW oWnd STYLE WS_POPUP COLOR "W/R"
oWnd:bLClicked := { | nRow, nCol | nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand }
oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
oWnd:nLeft + nCol - nColPos ),) }
oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }
ACTIVATE WINDOW oWnd
return nil
oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
oWnd:nLeft + nCol - nColPos,,, .T. ),) }
// Moving a window, with the mouse, without a caption
#include "FiveWin.ch"
function Main()
local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand
DEFINE CURSOR oCrsHand HAND
lRECT:=lRectWIN():new()
lRECT:AddRect( 0, 0,100,100, {|| MsgInfo("Dentro","Inside") } )
DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_WHITE, CLR_BLUE
oWnd:bLClicked := { | nRow, nCol | iif(lRECT:Check(nRow, nCol),nil,( nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand) )}
oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos, oWnd:nLeft + nCol - nColPos,,, .T. ),) }
oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }
ACTIVATE WINDOW oWnd on paint(areal(oWNd))
return nil
function areal(lWin)
// quadrado marcando o local onde o click sera capturado
RoundRect( lWin:hDC, 0 , 0 , 100, 100, 0, 0)
return
Class lRecTWIN
data xWin
data aRec
method New() constructor
method AddRect(nTop, nLeft, nBottom, nRight, bAction) INLINE AAdd(::aRec, {nTop,nLeft,nBottom,nRight, bAction})
method Check()
endclass
method New() class lRectWIN
::arec:={}
return self
method Check(x,y) CLASS lRectWIN
local ret:=.f.
for n = 1 to len(::aRec)
if (x>::aRec[n][1] .and. y>::aRec[n][2] .and. x<::aRec[n][3] .and. y<::aRec[n][4])
if (::aRec[n][5]<>Nil)
eVal(::aRec[n][5])
endif
ret:=.t.
endif
next n
return(ret)
// Moving a window, with the mouse, without a caption
#include "FiveWin.ch"
function Main()
local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand, oBmp
DEFINE CURSOR oCrsHand HAND
DEFINE BITMAP oBmp FILENAME "test.bmp"
DEFINE WINDOW oWnd STYLE WS_POPUP COLOR "W/R"
oWnd:bLClicked := { | nRow, nCol | nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand }
oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
oWnd:nLeft + nCol - nColPos,,, .T. ),) }
oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }
oWnd:SetSize( 221, 221 )
oWnd:Center()
ACTIVATE WINDOW oWnd ;
ON INIT SetTransparent( oWnd ) ;
ON PAINT PaintTransparent( hDC, oBmp:hBitmap, 0, 0 ) ;
ON RIGHT CLICK oWnd:End()
oBmp:End()
return nil
#define LWA_COLORKEY 1
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
STATIC FUNCTION SETTRANSPARENT( oDlg )
SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, NOR( GETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, CLR_RED,, LWA_COLORKEY )
RETURN NIL
function PaintTransparent( hDC, hBitmap, nRow, nCol )
local hBmpOld := SelectObject( hDC, hBitmap )
local nZeroZeroClr := GetPixel( hDC, 0, 0 )
local nOldClr
SelectObject( hDC, hBmpOld )
nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
SetBkColor( hDC, nOldClr )
return nil
oWnd:bLClicked := { | nRow, nCol | SetCapture( oWnd:hWnd ), nRowPos := nRow, nColPos := nCol, lDrag := .T.,;
oWnd:oCursor := oCrsHand }
...
oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil, ReleaseCapture() }
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot], Willi Quintana and 39 guests