home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 4
/
BUGCD1997_05.BIN
/
aplic
/
clip4win
/
clip4win.exe
/
C4W30E.HUF
/
SOURCE
/
CONTRIB
/
SPIN.ZIP
/
SPIN.PRG
< prev
Wrap
Text File
|
1993-05-30
|
6KB
|
180 lines
// Spinning Cursor - 06/30/93 - Hugh A. Lokey
// Having used FoxBase on the Mac I was impressed by the spinning
// ball cursor when something was going on. So I decided to see
// if it could be done with Clip4Win. When the computer/your
// program is doing something that might take a little time it is
// nice to give the user some visual clue that the computer is
// actually working and not "hung up". While the Windows hourglass
// cursor does do this it is not really enough in my lowly opinion!
// To use these routines you will need to have a copy of the
// Microsoft Resource Compiler (RC.EXE) to add the cursors to
// your exe file.
// Since Windows uses co-operative multi-tasking you will have to
// call SpinBall() to make the cursor change/spin. I toyed around
// with using a timer and checking for EVENT_TIMER but the code
// overhead was much higher.
// Example of usage:
//
// LoadBalls() // Only needs to be called once at the start of your
// program.
// Working(.T.,"Starting message to let user know what is going on...")
// SELECT FOO
// GO TOP
// DO WHILE !EOF()
// SpinBall()
// DO SOMETHING HERE
// SKIP
// ENDDO
// Working(.F.)
//
// DestroyBalls() // Call upon exit from your program to free up
// system resources..
// Depending on what you are doing and the speed of the machine being
// used you can include an optional delay in the call to SpinBall().
// This delay should be in hundreds of seconds. You will know if
// you need a delay when the "ball" spins so fast that it strobes and
// appears to spin backwards!
// Declare statics to hold handles to ball cursors
STATIC HBALL1,HBALL2,HBALL3,HBALL4
FUNCTION LoadBalls
HBALL1 := LoadCursor(hInst,"BALL1"+CHR(0))
HBALL2 := LoadCursor(hInst,"BALL2"+CHR(0))
HBALL3 := LoadCursor(hInst,"BALL3"+CHR(0))
HBALL4 := LoadCursor(hInst,"BALL4"+CHR(0))
RETURN(NIL)
FUNCTION DestroyBalls
DestroyCursor(HBALL1)
DestroyCursor(HBALL2)
DestroyCursor(HBALL3)
DestroyCursor(HBALL4)
RETURN(NIL)
FUNCTION Working(lOnOff,cText,cMsg)
STATIC hOldCur, hOldWnd, cOldMsg
IF lOnOff == .T.
IF cMsg != NIL
cOldMsg := cMsg
ENDIF
hOldWnd := _LasthWnd()
hOldCur := SetCursor(HBALL1)
IF cText != NIL
Message(hOldWnd,cText)
ENDIF
ELSE
SelectWindow(hOldWnd)
SetCursor(hOldcur)
IF cOldMsg != NIL
Message(hOldWnd,cOldMsg)
ENDIF
ENDIF
RETURN(NIL)
FUNCTION SpinBall(nDelay)
STATIC nBall := 1
IF nDelay != NIL
Delay(nDelay)
ENDIF
DO CASE
CASE nBall == 1
SetCursor(HBALL2)
nBall := 2
CASE nBall == 2
SetCursor(HBALL3)
nBall := 3
CASE nBall == 3
SetCursor(HBALL4)
nBall := 4
CASE nBall == 4
SetCursor(HBALL1)
nBall := 1
ENDCASE
RETURN(.T.)
// Not a very good delay function - depends on speed of machine as
// to actual delay. If anyone has a GOOD delay function I would
// very much like a copy!!!!
STATIC FUNCTION Delay(nDelay)
DO WHILE (SECONDS()+(nDelay/100)) < SECONDS()
ENDDO
RETURN(NIL)
// Delete these if you have already downloaded them....
// Display a message in a sunken message bar at the bottom of a window
FUNCTION Message(hWnd,cText)
LOCAL nLeft, nTop, nRight, nBottom, aCRect, hDC
LOCAL nOldBkClor
aCRect := GetClientRect(hWnd)
nLeft := 0
nTop := aCRect[4]-26
nRight := aCRect[3]
nBottom := nTop+28
hDC := GetDC(hWnd)
nOldBkClor := SetBkColor(hDC,RGB(192,192,192))
MsgBar(hWnd)
DrawText(hDC,cText,;
{nLeft+20,nTop+5,nRight-11,nBottom-5},DT_LEFT)
SetBkColor(hDC,nOldBkClor)
ReleaseDC(hWnd,hDC)
RETURN(NIL)
// Called by Message() to draw a sunken bar at the bottom of a window
// Can be called directly to just draw the bar.
FUNCTION MsgBar(hWnd)
LOCAL nLeft, nTop, nRight, nBottom, aCRect, hOldPen
LOCAL hDC, hColor, hBlackPen, hGreyPen, hWhitePen
hDc := GetDC(hWnd)
aCRect := GetClientRect(hWnd)
nLeft := 0
nTop := aCRect[4]-26
nRight := aCRect[3]
nBottom := nTop+26
hBlackPen := CreatePen(PS_SOLID,1,RGB(0,0,0))
hGreyPen := CreatePen(PS_SOLID,1,RGB(128,128,128))
hWhitePen := CreatePen(PS_SOLID,1,RGB(255,255,255))
hOldPen := SelectObject(hDC,hBlackPen)
Rectangle(hDC,nLeft,nTop,nRight,nBottom)
hColor := CreateSolidBrush(RGB(192,192,192))
FillRect(hDC,nLeft,nTop+1,nRight,nBottom,hColor)
SelectObject(hDC,hGreyPen)
MoveTo(hDC,nLeft+10,nBottom-4)
LineTo(hDC,nLeft+10,nTop+4)
LineTo(hDC,nRight-10,nTop+4)
SelectObject(hDC,hWhitePen)
LineTo(hDC,nRight-10,nBottom-4)
LineTo(hDC,nLeft+10,nBottom-4)
SelectObject(hDC,hOldPen)
ReleaseDC(hWnd,hDC)
DeleteObject(hColor)
DeleteObject(hBlackPen)
DeleteObject(hGreyPen)
DeleteObject(hWhitePen)
RETURN(NIL)