home *** CD-ROM | disk | FTP | other *** search
- '********************************PRTSCRN.BAS*******************************
- '
- 'JRD NOTE:
- '
- 'Another "not to be found" little program, how to disable and re-enable
- 'the Print Screen Key. Tossed in a Print Screen Toggle and the Print
- 'Screen INTERRUPT too. But the INTERRUPT was easy as that is described
- 'everywhere.....
- '
- 'Since I know that some of you will pound away at that Print Screen key,
- 'I decided to trap it.... Ha! easier said than done. The Print Screen key
- 'is handled by the ROM BIOS; there is no scan code, no ASCII code, no
- 'INTERRUPT, no nothin' way to trap that key short of Assembly, "C" or ...?
- '
- 'What I have done is... use KEY ON. And even with that you have to trap
- 'five (5) key states which do not include the Caps Locks or Num Lock keys.
- '
- 'Made a SUB to disable or toggle those keys.
- '
- '4/17/94
- '
- DEFINT A-Z
- '$INCLUDE: 'qb.bi'
- DIM SHARED Regs AS RegType
- 'CONST False = 0, True = -1
-
- 'Declares from JOHN_SUB.BAS
- 'SUBs
- DECLARE SUB ColorIt (Fgd%, Bkg%)
- DECLARE SUB CursorOff ()
- DECLARE SUB CursorOn ()
- DECLARE SUB LocateIt (Row%, Message$)
- DECLARE SUB SetBorder (ColrByte%)
- DECLARE SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- DECLARE SUB TwoColrs (Fgd%, Bkg%, Colr%)
- DECLARE SUB ToggleNumCapLock (OnOff%)
- DECLARE SUB WaitKey ()
-
- 'Functions
- DECLARE FUNCTION Center% (text$)
-
- 'Declares in PRTSCRN.BAS
- DECLARE SUB EnablePrtScrn ()
- DECLARE SUB DisablePrtScrn ()
- DECLARE SUB PrintScreen ()
- DECLARE SUB WhatKey (TheKee$)
- DECLARE SUB WhatKeyPrint (TheKee$)
-
- 'executable code below
- Copyright$ = "■Copyright (c) 1994 LearnWare (c) ■ John De Palma■"
- REDIM SHARED Box$(1 TO 56)
- Q$ = CHR$(34)
- CALL ColorIt(15, 1)
- CLS
-
- FOR i = 1 TO 25
- LOCATE i, 1
- PRINT STRING$(80, 96 + i);
- NEXT
- CALL SetBorder(2)
- CALL DisablePrtScrn
-
- CursorOff
- CALL ColorIt(11, 2)
- text$ = "Press Print Screen, BUT... it Won't WORK!"
- Message$ = SPACE$(LEN(text$))
- CALL TextBoxShadow(2, 0, Message$, 4, 1, 2)
- CALL LocateIt(3, TIME$)
- CALL LocateIt(4, text$)
- CALL ColorIt(14, 2)
- text$ = "PRESS: {Enter} to Continue"
- CALL LocateIt(5, text$)
-
- CALL ToggleNumCapLock(True) 'turns the Caps/Num Locks off
- 'or the next won't work
-
- KEY 15, CHR$(&H0) + CHR$(&H37) 'Standard no SHIFTs
- KEY 16, CHR$(&H2) + CHR$(&H37) 'Standard LEFT SHIFT
- KEY 17, CHR$(&H1) + CHR$(&H37) 'Standard RIGHT SHIFT
- KEY 18, CHR$(&H80) + CHR$(&H2A) 'Extended no SHIFTs
- KEY 19, CHR$(&H82) + CHR$(&H2A) 'Extended LEFT SHIFT
- KEY 20, CHR$(&H81) + CHR$(&H2A) 'Extended RIGHT SHIFT
-
- FOR i% = 15 TO 20
- ON KEY(i%) GOSUB PrintScreenPressed:
- KEY(i%) ON
- NEXT
-
- WhatKeyPrint (CHR$(13))
-
- CALL ColorIt(15, 1)
-
- CALL EnablePrtScrn
- CALL ColorIt(15, 4)
- text$ = "Now Press Print Screen, 'cause it WORKS!"
- Message$ = SPACE$(LEN(text$))
- CALL TextBoxShadow(9, 0, Message$, 6, 6, 2)
- CALL LocateIt(10, TIME$)
- CALL LocateIt(11, text$)
- CALL ColorIt(14, 4)
- text$ = "PRESS: <SPACE-BAR> to Continue)"
- CALL LocateIt(12, text$)
-
- WhatKey (" ")
- CALL ColorIt(15, 3)
- Message$ = "Sending a Form Feed for a Laser Printer..."
- CALL TextBoxShadow(15, 0, Message$, 1, 0, 0)
- LPRINT CHR$(12)
-
- CALL ColorIt(15, 2)
- text$ = "PRESS: " + Q$ + "P" + Q$ + " to Do a Print Screen"
- Message$ = SPACE$(LEN(text$))
- CALL TextBoxShadow(19, 0, Message$, 5, 1, 2)
- CALL LocateIt(20, TIME$)
- CALL LocateIt(21, text$)
-
- WhatKey ("P")
- CALL PrintScreen
-
- CALL ColorIt(14, 6)
- text$ = " Demonstration is ENDed "
- CALL LocateIt(22, text$)
- BEEP
- CALL SetBorder(0)
- WaitKey
- CALL ColorIt(7, 0)
- CursorOn
- CALL ToggleNumCapLock(False) 'Toggles the Caps/Num Lock keys
- END
-
-
- PrintScreenPressed:
-
- Message$ = "PrntScrn PRESSED!"
- CALL TextBoxShadow(9, 0, Message$, 6, 1, 0)
- RETURN
-
- FUNCTION Center% (text$)
- Center% = 41 - LEN(text$) \ 2
- END FUNCTION
-
- SUB ColorIt (Fgd, Bkg)
- COLOR Fgd, Bkg
- END SUB
-
- SUB CursorOff
- LOCATE , , 0
- END SUB
-
- SUB CursorOn
- LOCATE , , 1
- END SUB
-
- SUB DisablePrtScrn
-
- DEF SEG = 0
- POKE &H500, 1
- DEF SEG
-
- END SUB
-
- SUB EnablePrtScrn
-
- DEF SEG = 0
- POKE &H500, 0
- DEF SEG
-
- END SUB
-
- SUB LocateIt (Row%, text$)
- LOCATE Row%, Center(text$)
- PRINT text$;
- END SUB
-
- SUB PrintScreen STATIC
-
- 'DIM Regs AS RegType
- CALL INTERRUPT(&H5, Regs, Regs)
- LPRINT CHR$(12)
-
- END SUB
-
- SUB SetBorder (ColrByte%) STATIC
-
- 'DIM Regs AS RegType
- Regs.ax = &H1001
- Regs.bx = ColrByte% * &H100
- CALL INTERRUPT(&H10, Regs, Regs)
-
- END SUB
-
- SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
-
- 'got to have a REDIM SHARED Box$(1 to 56) in main module
- 'Other SUBs Needed for this are:
- 'TwoColrs(Fgd%, Bkg%, Colr%)
- 'LocateIt(Row%, Text$)
- '
- 'Puts a message into a three line box -or-
- 'draw a box without a message using Message$=SPACE$(x)
- 'where "x" is the width of the box and Length%= number of lines > 3
- 'Boxes are centered if Col% = 0; else left side of box = Col%.
- 'Boxes display a true shadow if Shadow% <> 0
- 'True = -1: False = 0
-
- ReturnRow% = CSRLIN
- ReturnCol% = POS(0)
- STATIC BoxReadFlag
- Message$ = LEFT$(Message$, 60)
- BoxWidth% = LEN(Message$) + 4
- SELECT CASE Outline%
- CASE 0
- j = 8 * 6 + 1
- CASE 1
- j = 1
- CASE 2
- j = 8 + 1
- CASE 3
- j = 8 * 2 + 1
- CASE 4
- j = 8 * 3 + 1
- CASE 5
- j = 8 * 4 + 1
- CASE 6
- j = 8 * 5 + 1
- CASE ELSE
- j = 8 * 6 + 1
- END SELECT
-
- IF BoxReadFlag THEN GOTO Skip
- REDIM Box$(1 TO 56)
- BoxReadFlag = True
-
- 'single line box
- Box$(1) = "┌"
- Box$(2) = "─"
- Box$(3) = "┐"
- Box$(4) = "│"
- Box$(5) = "│"
- Box$(6) = "└"
- Box$(7) = "─"
- Box$(8) = "┘"
-
- 'double top box
- Box$(9) = "╒"
- Box$(10) = "═"
- Box$(11) = "╕"
- Box$(12) = "│"
- Box$(13) = "│"
- Box$(14) = "╘"
- Box$(15) = "═"
- Box$(16) = "╛"
-
- 'double side box
- Box$(17) = "╓"
- Box$(18) = "─"
- Box$(19) = "╖"
- Box$(20) = "║"
- Box$(21) = "║"
- Box$(22) = "╙"
- Box$(23) = "─"
- Box$(24) = "╜"
-
- 'double box
- Box$(25) = "╔"
- Box$(26) = "═"
- Box$(27) = "╗"
- Box$(28) = "║"
- Box$(29) = "║"
- Box$(30) = "╚"
- Box$(31) = "═"
- Box$(32) = "╝"
-
- 'bold box
- Box$(33) = "█"
- Box$(34) = "▀"
- Box$(35) = "█"
- Box$(36) = "█"
- Box$(37) = "█"
- Box$(38) = "█"
- Box$(39) = "▄"
- Box$(40) = "█"
-
- 'bold and thick box
- Box$(41) = "█"
- Box$(42) = "█"
- Box$(43) = "█"
- Box$(44) = "█"
- Box$(45) = "█"
- Box$(46) = "█"
- Box$(47) = "█"
- Box$(48) = "█"
-
- 'no box
- Box$(49) = " "
- Box$(50) = " "
- Box$(51) = " "
- Box$(52) = " "
- Box$(53) = " "
- Box$(54) = " "
- Box$(55) = " "
- Box$(56) = " "
-
- Skip:
-
- IF Col% = 0 THEN
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- CALL LocateIt(Row%, BoxText$)
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- 'COLOR Fgd%, Bkg%
-
- COLOR 7, 0
- LOCATE Row% + i + 1, Center(BoxText$) + 2
-
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- ELSE
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- LOCATE Row%, Col%
- PRINT BoxText$;
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- 'COLOR Fgd%, Bkg%
- 'COLOR 7,0
- LOCATE Row% + i + 1, Col% + 2
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- END IF
- LOCATE ReturnRow%, ReturnCol%
- END SUB
-
- SUB ToggleNumCapLock (OnOff%)
-
- 'If OnOff% = True then turns them off, else toggles them
- DEF SEG = 0
- Address = &H417
- 'Status = PEEK(Address)
-
- IF OnOff% THEN
- POKE (Address), PEEK(Address) AND NOT 32
- POKE (Address), PEEK(Address) AND NOT 64
- ELSE
- 'Num Lock Toggle
- POKE (Address), PEEK(Address) XOR 32
- 'Caps Lock Toggle
- POKE (Address), PEEK(Address) XOR 64
- END IF
-
- DEF SEG
-
- END SUB
-
- SUB TogglePrntScrn STATIC
-
- 'If PrntScreen is disabled, it is enabled
- 'If PrntScreen is enabled, it is disabled
- 'A Toggle SUB
- 'So you call it once to disable and again to enable
- DEF SEG = 0
- Toggle = PEEK(&H500)
- IF Toggle THEN
- POKE &H500, 0
- ELSE
- POKE &H500, 1
- END IF
- DEF SEG
-
- END SUB
-
- SUB TwoColrs (Fgd%, Bkg%, Colr%)
-
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
-
- END SUB
-
- SUB WaitKey
-
- WHILE INKEY$ <> "": WEND
- DO
- Kee$ = INKEY$
- LOOP UNTIL LEN(Kee$)
- IF Kee$ = CHR$(27) THEN END
-
- END SUB
-
- SUB WhatKey (TheKee$)
-
- TheKee$ = UCASE$(TheKee$)
- DO UNTIL UCASE$(Kee$) = TheKee$
- Kee$ = INKEY$
- LOOP
-
- END SUB
-
- SUB WhatKeyPrint (TheKee$)
-
- TheKee$ = UCASE$(TheKee$)
- DO UNTIL UCASE$(Kee$) = TheKee$
- Kee$ = INKEY$
-
- DO
- FColr = INT((15 - 0 + 1) * RND + 0)
- BColr = INT((7 - 0 + 1) * RND + 0)
- LOOP UNTIL FColr <> BColr
- CALL ColorIt(FColr, BColr)
- CALL LocateIt(14, "PrntScrn Waiting...")
- LOOP
-
- END SUB
-
-