home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Hutch / DOWNLOAD / Dbldr.exe / LISTBOX / LISTBOX.BAS < prev    next >
Encoding:
BASIC Source File  |  1999-08-11  |  3.5 KB  |  130 lines

  1. '######################## Dialog Builder Template #########################
  2.  
  3.     #INCLUDE "listbox.inc"
  4.  
  5. '##########################################################################
  6.  
  7. FUNCTION WinMain(ByVal Instance      as LONG, _
  8.                  ByVal hPrevInstance as LONG, _
  9.                  lpszCmdLine         as ASCIIZ PTR, _
  10.                  ByVal nCmdShow      as LONG) AS LONG
  11.  
  12.     hInstance = Instance
  13.  
  14.     DialogBox hInstance,ByVal 100,0,CodePtr(DlgProc1)
  15.  
  16.     FUNCTION = 0
  17.  
  18. END FUNCTION
  19.  
  20. '##########################################################################
  21.  
  22. FUNCTION DlgProc1(ByVal hDlg   as LONG, _
  23.                   ByVal Msg    as LONG, _
  24.                   ByVal wParam as LONG, _
  25.                   ByVal lParam as LONG) EXPORT as LONG
  26.  
  27.   LOCAL Caption as ASCIIZ * 20  ' make larger if needed
  28.  
  29.   Select Case Msg
  30.  
  31.       Case %WM_INITDIALOG
  32.  
  33.         hWnd = hDlg     ' hWnd is global handle
  34.  
  35.         SendMessage hDlg,%WM_SETICON,1, _
  36.                     LoadIcon(hInstance,ByVal 1)
  37.  
  38.         Caption="List Box Test"
  39.           SendMessage hDlg,%WM_SETTEXT,0,VarPtr(Caption)
  40.  
  41.         ' ----------------------------
  42.         ' Get handles for dialog items
  43.         ' ----------------------------
  44.           h1ListBox1     = GetDlgItem(hDlg,101)
  45.           lpListProc1& =SetWindowLong(h1ListBox1,%GWL_WNDPROC,_
  46.                                       ByVal CodePtr(ListProc1))
  47.  
  48.           h1Static1      = GetDlgItem(hDlg,102)
  49.           h1Button1      = GetDlgItem(hDlg,103)
  50.  
  51.         ' ------------------------------
  52.         ' Put some items in the list box
  53.         ' ------------------------------
  54.           Data Item 1
  55.           Data Item 2
  56.           Data Item 3
  57.           Data Item 4
  58.           Data Item 5
  59.           Data Item 6
  60.           Data Item 7
  61.           Data Item 8
  62.           Data Item 9
  63.           Data Item 10
  64.           Data Item 11
  65.           Data Item 12
  66.           Data Item 13
  67.           Data Item 14
  68.           Data Item 15
  69.           Data Item 16
  70.           Data Item 17
  71.           Data Item 18
  72.           Data Item 19
  73.           Data Item 20
  74.  
  75.           number& = DATACOUNT
  76.  
  77.           rf& = 1
  78.  
  79.           Do
  80.             x$=read$(rf&)
  81.             SendMessage h1ListBox1,%LB_ADDSTRING,0,ByVal StrPtr(x$)
  82.             ! inc rf&
  83.             If rf& > number& Then Exit Do
  84.           Loop
  85.  
  86.       Case %WM_COMMAND
  87.         Select Case wParam
  88.           Case 103    ' "Close"
  89.             ! jmp Outa_Here
  90.  
  91.         End Select
  92.  
  93.       Case %WM_CLOSE
  94.         Outa_Here:
  95.         EndDialog hDlg, 0
  96.  
  97.   END Select
  98.  
  99. END FUNCTION
  100.  
  101. '##########################################################################
  102.  
  103. FUNCTION ListProc1(BYVAL hCtl   as LONG, _
  104.                    BYVAL Msg    as LONG, _
  105.                    BYVAL wParam as LONG, _
  106.                    BYVAL lParam as LONG) EXPORT AS LONG
  107.  
  108.     Select Case Msg
  109.       Case %WM_LBUTTONDBLCLK
  110.       ' ------------------------------------------------
  111.       ' Get the index of the selected item, get the text
  112.       ' at that index in the listbox and then display it
  113.       ' ------------------------------------------------
  114.         cSel& = SendMessage(h1ListBox1,%LB_GETCURSEL,0,0)
  115.  
  116.         Buffer$ = space$(32)
  117.         SendMessage h1ListBox1,%LB_GETTEXT,cSel&,ByVal StrPtr(Buffer$)
  118.  
  119.         MessageBox hWnd,ByCopy Buffer$, _
  120.                    "SubClassed List Box",%MB_ICONINFORMATION
  121.  
  122.     End Select
  123.  
  124.   FUNCTION=CallWindowProc(ByVal lpListProc1&,hCtl,Msg,wParam,lParam)
  125.  
  126. END FUNCTION
  127.  
  128. ' ##########################################################################
  129.  
  130.