home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / ACHOICE.PRG < prev    next >
Text File  |  1994-11-29  |  2KB  |  61 lines

  1. /////////////////////////
  2. //
  3. //    achoice.prg - alternative ACHOICE() function using Windows list box
  4. //
  5. //    Written by:    John M. Skelton, 12-May-93.
  6. //
  7. //    Copyright (C) 1993 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
  8. //    All Rights Reserved.
  9. //
  10. /////////////////////////
  11.  
  12.  
  13. #define    WIN_WANT_LBS
  14. #include "windows.ch"
  15.  
  16.  
  17. function achoice(nTop, nLeft, nBottom, nRight, aChoices)
  18. local    aDlg, nRet, cText, nX, nY, nW, nH, nDX, nDY
  19. default nTop to 5, nLeft to 5, nBottom to 15, nRight to 45
  20. nDX = C4W_LoWord(GetDialogBaseUnits()) / 2
  21. nDY = C4W_HiWord(GetDialogBaseUnits()) / 2
  22. nX = nLeft * nDX
  23. nY = nTop * nDY
  24. nW = (nRight - nLeft + 1) * nDX + 20
  25. nH = (nBottom - nTop + 1) * nDY + 40
  26. aDlg = CreateDialog("Achoice",                        ;
  27.             WS_CAPTION + WS_SYSMENU + WS_GROUP + WS_TABSTOP    ;
  28.             + WS_THICKFRAME + WS_VISIBLE + WS_POPUP,        ;
  29. ;//            100, 30, 100, 100)
  30.             nX, nY, nW, nH)
  31.  
  32. // You might like to add + LBS_SORT to the  WS_* values below...
  33. aDlg = AppendDialog(aDlg, "listbox", DLG_LISTBOX,            ;
  34.             WS_CHILD + WS_VISIBLE + WS_VSCROLL + WS_BORDER    ;
  35.             + WS_TABSTOP + LBS_USETABSTOPS,            ;
  36. ;//            10, 10, 80, 60,                    ;
  37.             10, 10, nW - 20, nH - 40,                ;
  38.             aChoices)
  39. aDlg = AppendDialog(aDlg, "ok", DLG_BUTTON,                ;
  40.             BS_DEFPUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE,  ;
  41. ;//            10, 75, 35, 15,                    ;
  42. ;//            10, nH - 25, 35, 15,                ;
  43.             (nW - 80) / 3, nH - 25, 35, 15,            ;
  44.             "&Ok")
  45. aDlg = AppendDialog(aDlg, "cancel", DLG_BUTTON,                ;
  46.             BS_PUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE,    ;
  47. ;//            55, 75, 35, 15,                    ;
  48. ;//            nW - 45, nH - 25, 35, 15,                ;
  49.             2 * (nW - 80) / 3 + 35, nH - 25, 35, 15,        ;
  50.             "&Cancel")
  51.  
  52. if ModalDialog(aDlg) = 0 .or. GetDialogResult(aDlg, "cancel") = .T.
  53.     nRet = 0
  54. else
  55.     cText = GetDialogResult(aDlg, "listbox")
  56.     nRet = ascan(aChoices, cText)
  57. endif
  58.  
  59. return nRet
  60.  
  61.