home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 June / PCWorld_2002-06_cd.bin / Software / Komercni / xbase / express / exd17208.r04 / exp17 / Samples / Xdemo.prg < prev    next >
Text File  |  2002-02-07  |  11KB  |  374 lines

  1. /*
  2.  ╓─────────────────────────────────────────────────────────────────╖
  3.  ║  Program..: XDEMO.PRG                                           ║
  4.  ║  Author...: Roger J. Donnay                                     ║
  5.  ║  Notice...: (c) DONNAY Software Designs 1987-2001               ║
  6.  ║  Date.....: Sep 15, 2001                                        ║
  7.  ║  Notes....: eXPress Demo Program                                ║
  8.  ╙─────────────────────────────────────────────────────────────────╜
  9.  
  10.  This sample program is a menu system used to select one of five
  11.  other demonstration programs included in XDEMO*.PRG and XSAMPLE*.PRG
  12. */
  13.  
  14. #include "dcdialog.ch"
  15. #include "dcbitmap.ch"
  16. #include "dcicon.ch"
  17. #include "appevent.ch"
  18. #include "inkey.ch"
  19.  
  20. #define VK_NUMLOCK        0x90
  21. #define VK_SCROLL         0x91
  22. #define VK_CAPITAL        0x14
  23. #define APPKEY_PRESSED    2
  24.  
  25. STATIC bActiveBlock, oDialog
  26.  
  27. FUNCTION XDemo()
  28.  
  29. LOCAL Getlist, GetOptions, lDebugMode := .f., oDebug, ;
  30.       oAppWindow := SetAppWindow(), oMenuBar, oMenuFile, ;
  31.       oMenuSample, oMenuApp, nEvent, mp1, mp2, oXbp, oMsgBox, ;
  32.       cVersion, oStatBottom, oToolBottom, oMsgStatic, ;
  33.       oNumStatic, oCapsStatic, oInsStatic, oThread, nWidth, ;
  34.       nHeight, nWindowWidth, nWindowHeight, nColPixels, nRowPixels,;
  35.       cSayFont, cGetFont
  36.  
  37. Private oTest
  38.  
  39. DC_Gui(.t.)
  40. DC_IconDefault(ICON_EXPRESS)
  41.  
  42. #ifdef EXPRESS20
  43.   ErrorBlock({|e|DC_ErrorGui(e)})
  44.   DC_SetdCLIP('..\DICT')
  45. #endif
  46.  
  47. DC_DotHotKey(xbeK_ALT_F12)
  48.  
  49. GetList := {}
  50. SET PATH TO ..\DATA
  51.  
  52. DC_ChDir(DC_Path(AppName(.t.)))
  53.  
  54. DCMENUBAR oMenuBar EVAL {|o|o:endMenu := {||oMsgBox:setCaption('')} }
  55.  
  56. /* ---- File Submenu ---- */
  57.  
  58. DCSUBMENU oMenuFile PROMPT "&File" PARENT oMenuBar ;
  59.    MESSAGE 'Select Demo Run Mode' INTO oMsgBox
  60.  
  61.   DCMENUITEM "E~xit" PARENT oMenuFile ;
  62.      ACTION _ActiveBlock( {|o|_XDemoExit(GetList)} ) ;
  63.      MESSAGE 'Quit the eXPress++ Demo Program' INTO oMsgBox
  64.  
  65. /* ---- Application Submenu ---- */
  66.  
  67. DCSUBMENU oMenuApp PROMPT "&Applications" PARENT oMenuBar ;
  68.    MESSAGE 'Miscellaneous Applications (with source code)' INTO oMsgBox
  69.  
  70.    DCMENUITEM "~Collection" PARENT oMenuApp ;
  71.       MESSAGE 'My personal Inventory' INTO oMsgBox ;
  72.       ACTION _ActiveBlock( {|o|XDemo_1(oDialog:drawingArea)} )  // XDEMO1.PRG
  73.  
  74.    DCMENUITEM "~Documentor - XDoc" PARENT oMenuApp ;
  75.       MESSAGE 'My documentor' INTO oMsgBox ;
  76.       ACTION _ActiveBlock( {|o|XDoc(oDialog:drawingArea)} )  // XDOC.PRG
  77.  
  78.    DCMENUITEM "ClipBoard Capture - XClipDoc" PARENT oMenuApp ;
  79.       MESSAGE 'My Clipboard Capture' INTO oMsgBox ;
  80.       ACTION _ActiveBlock( {|o|XClipDoc(oDialog:drawingArea)} )  // CLIPDOC.PRG
  81.  
  82. /* ---- Samples Submenu ---- */
  83.  
  84. DCSUBMENU oMenuSample PROMPT "~Samples" PARENT oMenuBar ;
  85.    MESSAGE 'Miscellanous Samples and Demo Programs (with source code)' ;
  86.      INTO oMsgBox
  87.  
  88.    DCMENUITEM "~Sample Group 1" PARENT oMenuSample  ;
  89.       MESSAGE 'Run Sample Group #1' INTO oMsgBox ;
  90.       ACTION _ActiveBlock( {|o|X_Samples_1(oDialog:drawingArea)} )  // XSAMPLE1.PRG
  91.  
  92.    DCMENUITEM "~Sample Group 2" PARENT oMenuSample ;
  93.       MESSAGE 'Run Sample Group #2' INTO oMsgBox ;
  94.       ACTION _ActiveBlock( {|o|X_Samples_2(oDialog:drawingArea)} )  // XSAMPLE2.PRG
  95.  
  96.    DCMENUITEM "~Sample Group 3" PARENT oMenuSample ;
  97.       MESSAGE 'Run Sample Group #3' INTO oMsgBox ;
  98.       ACTION _ActiveBlock( {|o|X_Samples_3(oDialog:drawingArea)} )  // XSAMPLE3.PRG
  99.  
  100.    DCMENUITEM "~Sample Group 4" PARENT oMenuSample ;
  101.       MESSAGE 'Run Sample Group #4' INTO oMsgBox ;
  102.       ACTION _ActiveBlock( {|o|X_Samples_4(oDialog:drawingArea)} )  // XSAMPLE4.PRG
  103.  
  104.    DCMENUITEM "~Sample Group 5" PARENT oMenuSample ;
  105.       MESSAGE 'Run Sample Group #5' INTO oMsgBox ;
  106.       ACTION _ActiveBlock( {|o|X_Samples_5(oDialog:drawingArea)} )  // XSAMPLE5.PRG
  107.  
  108.    DCMENUITEM "~Sample Group 6" PARENT oMenuSample ;
  109.       MESSAGE 'Run Sample Group #6' INTO oMsgBox ;
  110.       ACTION _ActiveBlock( {|o|X_Samples_6(oDialog:drawingArea)} )  // XSAMPLE6.PRG
  111.  
  112.    DCMENUITEM SEPARATOR PARENT oMenuSample
  113.  
  114.    DCMENUITEM "Demo Program 2" PARENT oMenuSample ;
  115.       MESSAGE 'Run Demo Program #2' INTO oMsgBox ;
  116.       ACTION _ActiveBlock( {|o|XDemo_2(oDialog:drawingArea)} ) // XDEMO2.PRG
  117.  
  118.    DCMENUITEM "Demo Program 3" PARENT oMenuSample ;
  119.       MESSAGE 'Run Demo Program #3' INTO oMsgBox ;
  120.       ACTION _ActiveBlock( {|o|XDemo_3(oDialog:drawingArea)} ) // XDEMO3.PRG
  121.  
  122.    DCMENUITEM "Demo Program 4 (Gui)" PARENT oMenuSample ;
  123.       MESSAGE 'Run Demo Program #4 in Gui Mode' INTO oMsgBox ;
  124.       ACTION _ActiveBlock( {|o|XDemo_4(oDialog:drawingArea,.t.)} )  // XDEMO4.PRG
  125.  
  126.    DCMENUITEM "Demo Program 4 (Text)" PARENT oMenuSample ;
  127.       MESSAGE 'Run Demo Program #4 in Text Mode' INTO oMsgBox ;
  128.       ACTION _ActiveBlock( {|o|XDemo_4(oDialog:drawingArea,.f.)} ) // XDEMO4.PRG
  129.  
  130.    DCMENUITEM "Demo Program 5" PARENT oMenuSample ;
  131.       MESSAGE 'Run Demo Program #5' INTO oMsgBox ;
  132.       ACTION _ActiveBlock( {|o|XDemo_5(oDialog:drawingArea)} )  // XDEMO5.PRG
  133.  
  134.  
  135. // Bottom Statusbar with message, scrollbar, buttons, key status
  136. DCSTATUSBAR oStatBottom HEIGHT 28 ALIGN DCGUI_ALIGN_BOTTOM
  137.  
  138. @ 3,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX ;
  139.       SIZE 450,20 ;
  140.       PARENT oStatBottom PIXEL OBJECT oMsgStatic
  141.  
  142. @ 1,2 DCSAY '' ;
  143.       SIZE 450,18 ;
  144.       SAYCENTER ;
  145.       COLOR GRA_CLR_BLUE, GRA_CLR_BACKGROUND ;
  146.       OBJECT oMsgBox PARENT oMsgStatic PIXEL ;
  147.       FONT '8.Tahoma'
  148.  
  149. @ 3,0 DCTOOLBAR oToolBottom SIZE 84,20 BUTTONSIZE 40,20 ;
  150.       TYPE XBPSTATIC_TYPE_RECESSEDBOX PARENT oStatBottom PIXEL
  151.  
  152. DCADDBUTTON CAPTION '&Exit' ;
  153.   ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)} ;
  154.   PARENT oToolBottom PIXEL ;
  155.   WHEN {||Valtype(DC_GetCargo(oDialog))#'L'.OR.!DC_GetCargo(oDialog)} ;
  156.   TOOLTIP 'Exit this Demo Program'
  157.  
  158. DCADDBUTTON TYPE XBPSTATIC_TYPE_RAISEDBOX SIZE 3,22 ;
  159.   PARENT oToolBottom PIXEL
  160.  
  161. DCADDBUTTON CAPTION '~View' ;
  162.   ACTION {||DC_ArrayView(AppDeskTop())} ;
  163.   PARENT oToolBottom PIXEL ;
  164.   TOOLTIP 'View/Browse the Application Object Tree'
  165.  
  166. @ 3,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX ;
  167.       SIZE 30,20 PARENT oStatBottom PIXEL OBJECT oCapsStatic
  168.  
  169. @ 3,1 DCSAY 'Caps' PARENT oCapsStatic ID 'CAPSLOCK' ;
  170.       SAYSIZE 28,18 SAYCENTER PIXEL FONT '7.Helv'
  171.  
  172. @ 3,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX ;
  173.       SIZE 30,20 PARENT oStatBottom PIXEL OBJECT oNumStatic
  174.  
  175. @ 3,1 DCSAY 'Num' PARENT oNumStatic ID 'NUMLOCK' ;
  176.       SAYSIZE 28,18 SAYCENTER PIXEL FONT '7.Helv'
  177.  
  178. @ 3,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX ;
  179.       SIZE 30,20 PARENT oStatBottom PIXEL OBJECT oInsStatic
  180.  
  181. @ 3,1 DCSAY '' PARENT oInsStatic ID 'INSERT' ;
  182.       SAYSIZE 28,18 SAYCENTER PIXEL FONT '7.Helv'
  183.  
  184.  
  185. // @ 2, 5 DCSTATIC XBPSTATIC_TYPE_TEXT SIZE 25,1 /*COLOR GRA_CLR_RED*/ ;
  186. //        CAPTION 'test' OBJECT M->oTest FONT '10.Arial CE' ;
  187. //        OPTIONS XBPSTATIC_TEXT_CENTER+XBPSTATIC_TEXT_VCENTER
  188.  
  189.  
  190. DCHOTKEY xbeK_INS ACTION {||ReadInsert(!ReadInsert())}
  191.  
  192. nWidth := AppDeskTop():currentSize()[1]
  193. nHeight := AppDeskTop():currentSize()[2]
  194.  
  195. IF nWidth <= 800
  196.   nWindowWidth := 640
  197.   nWindowHeight := 500
  198.   cSayFont := '7.Helv'
  199.   cGetFont := '9.Courier New'
  200.   nColPixels := 7
  201.   nRowPixels := 20
  202. ELSEIF nWidth <= 1024
  203.   nWindowWidth := 800
  204.   nWindowHeight := 600
  205.   cSayFont := '8.Helv'
  206.   cGetFont := '10.Courier New'
  207.   nColPixels := 8.5
  208.   nRowPixels := 24
  209. ELSEIF nWidth <= 1280
  210.   nWindowWidth := 1000
  211.   nWindowHeight := 800
  212.   cSayFont := '10.Helv'
  213.   cGetFont := '11.Courier New'
  214.   nColPixels := 10
  215.   nRowPixels := 28
  216. ELSE
  217.   nWindowWidth := 1200
  218.   nWindowHeight := 1000
  219.   cSayFont := '11.Helv'
  220.   cGetFont := '12.Courier New'
  221.   nColPixels := 11.5
  222.   nRowPixels := 32
  223. ENDIF
  224.  
  225. DCGETOPTIONS ;
  226.    WINDOWHEIGHT nWindowHeight ;
  227.    WINDOWWIDTH nWindowWidth ;
  228.    HELPFILE '..\DOC\EXPRESS.HLP' ;
  229.    BITMAP BITMAP_EXPRESS_BACKGROUND1 ;
  230.    ICON ICON_EXPRESS ;
  231.    NOBUSY ;
  232.    SAYFONT cSayFont ;
  233.    GETFONT cGetFont ;
  234.    FONT cSayFont ;
  235.    COLPIXELS nColPixels ;
  236.    ROWPIXELS nRowPixels ;
  237.    ROWSPACE nRowPixels ;
  238.    AUTOWINDOWMENU ;
  239.    TOOLTIPCOLOR GRA_CLR_BLACK, GRA_CLR_YELLOW ;
  240.    ABORTQUERY MSG {||DC_MsgBox(,,{'Exit eXPress++ Demo?'},,,,.t.)} ;
  241.    CLOSEQUERY MSG {||DC_MsgBox(,,{'Exit eXPress++ Demo?'},,,,.t.)} ;
  242.    EVAL {|o|SetTimerEvent(100,{||_UpdateStats(GetList)},SetAppWindow(o)) }
  243.  
  244. DC_GetOptDefault(GetOptions)
  245.  
  246. cVersion := '1.3'
  247.  
  248. #ifdef EXPRESS15
  249.   cVersion := '1.6'
  250. #endif
  251.  
  252. #ifdef EXPRESS16
  253.   cVersion := '1.6'
  254. #endif
  255.  
  256. #ifdef EXPRESS17
  257.   cVersion := '1.7'
  258. #endif
  259.  
  260. #ifdef EXPRESS20
  261.   cVersion := '2.0'
  262. #endif
  263.  
  264. FErase('XPP' + GetNetName())
  265.  
  266. DCREAD GUI ;
  267.    TITLE 'eXPress++ Version ' + cVersion OPTIONS GetOptions ;
  268.    PARENT @oDialog ;
  269.  
  270. SetAppWindow(oAppWindow)
  271.  
  272. SetTimerEvent(0)
  273.  
  274. RETURN nil
  275.  
  276. * --------------------- *
  277.  
  278. FUNCTION _ActiveBlock( bBlock )
  279.  
  280. RETURN {|o|o:=Thread():new(),o:Start(bBlock)}
  281.  
  282. /* --------------------- */
  283.  
  284. STATIC FUNCTION _XDemoExit( GetList )
  285.  
  286. IF DC_MsgBox(,,{'Are you sure you want to Quit the eXPress++ Demo?'}, ;
  287.       'eXPress++',,,.t.)
  288.   QUIT
  289. ENDIF
  290.  
  291. RETURN nil
  292.  
  293. * ------------------
  294.  
  295. FUNCTION _UpdateStats( GetList )
  296.  
  297. STATIC snCaps := 0, snNum := 0
  298.  
  299. LOCAL oCapsLock := DC_GetObject(GetList,'CAPSLOCK')
  300. LOCAL oNumLock  := DC_GetObject(GetList,'NUMLOCK')
  301. LOCAL oInsert   := DC_GetObject(GetList,'INSERT')
  302. LOCAL nCaps     := AppKeystate( VK_CAPITAL, .T. )
  303. LOCAL nNum      := AppKeystate( VK_NUMLOCK, .T. )
  304. LOCAL oCapsStatic, oNumStatic
  305.  
  306. IF Valtype(oCapsLock) # 'O' .OR. Valtype(oNumLock) # 'O' .OR. Valtype(oInsert) # 'O'
  307.   RETURN nil
  308. ENDIF
  309.  
  310. oNumStatic := oNumLock:setParent()
  311. IF nNum == APPKEY_PRESSED
  312.   oNumLock:enable()
  313. ELSE
  314.   oNumLock:disable()
  315. ENDIF
  316.  
  317. oCapsStatic := oCapsLock:setParent()
  318. IF nCaps == APPKEY_PRESSED
  319.   oCapsLock:enable()
  320. ELSE
  321.   oCapsLock:disable()
  322. ENDIF
  323.  
  324. IF ReadInsert()
  325.   oInsert:SetCaption( "Ins" )
  326. ELSE
  327.   oInsert:SetCaption( "Ovr" )
  328. ENDIF
  329.  
  330. RETURN nil
  331.  
  332.  
  333. // Retrieving Computername
  334.  
  335. #INCLUDE "DLL.CH"
  336.  
  337. DLLFUNCTION RegOpenKeyExA(nHkeyClass, cKeyName, reserved, access, @nKeyHandle);
  338.             USING STDCALL FROM ADVAPI32.DLL
  339.  
  340. DLLFUNCTION RegQueryValueExA(nKeyHandle, cEntry, reserved, @valueType, ;
  341.             @cName, @nSize);
  342.             USING STDCALL FROM ADVAPI32.DLL
  343.  
  344. DLLFUNCTION RegCloseKey( nKeyHandle );
  345.             USING STDCALL FROM ADVAPI32.DLL
  346.  
  347. FUNCTION GetNetName()
  348.  
  349. LOCAL nHKey      := 2147483650
  350. LOCAL cKeyName   := "System\CurrentControlSet\Control\ComputerName\ComputerName"
  351. LOCAL cEntryName := "Computername"
  352. LOCAL cName := "", rc
  353. LOCAL nNameSize
  354. LOCAL nKeyHandle
  355. LOCAL nValueType
  356. nKeyHandle := 0
  357. IF RegOpenKeyExA(nHKey, cKeyName,0, 1, @nKeyHandle) = 0
  358.   nValueType  := 0
  359.   nNameSize  := 0
  360.   RegQueryValueExA(nKeyHandle, cEntryName, 0, @nValueType, 0, @nNameSize)
  361.   IF nNameSize > 0
  362.     cName := space( nNameSize )
  363.     rc := RegQueryValueExA(nKeyHandle, cEntryName,;
  364.                            0, @nValueType, @cName, @nNameSize)
  365.   ENDIF
  366.   RegCloseKey( nKeyHandle)
  367. ENDIF
  368.  
  369. RETURN (upper(alltrim(cName)))
  370.  
  371.  
  372.  
  373.  
  374.