********************************************************************************* * Program : DOSLIKE.PRG * Launch DosLike * Aim : Sample demonstrating very old xBase programming style under NTKRad. * Make......: Juste type MKRAD DosLike * Date : 11/17/06 * Copyright : (c) 2006 - Jn DECHEREUX. Tous droits r‚serv‚s/All Rights Reserved. #include "windows.ch" #include "ntkcctrl.ch" #include "ntkgdi.ch" #include "ntkmsg.ch" #include "ntkacc.ch" #include "ntkdlg.ch" #include "ntkmenus.ch" #include "ntkedget.ch" #include "ntkcmd.ch" #include "wNtk.ch" #include "wNtkKeys.ch" #define TAB CHR(9) #define CR CHR(13) #define CRLF CHR(13)+CHR(10) FUNCTION MAIN() LOCAL aDosFont, hDosFont LOCAL cWinTitle := " DOSLIKE: NTKRad also supports very old xBase programming style... " PRIVATE hWndMain PRIVATE cSrcData := SPACE(50) PRIVATE cDstData := SPACE(50) CREATE WINDOW hWndMain ; STYLE WND_FIXED ; EXSTYLE WS_EX_TOPMOST ; // 'Always on Top' style if you want to use all Clipper-like commands. Otherwise, you'll have to use the ON PAINT clause. SIZE 640,480 ; // Mimic a Dos Screen TITLE cWinTitle // ------------------------- Settings SET DATE FRENCH SET CENTURY ON // Here, we're preparing our screen canvas... SET PIXEL MODE OFF // default is always ON SET ROW RATIO TO 20 // default is set to 20 pixels SET COL RATIO TO 8 // default is set to 8 pixels. // Now, we can emulate a standard 25 Rows x 80 Cols Dos-Screen SET GLOBAL VALIDATION KEY TO VK_F10 // -- allow user to exit Get session by pressing Esc, PgUp, PgDn or GVK... // ----- If you need a Dos-like font, just load NTK-Dos for Clipper fixed font... NTK_AddFontResource( "NTK08X16.FON" ) // Thx to Marco Selli & JNE for their great contribution... CREATE FONT hDosFont FACENAME "NTK08X16" SIZE 16 IF hDosFont == 0 NTK_MsgBox( hWndMain, "Cannot create this font..." ) ENDIF **SET DEFAULT FONT TO NTK_GetStockObject(ANSI_FIXED_FONT) // Std Window's Fixe Font SET DEFAULT SAY FONT TO hDosFont // Ntk supplied Fixe Font ACTIVATE WINDOW hWndMain MODE NORMAL // MODE can be: NORMAL, MAXIMIZE or ICONIZE ... // ------------------------------------------------------------------------------ // --- Please Note that, to obtain a correct Win32 refresh, you should place the // --- following portion code within a specific DoRepaint() proc., which is // --- declared to the ON PAINT Clause of CREATE WINDOW... Though, it is not // --- absolutely required and works also with the old xBase way of doing things... // ------------------------------------------------------------------------------ SET COLOR TO W+/G CLEAR *@ 0,0 , __NtkMaxRow(), __NtkMaxCol() BOX // same as CLEAR @ 03,01 , 08,78 BOX NTK_BXS_SIMPLE COLOR "R+/B" SET COLOR TO B+/W+ @ 01, 10 SAY cWinTitle FONT NTK_GetStockObject(SYSTEM_FONT) SET COLOR TO G+/N @ 22,30 SAY "Hit ESC key to Quit..." SET COLOR TO W @ 10,15 SAY "Available MaxRow:" + STR( __NtkMaxRow() ) @ 12,15 SAY "Available MaxCol:" + STR( __NtkMaxCol() ) // ------------------------------------------------------------------------------ DO WHILE .T. @ 04,05 SAY "Source Datas:" GET cSrcData VALID TestGet1() PICT "@!" @ 06,05 SAY "Dest. Datas:" GET cDstData VALID TestGet2() READ IF NTK_LastKey()==K_ESC .OR. NTK_LastKey()==K_ALT_F4; .OR. NTK_LastBtn()==-1 Exit ELSEIF NTK_LastKey()==VK_F10 // You must not test K_*, but VK_* accelkey of Windows. tone(1300,1) tone( 300,1) *DoMySaveProc() ENDIF ENDDO CLEAR GETS // Must be use after READ clause : NTK_GetCtrl() is no longer activated while aGetList is empty... DELETE FONT hDosFont NTK_RemoveFontResource( "NTK08X16.FON" ) CLOSE WINDOW hWndMain RETURN ****** ****** ****** PROCEDURE TESTGET1 IF EMPTY(cSrcData) SET COLOR TO R+/N @ 00,00 SAY "This area cannot be empty! Press any key to continue..." INTO WINDOW hWndMain CLEAR TYPEAHEAD **NtkInkey(0) // Event loop. Wait until user press any key... NtkInkey(2) // Event loop. Wait for a key, but no more than 2 seconds... (not recommended in GUI environment!) SET COLOR TO W+/G @ 00,00 SAY SPACE(80) RETURN .F. ENDIF cDstData := cSrcData // Copy cSrsVar into cDstData // The following is an extra NTKRad's feature... REFRESH GETS OF hWndMain // Refresh active Get buffers - Don't forget it! RETURN .T. ****** ****** ****** PROCEDURE TESTGET2 SET COLOR TO W+/G //WAIT // The famous 'Press any key to continue..." WAIT "Press any key to EXIT from GET #2..." @ 00,00 SAY SPACE(80) tone(1000,1) tone(1000,1) RETURN .T. ****** ****** ******