#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
#include "fivewin.ch"
function Main()
public oWnd
DEFINE DIALOG ownd title "FiveWin - Move"
ACTIVATE dialog oWnd centered ON LEFT CLICK DRAGDLG( ownd )
return nil
STATIC FUNCTION DRAGDLG( oDlg )
LOCAL aCoo := GETWNDRECT( oDlg:hWnd )
LOCAL aOrg := GETCURSORPOS()
LOCAL aPos, i
WHILE GETKEYSTATE( VK_RBUTTON )
aPos = GETCURSORPOS()
oDlg:oCursor := oCrsHand
MOVEWINDOW( oDlg:hWnd, aCoo[ 1 ] + aPos[ 1 ] - aOrg[ 1 ], aCoo[ 2 ] + aPos[ 2 ] - aOrg[ 2 ],,,.T.)
FOR i = 1 TO 10
SYSREFRESH()
NEXT
ENDDO
RETURN NIL
// Testing how to scroll a window with its contents
//PAN function
#include "FiveWin.ch"
#define D_WIDTH 4
#define D_HEIGHT 13
FUNCTION Main()
LOCAL oWnd,oScrWnd,nRowPos, nColPos, lDrag := .F.
LOCAL cGet0101 := space(10), ; //Row 1
cGet0102 := space(10), ;
cGet0103 := space(10), ;
cGet0104 := space(10), ;
cGet0105 := space(10), ;
cGet0201 := space(10), ; //Row 2
cGet0202 := space(10), ;
cGet0203 := space(10), ;
cGet0204 := space(10), ;
cGet0205 := space(10), ;
cGet0301 := space(10), ; //Row 3
cGet0302 := space(10), ;
cGet0303 := space(10), ;
cGet0304 := space(10), ;
cGet0305 := space(10), ;
cGet0401 := space(10), ; //Row 4
cGet0402 := space(10), ;
cGet0403 := space(10), ;
cGet0404 := space(10), ;
cGet0405 := space(10), ;
cGet0501 := space(10), ; //Row 5
cGet0502 := space(10), ;
cGet0503 := space(10), ;
cGet0504 := space(10), ;
cGet0505 := space(10), ;
cGet0601 := space(10), ; //Row 6
cGet0602 := space(10), ;
cGet0603 := space(10), ;
cGet0604 := space(10), ;
cGet0605 := space(10), ;
cGet0701 := space(10), ; //Row 7
cGet0702 := space(10), ;
cGet0703 := space(10), ;
cGet0704 := space(10), ;
cGet0705 := space(10), ;
cGet0801 := space(10), ; //Row 8
cGet0802 := space(10), ;
cGet0803 := space(10), ;
cGet0804 := space(10), ;
cGet0805 := space(10), ;
cGet0901 := space(10), ; //Row 9
cGet0902 := space(10), ;
cGet0903 := space(10), ;
cGet0904 := space(10), ;
cGet0905 := space(10), ;
cGet1001 := space(10), ; //Row 10
cGet1002 := space(10), ;
cGet1003 := space(10), ;
cGet1004 := space(10), ;
cGet1005 := space(10), ;
cGet1101 := space(10), ; //Row 11
cGet1102 := space(10), ;
cGet1103 := space(10), ;
cGet1104 := space(10), ;
cGet1105 := space(10)
local oCrsHand
DEFINE CURSOR oCrsHand HAND
oWnd = TMyWindow():New( 0, 0, 25, 70, "Scroll Window",,,,,, .T., .T. )
/*
define window oWnd from 0, 0 TO 25, 70 ;
title "Scroll Window" ;
vscroll hscroll
*/
@ 9,17 bitmap file "..\bitmaps\pic1.bmp" of oWnd size 120,148 adjust
@ 9,32 bitmap file "..\bitmaps\pic2.bmp" of oWnd size 120,148 adjust
@ 9,47 bitmap file "..\bitmaps\pic3.bmp" of oWnd size 120,148 adjust
@ 9,62 bitmap file "..\bitmaps\pic4.bmp" of oWnd size 120,148 adjust
@ 9,77 bitmap file "..\bitmaps\pic5.bmp" of oWnd size 120,148 adjust
@ 21*13,02*8 say "Customer " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 23*13,02*8 say "P.O. # " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 25*13,02*8 say "Style No." of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 27*13,02*8 say "Fabrics " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 29*13,02*8 say "Fob " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 31*13,02*8 say "Q'TY " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 33*13,02*8 say "DEL. " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 35*13,02*8 say "MAKER " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 37*13,02*8 say "QTA " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 39*13,02*8 say "SIZE " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 41*13,02*8 say "Size B/D " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 43*13,02*8 say "REMARKS " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 21*13,17*8 say "Venture " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 21*13,32*8 say "Sears " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 21*13,47*8 say "Kohl's " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 21*13,62*8 say "Kiss " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
@ 21*13,77*8 say "K-MART " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
//-* Row 1
@ 23*13,17*8 get cGet0101 size 120,26 of oWnd update pixel
@ 23*13,32*8 get cGet0102 size 120,26 of oWnd update pixel
@ 23*13,47*8 get cGet0103 size 120,26 of oWnd update pixel
@ 23*13,62*8 get cGet0104 size 120,26 of oWnd update pixel
@ 23*13,77*8 get cGet0105 size 120,26 of oWnd update pixel
//-* Row 2
@ 25*13,17*8 get cGet0201 size 120,26 of oWnd update pixel
@ 25*13,32*8 get cGet0202 size 120,26 of oWnd update pixel
@ 25*13,47*8 get cGet0203 size 120,26 of oWnd update pixel
@ 25*13,62*8 get cGet0204 size 120,26 of oWnd update pixel
@ 25*13,77*8 get cGet0205 size 120,26 of oWnd update pixel
//-* Row 3
@ 27*13,17*8 get cGet0301 size 120,26 of oWnd update pixel
@ 27*13,32*8 get cGet0302 size 120,26 of oWnd update pixel
@ 27*13,47*8 get cGet0303 size 120,26 of oWnd update pixel
@ 27*13,62*8 get cGet0304 size 120,26 of oWnd update pixel
@ 27*13,77*8 get cGet0305 size 120,26 of oWnd update pixel
//-* Row 4
@ 29*13,17*8 get cGet0401 size 120,26 of oWnd update pixel
@ 29*13,32*8 get cGet0402 size 120,26 of oWnd update pixel
@ 29*13,47*8 get cGet0403 size 120,26 of oWnd update pixel
@ 29*13,62*8 get cGet0404 size 120,26 of oWnd update pixel
@ 29*13,77*8 get cGet0405 size 120,26 of oWnd update pixel
//-* Row 5
@ 31*13,17*8 get cGet0501 size 120,26 of oWnd update pixel
@ 31*13,32*8 get cGet0502 size 120,26 of oWnd update pixel
@ 31*13,47*8 get cGet0503 size 120,26 of oWnd update pixel
@ 31*13,62*8 get cGet0504 size 120,26 of oWnd update pixel
@ 31*13,77*8 get cGet0505 size 120,26 of oWnd update pixel
//-* Row 6
@ 33*13,17*8 get cGet0601 size 120,26 of oWnd update pixel
@ 33*13,32*8 get cGet0602 size 120,26 of oWnd update pixel
@ 33*13,47*8 get cGet0603 size 120,26 of oWnd update pixel
@ 33*13,62*8 get cGet0604 size 120,26 of oWnd update pixel
@ 33*13,77*8 get cGet0605 size 120,26 of oWnd update pixel
//-* Row 7
@ 35*13,17*8 get cGet0701 size 120,26 of oWnd update pixel
@ 35*13,32*8 get cGet0702 size 120,26 of oWnd update pixel
@ 35*13,47*8 get cGet0703 size 120,26 of oWnd update pixel
@ 35*13,62*8 get cGet0704 size 120,26 of oWnd update pixel
@ 35*13,77*8 get cGet0705 size 120,26 of oWnd update pixel
//-* Row 8
@ 37*13,17*8 get cGet0801 size 120,26 of oWnd update pixel
@ 37*13,32*8 get cGet0802 size 120,26 of oWnd update pixel
@ 37*13,47*8 get cGet0803 size 120,26 of oWnd update pixel
@ 37*13,62*8 get cGet0804 size 120,26 of oWnd update pixel
@ 37*13,77*8 get cGet0805 size 120,26 of oWnd update pixel
//-* Row 9
@ 39*13,17*8 get cGet0901 size 120,26 of oWnd update pixel
@ 39*13,32*8 get cGet0902 size 120,26 of oWnd update pixel
@ 39*13,47*8 get cGet0903 size 120,26 of oWnd update pixel
@ 39*13,62*8 get cGet0904 size 120,26 of oWnd update pixel
@ 39*13,77*8 get cGet0905 size 120,26 of oWnd update pixel
//-* Row 10
@ 41*13,17*8 get cGet1001 size 120,26 of oWnd update pixel
@ 41*13,32*8 get cGet1002 size 120,26 of oWnd update pixel
@ 41*13,47*8 get cGet1003 size 120,26 of oWnd update pixel
@ 41*13,62*8 get cGet1004 size 120,26 of oWnd update pixel
@ 41*13,77*8 get cGet1005 size 120,26 of oWnd update pixel
//-* Row 11
@ 43*13,17*8 get cGet1101 size 120,26 of oWnd update pixel
@ 43*13,32*8 get cGet1102 size 120,26 of oWnd update pixel
@ 43*13,47*8 get cGet1103 size 120,26 of oWnd update pixel
@ 43*13,62*8 get cGet1104 size 120,26 of oWnd update pixel
@ 43*13,77*8 get cGet1105 size 120,26 of oWnd update pixel
@ 50,20 button "&Ok" size 80,20 of oWnd ;
action (MsgInfo("You click OK button!"),oWnd:End())
@ 50,40 button "&Cancel" size 80,20 of oWnd ;
action (MsgInfo("You click Cancel button!"),oWnd:End())
oWnd:bMMoved := { |nRow, nCol |;
iif(lDrag = .t.,;
( Sysrefresh(),;
(ScrollWindow( oWnd:hWnd, 0, ;
( nRowPos - nRow )*D_HEIGHT, ;
0, GetClientRect(oWnd:hWnd) ), nRowPos := nRow), ;
ScrollWindow( oWnd:hWnd,;
(nColPos- nCol )*D_WIDTH,0, ;
0,GetClientRect(oWnd:hWnd) ),nColPos := nCol ) , ) }
// oWnd:bLButtonUp := { |y,x | msginfo(3) }
// oWnd:brClicked := { |y,x | msginfo(4) }
oWnd:bMButtonDown := { | nRow, nCol |( oWnd:oCursor := oCrsHand,;
nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand) }
oWnd:bMButtonUp := { |y,x | oWnd:oCursor := nil,lDrag := .F. }
ACTIVATE WINDOW oWnd ;
ON INIT ( TScrWnd():New(oWnd,1,40,1,70) )
RETURN( NIL )
CLASS TMyWindow FROM TWindow
CLASSDATA lRegistered AS LOGICAL
DATA bMouseWheel
METHOD MouseWheel( nKey, nDelta, nXPos, nYPos ) INLINE ;
If( ::bMouseWheel != nil, Eval( ::bMouseWheel, nKey, nDelta, nXPos, nYPos ),)
ENDCLASS
//============================================================================
// FileName : SCROLL.PRG
// Purpose : Windows Scroll Class
// Author : Eric Yang
// Update History :
// Date Contents
// ---------- ---------------------------------------------------------------
// 1997.02.01
//
//============================================================================
#include "FiveWin.ch"
#ifndef TRUE
#define TRUE .T.
#define FALSE .F.
#endif
CLASS TScrWnd
DATA oWnd
DATA nVPos,nHPos
METHOD New( oWnd,nV1,nV2,nH1,nH2 ) CONSTRUCTOR
METHOD SetScroll( nV1,nV2,nH1,nH2 )
//-*------------------------------------------------------------
METHOD VScroll()
METHOD VScrollThumb()
METHOD VScrollTrack()
METHOD VScrollPgDown()
METHOD VScrollPgUp()
//-*-----------------------------
METHOD HScroll()
METHOD HScrollThumb()
METHOD HScrollTrack()
METHOD HScrollPgDown()
METHOD HScrollPgUp()
ENDCLASS
METHOD New( oWnd,nV1,nV2,nH1,nH2 ) CLASS TScrWnd
::nVPos := 0
::nHPos := 0
::oWnd := oWnd
::SetScroll( nV1,nV2,nH1,nH2 )
::oWnd:bMouseWheel = { | nKey, nDelta, nXPos, nYPos |If( nDelta < 0, ::oWnd:oVScroll:GoDown(), ::oWnd:oVScroll:GoUp() ) }
RETURN Self
METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrWnd
LOCAL aCoors1:={},aCoors2:={}
//--------------------------------------------------
//-* Vertical Scroll Bar
// ? ::oWnd:oVSCroll=NIL
if ::oWnd:oVScroll != NIL
// ? nV1,nV2
::oWnd:oVScroll:SetRange( nV1,nV2 )
::nVPos := ::oWnd:oVScroll:GetPos()
::oWnd:oVScroll:bGoDown := {|| ::VScroll() }
::oWnd:oVScroll:bGoUp := {|| ::VScroll() }
::oWnd:oVScroll:bPageUp := {|| ::VScrollPgUp() }
::oWnd:oVScroll:bPageDown := {|| ::VScrollPgDown() }
::oWnd:oVScroll:bGoTop := {|| ::VScroll() }
::oWnd:oVScroll:bGoBottom := {|| ::VScroll() }
::oWnd:oVScroll:nPgStep := 10
//::oWnd:oVScroll:lReDraw := TRUE
::oWnd:oVScroll:bPos := {|nPos| ::VScrollThumb(nPos) }
::oWnd:oVScroll:bTrack := {|nPos| ::VScrollTrack(nPos) }
endif
//--------------------------------------------------
//-* Horizontal Scroll Bar
if ::oWnd:oHScroll != NIL
::oWnd:oHScroll:SetRange( nH1,nH2 )
::nHPos := ::oWnd:oHScroll:GetPos()
::oWnd:oHScroll:bGoDown := {|| ::HScroll() }
::oWnd:oHScroll:bGoUp := {|| ::HScroll() }
::oWnd:oHScroll:bPageUp := {|| ::HScrollPgUp() }
::oWnd:oHScroll:bPageDown := {|| ::HScrollPgDown() }
::oWnd:oHScroll:bGoTop := {|| ::HScroll() }
::oWnd:oHScroll:bGoBottom := {|| ::HScroll() }
::oWnd:oHScroll:nPgStep := 10
//::oWnd:oHScroll:lReDraw := TRUE
::oWnd:oHScroll:bPos := {|nPos| ::HScrollThumb(nPos) }
::oWnd:oHScroll:bTrack := {|nPos| ::HScrollTrack(nPos) }
endif
//::oWnd:bKeyChar := {|nKey,nFlags| ScrollKey(nKey) }
//--------------------------------------------------
RETURN( NIL )
//STATIC FUNCTION ScrollKey(nKey)
//MsgInfo( "Key : "+str(nKey,10) )
//if nKey == K_ENTER
// goMainDlg:End()
// lRetVal := TRUE
//endif
//RETURN( NIL )
//=================================================================
//-* Vertical Scroll Bar
METHOD VScroll() CLASS TScrWnd
LOCAL nNewPos
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
nNewPos := ::oWnd:oVScroll:GetPos()
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos-nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )
METHOD VScrollThumb(nNewPos) CLASS TScrWnd
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
::oWnd:oVScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
(::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )
METHOD VScrollTrack(nNewPos) CLASS TScrWnd
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
::oWnd:oVScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
(::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )
METHOD VScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
if ::nVPos < ::oWnd:oVScroll:nMax
nNewPos := ::nVPos + ::oWnd:oVScroll:nPgStep
nNewPos := iif(nNewPos > ::oWnd:oVScroll:nMax, ::oWnd:oVScroll:nMax, nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )
METHOD VScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
if ::nVPos > ::oWnd:oVScroll:nMin
nNewPos := ::nVPos - ::oWnd:oVScroll:nPgStep
nNewPos := iif(nNewPos < ::oWnd:oVScroll:nMin,::oWnd:oVScroll:nMin,nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )
//=================================================================
//-* Horizontal Scroll Bar
METHOD HScroll() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
nNewPos := ::oWnd:oHScroll:GetPos()
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )
METHOD HScrollThumb(nNewPos) CLASS TScrWnd
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
::oWnd:oHScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )
METHOD HScrollTrack(nNewPos) CLASS TScrWnd
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
::oWnd:oHScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )
METHOD HScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos < ::oWnd:oHScroll:nMax
nNewPos := ::nHPos + ::oWnd:oHScroll:nPgStep
nNewPos := iif(nNewPos > ::oWnd:oHScroll:nMax, ::oWnd:oHScroll:nMax, nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
( ::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )
METHOD HScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos > ::oWnd:oHScroll:nMin
nNewPos := ::nHPos - ::oWnd:oHScroll:nPgStep
nNewPos := iif(nNewPos < ::oWnd:oHScroll:nMin,::oWnd:oHScroll:nMin,nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
( ::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )
//=* End of File =================================================
procedure AppSys // Xbase++ requirement
return
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 58 guests