home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / BUTTON2.PRG < prev    next >
Text File  |  1995-07-09  |  2KB  |  78 lines

  1. ////////////////////////////
  2. //
  3. //    Clip-4-Win button demo  (same as source\button.prg but using commands)
  4. //
  5. //    Copyright (C) 1992 Skelton Software, Kendal Cottage, Hillam, Leeds, UK.
  6. //    All Rights Reserved.
  7. //
  8. //    To build:  c4wbuild button2
  9. //
  10. ////////////////////////////
  11.  
  12. #define    WIN_WANT_ALL
  13. #include "windows.ch"
  14. #define    NO_C4WCLASS
  15. #include "commands.ch"
  16.  
  17.  
  18. // these need to be different so we know which button was selected
  19. #define    BTN1    1
  20. #define    BTN2    2
  21.  
  22. #define    nstr(i)     alltrim(str(i))
  23.  
  24.  
  25. function main()
  26. local    oApp, oWnd
  27. local    hDefPushButton, hPushButton
  28.  
  29. CREATE APPLICATION oApp  WINDOW oWnd  TITLE "Clip-4-Win button demo"    ;
  30.     ON INIT       DoInit(oWnd, @hDefPushButton, @hPushButton)    ;
  31.     ON WM_COMMAND OnCommand(@hDefPushButton, @hPushButton)
  32.  
  33. return nil
  34.  
  35.  
  36. static function DoInit(hWnd, hDefPushButton, hPushButton)
  37.  
  38. CREATE WINDOW hPushButton  CLASS "button"  INSTANCE 0            ;
  39.     TITLE "&PushButton"                        ;
  40.     STYLE WS_CHILD + WS_VISIBLE + WS_TABSTOP + WS_GROUP + BS_PUSHBUTTON ;
  41.     AT 100,150  SIZE 150,20  ID BTN2  IN hWnd
  42.  
  43. CREATE WINDOW hDefPushButton  CLASS "button"  INSTANCE 0        ;
  44.     TITLE "&DefPushButton"                        ;
  45.     STYLE WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_DEFPUSHBUTTON    ;
  46.     AT 350,150  SIZE 150,20  ID BTN1  IN hWnd
  47.  
  48. SetFocus(hDefPushButton)
  49. return nil
  50.  
  51.  
  52. static function OnCommand(hDefPushButton, hPushButton, hWnd, nMsg, nwParam)
  53. local    nButton := nwParam
  54.  
  55. MessageBox( , "Button number: " + nstr(nButton), "Info", MB_OK)
  56. if nButton == BTN1
  57.     DestroyWindow(hDefPushButton)
  58.     hDefPushButton = nil
  59.     if !empty(hPushButton)
  60.         SetFocus(hPushButton)
  61.     endif
  62. endif
  63. if nButton == BTN2
  64.     DestroyWindow(hPushButton)
  65.     hPushButton = nil
  66.     if !empty(hDefPushButton)
  67.         SetFocus(hDefPushButton)
  68.     endif
  69. endif
  70.  
  71. if empty(hDefPushButton) .and. empty(hPushButton)
  72.     MessageBox( , "Press ENTER to exit", "All buttons pressed", MB_OK)
  73.     quit
  74. endif
  75.  
  76. return nil
  77.  
  78.