home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / CONTRIB / ENTER.ZIP / TEST.PRG < prev    next >
Text File  |  1996-01-26  |  4KB  |  133 lines

  1. // Original by Paul Richards.  Minor clean-ups by JMS
  2. #define    WIN_WANT_HELP
  3. #define    WIN_WANT_ALL
  4. #include "windows.ch"
  5. #define    NO_C4WCLASS
  6. #include "commands.ch"
  7. #include "dialog.ch"
  8.  
  9. Static GetList
  10. Static Get1
  11. Static Get2
  12. Static Get3
  13. Static Get4
  14. Static Get5
  15. Static Get6
  16. Static    hWnd
  17.  
  18. Function Main()
  19. local    oApp, oWnd
  20.  
  21. CREATE APPLICATION oApp  WINDOW oWND  TITLE "Clip-4-Win Get Test"    ;
  22.     ON INIT MenuSetup(oWnd)
  23.  
  24. return nil
  25.  
  26. static function MenuSetup(oWnd)
  27. hWnd := oWnd
  28.  
  29. MENU IN oWnd
  30.     POPUP "&File"
  31.         MENUITEM "E&xit"             ACTION DoExit()
  32.     ENDPOPUP
  33.     POPUP "&Get Test"
  34.         MENUITEM "&Test"             ACTION GetTest()
  35.     ENDPOPUP
  36. ENDMENU
  37.  
  38. return nil
  39.  
  40. Function DoExit()
  41. Quit
  42. Return NIL
  43.  
  44. Function GetTest()
  45. // Load Dialog Box and Return
  46. Return DialogBox(_GetInstance() , "TEST",,; // Load Dialog
  47.                   {|hDlg, nMsg, nWparam, nLparam|;
  48.             GetFn(hDlg,nMsg,nWparam,nLparam)})
  49. Static Function GetFn(hDlgWnd,nMsg,nWparam,nLparam)
  50.  
  51. LOCAL nGet
  52.  
  53. Set Confirm On   // Most Important for the last Get
  54.  
  55. do Case
  56.    Case nMsg == WM_INITDIALOG
  57.        GetList   := {}
  58.  
  59.        // Dialog Box Header
  60.        Get1 := Get2 := Get3 := Get4 := Get5 := Get6 := Space(20)
  61.        @ Dialog hDlgWnd ID 101 get Get1
  62.        @ Dialog hDlgWnd ID 102 get Get2
  63.        @ Dialog hDlgWnd ID 103 get Get3
  64.        @ Dialog hDlgWnd ID 104 get Get4
  65.        @ Dialog hDlgWnd ID 105 get Get5
  66.        @ Dialog hDlgWnd ID 106 get Get6
  67.  
  68.        SendMessage(hDlgWnd,WM_SETTEXT,0,"Get Test")
  69.        Return(1)
  70.  
  71.    Case nMsg == WM_COMMAND
  72.        Do Case
  73.            Case nWparam == IDCANCEL    // Finished
  74.                Cancel Dialog hDlgWnd
  75.                EndDialog(hDlgWnd,IDCANCEL)
  76.                Return(1)
  77.  
  78.            Case nWParam >= 200 .and. nWParam <= 206  // PICK 1
  79.                PickList(hDlgWnd,nWparam-200)
  80.  
  81.            Case nWParam == 501  // ACCEPT
  82.                MessageBox(hDlgWnd,"Validate Gets"+chr(10)+chr(13)+;
  83.                                   "and Write to dBF","Accepting Dialog",MB_OK)
  84.                Cancel Dialog hDlgWnd
  85.                EndDialog(hDlgWnd,IDOK)
  86.                Return(1)
  87.  
  88.            Case nWParam == IDOK                       // Enter Depressed
  89.                 if GetDlgCtrlID(GetFocus()) == 101    // Take care of up
  90.                     GetList[2]:setFocus()             // key depressed in
  91.                     SetFocus(GetDlgItem(hDlgWnd,102)) // first get
  92.                 else
  93.                     // which read has focus
  94.                     for nGet := 1 to len(GetList)
  95.                         if GetList[nGet]:hasfocus
  96.                             exit
  97.                         endif
  98.                     next
  99.                     // if Move to next Get or to next button
  100.                     if nGet < len(GetList)
  101.                         nGet++
  102.                         GetList[nGet]:setFocus()
  103.                         SetFocus(GetDlgItem(hDlgWnd,100+nGet))
  104.                     else
  105.                         // Move TABSTOP Focus to Accept Button
  106.                         PostMessage(hDlgWnd,WM_NEXTDLGCTL,GetDlgItem(hDlgWnd,501),1)
  107.                     endif
  108.                 endif
  109.        EndCase
  110.  
  111. EndCase
  112.  
  113. RETURN(0)
  114.  
  115.  
  116. /////////////////////////////////
  117. Function PickList(hDlgWnd,nGet)
  118. /////////////////////////////////
  119.  
  120. Local nPick := "Pick List Value "+str(nGet,1,0)
  121.  
  122. MessageBox(hDlgWnd,"Pop up a pick list","Pick List",MB_OK)
  123.  
  124. GetList[nGet]:KillFocus()              // Update GetList Object Focus
  125. GetList[nGet]:varPut(nPick)            // Update GetList Object
  126. SetDlgItemText(hDlgWnd,100+nGet,nPick) // Update Dialog item
  127. SetFocus(GetDlgItem(hDlgWnd,100+nGet)) // Set Focus
  128. GetList[nGet]:SetFocus()               // to Picked Get
  129.  
  130. Return NIL
  131.  
  132.  
  133.