home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / APIInputBo79895562002.psc / ApiInputComboBox.bas next >
Encoding:
BASIC Source File  |  2002-09-12  |  37.6 KB  |  945 lines

  1. Attribute VB_Name = "APIInputBoxComboBox"
  2. 'Module name: APIInputBox & ComboBox
  3. 'Author: M.C
  4. 'Created: 09 may.02
  5.  
  6. 'main Api Window Creating  learned from:
  7. 'API Form by Joseph Huntley found on PSC               *
  8.  
  9. 'ver 1.0
  10. 'first bugy attempt
  11. 'ver 2.0 (excelency acchived)
  12. ' in ver 1.0 nothing could be typed in text portion of combo box
  13. ' this is now OK
  14. ' in ver 1.0 wierd thing happend to Num lock, caps lock on keyboard
  15. ' this is now ok
  16. ' added ability to swallow selection on ENTER key pressed
  17. ' horizontal and vertical scroll added as/and only if needed
  18. ' autotype ability added
  19. ' this last one vas especialy hard to figure out as API combobox doesn't
  20. ' get WM_CHAR message
  21. '? button added, unfortunately doesn't work.
  22.  
  23.  
  24.  
  25.  
  26. 'tons of declares, constants and stuff
  27. 'a lot of them not needed in this project
  28.  
  29. '**************************************************************
  30. 'tons of green stuff - as evidence of trial - error method, lol
  31. '**************************************************************
  32.  
  33. Public Declare Function RegisterClass Lib "user32" Alias "RegisterClassA" (Class As WNDCLASS) As Long
  34. Public Declare Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As Long) As Long
  35. Public Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  36. Public Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
  37. Public Declare Function TranslateMessage Lib "user32" (lpMsg As Msg) As Long
  38. Public Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As Long
  39. Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  40. Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
  41. Public Declare Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long
  42. Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
  43. Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  44. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  45. Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  46. Public Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
  47. Public Declare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long)
  48. Public Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
  49. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  50. Public Declare Function SetWindowText Lib "user632" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
  51. Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  52. Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  53. Public Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
  54. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  55. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  56. Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As Long
  57. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
  58. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
  59. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
  60. Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&) As Long
  61. Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook&) As Long
  62. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
  63. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  64.  
  65. Public Type POINTAPI
  66.     x As Long
  67.     y As Long
  68. End Type
  69. Public Type WNDCLASS
  70.     style As Long
  71.     lpfnwndproc As Long
  72.     cbClsextra As Long
  73.     cbWndExtra2 As Long
  74.     hInstance As Long
  75.     hIcon As Long
  76.     hCursor As Long
  77.     hbrBackground As Long
  78.     lpszMenuName As String
  79.     lpszClassName As String
  80. End Type
  81.  
  82. Public Type Msg
  83.     hwnd As Long
  84.     Message As Long
  85.     wParam As Long
  86.     lParam As Long
  87.     time As Long
  88.     pt As POINTAPI
  89. End Type
  90.  
  91. Private Type Rect
  92.     Left As Long
  93.     Top As Long
  94.     Right As Long
  95.     Bottom As Long
  96. End Type
  97.  
  98. Private Type CWPSTRUCT
  99.     lParam As Long
  100.     wParam As Long
  101.     Message As Long
  102.     hwnd As Long
  103. End Type
  104.  
  105. Const WM_MOVE = &H3
  106. Const WM_SETCURSOR = &H20
  107. Const WM_NCPAINT = &H85
  108. Const WM_COMMAND = &H111
  109.  
  110. Const SWP_FRAMECHANGED = &H20
  111. Const GWL_EXSTYLE = -20
  112.  
  113. Public Const CS_VREDRAW = &H1
  114. Public Const CS_HREDRAW = &H2
  115.  
  116. Public Const CW_USEDEFAULT = &H80000000
  117.  
  118. Public Const ES_MULTILINE = &H4&
  119.  
  120. ' Window styles
  121. Public Const WS_ACTIVECAPTION = &H1
  122. Public Const WS_BORDER = &H800000
  123. Public Const WS_CAPTION = &HC00000         ' WS_BORDER Or WS_DLGFRAME
  124. Public Const WS_CHILD = &H40000000
  125. Public Const WS_CHILDWINDOW = (WS_CHILD)
  126. Public Const WS_CLIPCHILDREN = &H2000000
  127. Public Const WS_CLIPSIBLINGS = &H4000000
  128. Public Const WS_DISABLED = &H8000000
  129. Public Const WS_DLGFRAME = &H400000
  130. Public Const WS_EX_ACCEPTFILES = &H10&
  131. Public Const WS_EX_APPWINDOW = &H40000
  132. Public Const WS_EX_CLIENTEDGE = &H200&
  133. Public Const WS_EX_CONTEXTHELP = &H400&
  134. Public Const WS_EX_CONTROLPARENT = &H10000
  135. Public Const WS_EX_DLGMODALFRAME = &H1&
  136. Public Const WS_EX_LAYERED = &H80000
  137. Public Const WS_EX_LAYOUTRTL = &H400000
  138. Public Const WS_EX_LEFT = &H0&
  139. Public Const WS_EX_LEFTSCROLLBAR = &H4000&
  140. Public Const WS_EX_LTRREADING = &H0&
  141. Public Const WS_EX_MDICHILD = &H40&
  142. Public Const WS_EX_NOACTIVATE = &H8000000
  143. Public Const WS_EX_NOINHERITLAYOUT = &H100000
  144. Public Const WS_EX_NOPARENTNOTIFY = &H4&
  145. Public Const WS_EX_TOOLWINDOW = &H80&
  146. Public Const WS_EX_TOPMOST = &H8&
  147. Public Const WS_EX_WINDOWEDGE = &H100&
  148. Public Const WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE)
  149. Public Const WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST)
  150. Public Const WS_EX_RIGHT = &H1000&
  151. Public Const WS_EX_RIGHTSCROLLBAR = &H0&
  152. Public Const WS_EX_RTLREADING = &H2000&
  153. Public Const WS_EX_STATICEDGE = &H20000
  154.  
  155. Public Const WS_EX_TRANSPARENT = &H20&
  156. Public Const WS_TABSTOP = &H10000
  157. Public Const WS_GROUP = &H20000
  158. Public Const WS_GT = (WS_GROUP Or WS_TABSTOP)
  159. Public Const WS_HSCROLL = &H100000
  160. Public Const WS_MINIMIZE = &H20000000
  161. Public Const WS_ICONIC = WS_MINIMIZE
  162. Public Const WS_MAXIMIZE = &H1000000
  163. Public Const WS_MAXIMIZEBOX = &H10000
  164. Public Const WS_SYSMENU = &H80000
  165. Public Const WS_MINIMIZEBOX = &H20000
  166. Public Const WS_THICKFRAME = &H40000
  167. Public Const WS_OVERLAPPED = &H0&
  168. Public Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
  169. Public Const WS_POPUP = &H80000000
  170. Public Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
  171. Public Const WS_SIZEBOX = WS_THICKFRAME
  172. Public Const WS_TILED = WS_OVERLAPPED
  173. Public Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
  174. Public Const WS_VISIBLE = &H10000000
  175. Public Const WS_VSCROLL = &H200000
  176.  
  177. 'buttonstyles
  178. Private Const BS_3STATE = &H5&
  179. Private Const BS_AUTO3STATE = &H6&
  180. Private Const BS_AUTOCHECKBOX = &H3&
  181. Private Const BS_AUTORADIOBUTTON = &H9&
  182. Private Const BS_BITMAP = &H80&
  183. Private Const BS_BOTTOM = &H800&
  184. Private Const BS_CENTER = &H300&
  185. Private Const BS_CHECKBOX = &H2&
  186. Private Const BS_DEFPUSHBUTTON = &H1&
  187. Private Const BS_DIBPATTERN = 5
  188. Private Const BS_DIBPATTERN8X8 = 8
  189. Private Const BS_DIBPATTERNPT = 6
  190. Private Const BS_FLAT = &H8000&
  191. Private Const BS_GROUPBOX = &H7&
  192. Private Const BS_HATCHED = 2
  193. Private Const BS_NULL = 1
  194. Private Const BS_HOLLOW = BS_NULL
  195. Private Const BS_ICON = &H40&
  196. Private Const BS_INDEXED = 4
  197. Private Const BS_LEFT = &H100&
  198. Private Const BS_LEFTTEXT = &H20&
  199. Private Const BS_MONOPATTERN = 9
  200. Private Const BS_MULTILINE = &H2000&
  201. Private Const BS_NOTIFY = &H4000&
  202. Private Const BS_OWNERDRAW = &HB&
  203. Private Const BS_PATTERN = 3
  204. Private Const BS_PATTERN8X8 = 7
  205. Private Const BS_PUSHBUTTON = &H0&
  206. Private Const BS_PUSHLIKE = &H1000&
  207. Private Const BS_RADIOBUTTON = &H4&
  208. Private Const BS_RIGHT = &H200&
  209. Private Const BS_RIGHTBUTTON = BS_LEFTTEXT
  210. Private Const BS_SOLID = 0
  211. Private Const BS_TEXT = &H0&
  212. Private Const BS_TOP = &H400&
  213. Private Const BS_USERBUTTON = &H8&
  214. Private Const BS_VCENTER = &HC00&
  215.  
  216.  
  217. Public Const COLOR_3DDKSHADOW = 21
  218. Public Const COLOR_BTNFACE = 15
  219. Public Const COLOR_3DFACE = COLOR_BTNFACE
  220. Public Const COLOR_BTNHIGHLIGHT = 20
  221. Public Const COLOR_3DHIGHLIGHT = COLOR_BTNHIGHLIGHT
  222. Public Const COLOR_3DHILIGHT = COLOR_BTNHIGHLIGHT
  223. Public Const COLOR_3DLIGHT = 22
  224. Public Const COLOR_BTNSHADOW = 16
  225. Public Const COLOR_3DSHADOW = COLOR_BTNSHADOW
  226. Public Const COLOR_ACTIVEBORDER = 10
  227. Public Const COLOR_ACTIVECAPTION = 2
  228. Public Const COLOR_ADD = 712
  229. Public Const COLOR_ADJ_MAX = 100
  230. Public Const COLOR_ADJ_MIN = -100
  231. Public Const COLOR_APPWORKSPACE = 12
  232. Public Const COLOR_BACKGROUND = 1
  233. Public Const COLOR_BLUE = 708
  234. Public Const COLOR_BLUEACCEL = 728
  235. Public Const COLOR_BOX1 = 720
  236.  
  237.  
  238. Public Const COLOR_BTNHILIGHT = COLOR_BTNHIGHLIGHT
  239. Public Const COLOR_BTNTEXT = 18
  240. Public Const COLOR_CAPTIONTEXT = 9
  241. Public Const COLOR_CURRENT = 709
  242. Public Const COLOR_CUSTOM1 = 721
  243. Public Const COLOR_DESKTOP = COLOR_BACKGROUND
  244. Public Const COLOR_ELEMENT = 716
  245. Public Const COLOR_GRADIENTACTIVECAPTION = 27
  246. Public Const COLOR_GRADIENTINACTIVECAPTION = 28
  247. Public Const COLOR_GRAYTEXT = 17
  248. Public Const COLOR_GREEN = 707
  249. Public Const COLOR_GREENACCEL = 727
  250. Public Const COLOR_HIGHLIGHT = 13
  251. Public Const COLOR_HIGHLIGHTTEXT = 14
  252. Public Const COLOR_HOTLIGHT = 26
  253. Public Const COLOR_HUE = 703
  254. Public Const COLOR_HUEACCEL = 723
  255. Public Const COLOR_HUESCROLL = 700
  256. Public Const COLOR_INACTIVEBORDER = 11
  257. Public Const COLOR_INACTIVECAPTION = 3
  258. Public Const COLOR_INACTIVECAPTIONTEXT = 19
  259. Public Const COLOR_INFOBK = 24
  260. Public Const COLOR_INFOTEXT = 23
  261. Public Const COLOR_LUM = 705
  262. Public Const COLOR_LUMACCEL = 725
  263. Public Const COLOR_LUMSCROLL = 702
  264. Public Const COLOR_MATCH_VERSION = &H200
  265. Public Const COLOR_MENU = 4
  266. Public Const COLOR_MENUTEXT = 7
  267. Public Const COLOR_MIX = 719
  268. Public Const COLOR_NO_TRANSPARENT = &HFFFFFFFF
  269. Public Const COLOR_PALETTE = 718
  270. Public Const COLOR_RAINBOW = 710
  271. Public Const COLOR_RED = 706
  272. Public Const COLOR_REDACCEL = 726
  273. Public Const COLOR_SAMPLES = 717
  274. Public Const COLOR_SAT = 704
  275. Public Const COLOR_SATACCEL = 724
  276. Public Const COLOR_SATSCROLL = 701
  277. Public Const COLOR_SAVE = 711
  278. Public Const COLOR_SCHEMES = 715
  279. Public Const COLOR_SCROLLBAR = 0
  280. Public Const COLOR_SOLID = 713
  281. Public Const COLOR_SOLID_LEFT = 730
  282. Public Const COLOR_SOLID_RIGHT = 731
  283. Public Const COLOR_TUNE = 714
  284. Public Const COLOR_WINDOW = 5
  285. Public Const COLOR_WINDOWFRAME = 6
  286. Public Const COLOR_WINDOWTEXT = 8
  287. Public Const COLORMATCHTOTARGET_EMBEDED = &H1
  288. Public Const COLORMGMTCAPS = 121
  289. Public Const COLORMGMTDLGORD = 1551
  290. Public Const COLOROKSTRING = "commdlg_ColorOK"
  291. Public Const COLOROKSTRINGA = "commdlg_ColorOK"
  292. Public Const COLOROKSTRINGW = "commdlg_ColorOK"
  293. Public Const COLORONCOLOR = 3
  294. Public Const COLORRES = 108
  295.  
  296.  
  297. Public Const WM_DESTROY = &H2
  298. Public Const WM_LBUTTONDOWN = &H201
  299. Public Const WM_LBUTTONUP = &H202
  300. Public Const WM_GETTEXTLENGTH = &HE
  301. Public Const WM_GETTEXT = &HD
  302. Public Const WM_SETTEXT = &HC
  303.  
  304. Public Const IDC_ARROW = 32512&
  305.  
  306. Public Const IDI_APPLICATION = 32512&
  307. Public Const IDI_ASTERISK = 32516&
  308. Public Const IDI_CLASSICON_OVERLAYFIRST = 500
  309. Public Const IDI_CLASSICON_OVERLAYLAST = 502
  310. Public Const IDI_CONFLICT = 161
  311. Public Const IDI_DISABLED_OVL = 501
  312. Public Const IDI_HAND = 32513&
  313. Public Const IDI_ERROR = IDI_HAND
  314. Public Const IDI_EXCLAMATION = 32515&
  315. Public Const IDI_FORCED_OVL = 502
  316.  
  317. Public Const IDI_INFORMATION = IDI_ASTERISK
  318. Public Const IDI_PROBLEM_OVL = 500
  319. Public Const IDI_QUESTION = 32514&
  320. Public Const IDI_RESOURCE = 159
  321. Public Const IDI_RESOURCEFIRST = 159
  322. Public Const IDI_RESOURCELAST = 161
  323. Public Const IDI_RESOURCEOVERLAYFIRST = 161
  324. Public Const IDI_RESOURCEOVERLAYLAST = 161
  325. Public Const IDI_WARNING = IDI_EXCLAMATION
  326. Public Const IDI_WINLOGO = 32517
  327. Public Const IDIGNORE = 5
  328.  
  329. Private Const HWND_TOPMOST = -1
  330.  
  331.  
  332. Public Const GWL_WNDPROC = (-4)
  333.  
  334. Public Const SW_SHOWNORMAL = 1
  335. Private Const SW_HIDE = 0
  336.  
  337. Private Const LB_SETHORIZONTALEXTENT = &H194
  338.  
  339. Public Const MB_OK = &H0&
  340. Public Const MB_ICONEXCLAMATION = &H30&
  341.  
  342.  
  343. Public Const gClassName = "MyClassName"
  344. Public Const gAppName = "My Window Caption"
  345.  
  346.  
  347. 'ComboBox styles
  348. Public Const CBS_OWNERDRAWVARIABLE = &H20&
  349. Public Const CBS_AUTOHSCROLL = &H40&
  350. Public Const CBS_DISABLENOSCROLL = &H800&
  351. Public Const CBS_DROPDOWN = &H2&
  352. Public Const CBS_DROPDOWNLIST = &H3&
  353. Public Const CBS_HASSTRINGS = &H200&
  354. Public Const CBS_LOWERCASE = &H4000&
  355. Public Const CBS_NOINTEGRALHEIGHT = &H400&
  356. Public Const CBS_OEMCONVERT = &H80&
  357. Public Const CBS_OWNERDRAWFIXED = &H10&
  358. Public Const CBS_SIMPLE = &H1&
  359. Public Const CBS_SORT = &H100&
  360. Public Const CBS_UPPERCASE = &H2000&
  361.  
  362. Public Const CB_ADDSTRING = &H143
  363. Public Const CB_DELETESTRING = &H144
  364. Public Const CB_DIR = &H145
  365. Public Const CB_ERR = (-1)
  366. Public Const CB_ERRSPACE = (-2)
  367. Public Const CB_FINDSTRING = &H14C
  368. Public Const CB_FINDSTRINGEXACT = &H158
  369. Public Const CB_GETCOUNT = &H146
  370. Public Const CB_GETCURSEL = &H147
  371. Public Const CB_GETDROPPEDCONTROLRECT = &H152
  372. Public Const CB_GETDROPPEDSTATE = &H157
  373. Public Const CB_GETDROPPEDWIDTH = &H15F
  374. Public Const CB_GETEDITSEL = &H140
  375. Public Const CB_GETEXTENDEDUI = &H156
  376. Public Const CB_GETHORIZONTALEXTENT = &H15D
  377. Public Const CB_GETITEMDATA = &H150
  378. Public Const CB_GETITEMHEIGHT = &H154
  379. Public Const CB_GETLBTEXT = &H148
  380. Public Const CB_GETLBTEXTLEN = &H149
  381. Public Const CB_GETLOCALE = &H15A
  382. Public Const CB_GETTOPINDEX = &H15B
  383. Public Const CB_INITSTORAGE = &H161
  384. Public Const CB_INSERTSTRING = &H14A
  385. Public Const CB_LIMITTEXT = &H141
  386. Public Const CB_MSGMAX = &H15B
  387. Public Const CB_MULTIPLEADDSTRING = &H163
  388. Public Const CB_OKAY = 0
  389. Public Const CB_RESETCONTENT = &H14B
  390. Public Const CB_SELECTSTRING = &H14D
  391. Public Const CB_SETCURSEL = &H14E
  392. Public Const CB_SETDROPPEDWIDTH = &H160
  393. Public Const CB_SETEDITSEL = &H142
  394. Public Const CB_SETEXTENDEDUI = &H155
  395. Public Const CB_SETHORIZONTALEXTENT = &H15E
  396. Public Const CB_SETITEMDATA = &H151
  397. Public Const CB_SETITEMHEIGHT = &H153
  398. Public Const CB_SETLOCALE = &H159
  399. Public Const CB_SETTOPINDEX = &H15C
  400. Public Const CB_SHOWDROPDOWN = &H14F
  401.  
  402. Public Const WM_UPDATEUISTATE = &H128
  403.  
  404. Public Const EM_SETSEL = &HB1
  405.  
  406. Private Const BM_CLICK = &HF5
  407.  
  408. Public OKButtonOldProc As Long ''Will hold address of the old window proc for the button
  409. Public CancelButtonOldProc As Long
  410. Public ComboBoxOldProc As Long
  411.  
  412. Public FormWindowHwnd As Long, OKButtonHwnd As Long, gEditHwnd As Long, TextHwnd As Long, CancelButtonHwnd As Long, ComboBoxHwnd As Long, HelpButtonHwnd As Long  ''You don't necessarily need globals, but if you're planning to gettext and stuff, then you're gona have to store the hwnds.
  413.  
  414. 'and some public dims
  415. Dim InputBoxCaption As String
  416. Dim InputBoxText As String
  417. Dim AddItems() As Variant  'array
  418. Dim i As Integer
  419. Public IBCBSelectedItem As Variant 'this will hold whatever you select in combo box
  420. Public avoid As Boolean
  421. Public CharCountNew As Integer
  422. Public CharCountOld As Integer
  423. Public FirstTime307Passed As Boolean ' used in combobox procedure
  424. Public textportion
  425. Public trouble As Boolean
  426. Private WHook As Long
  427.  
  428.  
  429. Public Sub CreateComboBoxInputBox(Caption As String, IBText As String, InputAddItems() As Variant)
  430. InputBoxCaption = Caption
  431. InputBoxText = IBText
  432. AddItems = InputAddItems
  433. CharCountOld = 0
  434. Main
  435. End Sub
  436. Public Sub Main()
  437.  
  438.    Dim wMsg As Msg
  439.  
  440.    ''Call procedure to register window classname. If false, then exit.
  441.    If RegisterWindowClass = False Then Exit Sub
  442.     
  443.       ''Create window
  444.       If CreateWindows Then
  445.          ''Loop will exit when WM_QUIT is sent to the window.
  446.          Do While GetMessage(wMsg, 0&, 0&, 0&)
  447.             ''TranslateMessage takes keyboard messages and converts
  448.             ''them to WM_CHAR for easier processing.
  449.             Call TranslateMessage(wMsg)
  450.             ''Dispatchmessage calls the default window procedure
  451.             ''to process the window message. (WndProc)
  452.             Call DispatchMessage(wMsg)
  453.          Loop
  454.       End If
  455.  
  456.     Call UnregisterClass(gClassName$, App.hInstance)
  457.  
  458.  
  459. End Sub
  460.  
  461. Public Function RegisterWindowClass() As Boolean
  462.  
  463.     Dim wc As WNDCLASS
  464.     
  465.     ''Registers our new window with windows so we
  466.     ''can use our classname.
  467.     
  468.     wc.style = CS_HREDRAW Or CS_VREDRAW
  469.     wc.lpfnwndproc = GetAddress(AddressOf WndProc) ''Address in memory of default window procedure.
  470.     wc.hInstance = App.hInstance
  471.     wc.hIcon = LoadIcon(0&, IDI_APLICATION) ''Default application icon
  472.     wc.hCursor = LoadCursor(0&, IDC_ARROW) ''Default arrow
  473.     wc.hbrBackground = COLOR_WINDOW ''Default a color for window.
  474.     wc.lpszClassName = gClassName$
  475.  
  476.     RegisterWindowClass = RegisterClass(wc) <> 0
  477.     
  478. End Function
  479. Public Function CreateWindows() As Boolean
  480.   
  481.     ''Create main window.
  482.     FormWindowHwnd = CreateWindowEx(0, gClassName$, InputBoxCaption, WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME, (Screen.Width / Screen.TwipsPerPixelX / 2) - 150, (Screen.Height / Screen.TwipsPerPixelY / 2) - 80, 300, 160, 0, 0, App.hInstance, ByVal 0&)
  483.     'FormWindowHwnd& = CreateWindowEx(0&, gClassName$, gAppName$, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 208, 150, 0&, 0&, App.hInstance, ByVal 0&)
  484.     'Create OK button
  485.     OKButtonHwnd = CreateWindowEx(0, "Button", "OK", WS_CHILD, 230, 10, 60, 25, FormWindowHwnd, 0, App.hInstance, ByVal 0&)
  486.     'Create Cancel button
  487.     CancelButtonHwnd = CreateWindowEx(0&, "button", "Cancel", WS_CHILD, 230, 45, 60, 25, FormWindowHwnd, 0&, App.hInstance, 0&)
  488.     'OKButtonHwnd = CreateWindowEx(0&, "Button", "Click Here", WS_CHILD, 58, 90, 85, 25, FormWindowHwnd&, 0&, App.hInstance, 0&)
  489.     ''Create textbox with a border (WS_EX_CLIENTEDGE) and make it multi-line (ES_MULTILINE)
  490.     'gEditHwnd& = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "This is the edit control." & vbCrLf & "As you can see, it's multiline.", WS_CHILD Or ES_MULTILINE, 0&, 0&, 200, 80, FormWindowHwnd&, 0&, App.hInstance, 0&)
  491.     
  492.     'Create 'label'
  493.     TextHwnd = CreateWindowEx(&H0, "static", InputBoxText, WS_CHILD, 5, 10, 200, 60, FormWindowHwnd, 0&, App.hInstance, 0&)
  494.     
  495.     'Create Combo
  496.     ComboBoxHwnd = CreateWindowEx(0&, "combobox", "H", CBS_DROPDOWN Or CBS_HASSTRINGS Or CBS_SORT Or CBS_AUTOHSCROLL Or WS_CHILD Or WS_VSCROLL Or WS_HSCROLL, 5, 80, 285, 100, FormWindowHwnd, 0, App.hInstance, 0&)
  497.     
  498.     'Create Help button
  499.     HelpButtonHwnd = CreateWindowEx(0&, "Button", "?", WS_CHILD, 0, -10, 14, 14, FormWindowHwnd, 0&, App.hInstance, ByVal 0&)
  500.     
  501.     
  502.  
  503.     'Tmp = SendMessage(ComboBoxHwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
  504.  
  505.     'Windows are all hidden, so show them.
  506.     Call ShowWindow(FormWindowHwnd, SW_SHOWNORMAL)
  507.     Call ShowWindow(OKButtonHwnd, SW_SHOWNORMAL)
  508.     Call ShowWindow(CancelButtonHwnd, SW_SHOWNORMAL)
  509.     'Call ShowWindow(gEditHwnd&, SW_SHOWNORMAL)
  510.     Call ShowWindow(TextHwnd, SW_SHOWNORMAL)
  511.     Call ShowWindow(ComboBoxHwnd, SW_SHOWNORMAL)
  512.     Call ShowWindow(HelpButtonHwnd, SW_SHOWNORMAL)
  513.     
  514.     'help button in caption bar
  515.     Dim FormWindowRect As Rect
  516.     GetWindowRect FormWindowHwnd, FormWindowRect
  517.     'procedure for help button
  518.     'WHook = SetWindowsHookEx(4, AddressOf HelpButtonProc, 0, App.ThreadID)
  519.     SetParent HelpButtonHwnd, GetParent(FormWindowHwnd)
  520.     SetWindowPos HelpButtonHwnd, 0, FormWindowRect.Right - 40, FormWindowRect.Top + 6, 17, 14, SWP_FRAMECHANGED
  521.     
  522.     'Dim FormWindowRect As Rect
  523.     'GetWindowRect FormWindowHwnd, FormWindowRect
  524.     'SetWindowPos HelpButtonHwnd, 0, FormWindowRect.Right - 75, FormWindowRect.Top + 6, 17, 14, SWP_FRAMECHANGED
  525.      
  526.     
  527.     'Call SetParent(HelpButtonHwnd, GetParent(FormWindowHwnd))
  528.    'Initialize the window hooking for the button
  529.     'WHook = SetWindowsHookEx(4, AddressOf HelpButtonProc, 0, App.ThreadID)
  530.     'Call SetWindowLong(HelpButtonHwnd, GWL_EXSTYLE, &H80)
  531.     'Call SetParent(HelpButtonHwnd, GetParent(FormWindowHwnd))
  532.     
  533.     'At this point the following pairs of lines must be written for each api created Window
  534.     
  535.     OKButtonOldProc = GetWindowLong(OKButtonHwnd, GWL_WNDPROC)
  536.     Call SetWindowLong(OKButtonHwnd, GWL_WNDPROC, GetAddress(AddressOf OKButtonProc))
  537.     
  538.     CancelButtonOldProc = GetWindowLong(CancelButtonHwnd, GWL_WNDPROC)
  539.     Call SetWindowLong(CancelButtonHwnd, GWL_WNDPROC, GetAddress(AddressOf CancelButtonProc))
  540.     
  541.     ComboBoxOldProc = GetWindowLong(ComboBoxHwnd, GWL_WNDPROC)
  542.     Call SetWindowLong(ComboBoxHwnd, GWL_WNDPROC, GetAddress(AddressOf ComboBoxProc))
  543.     
  544.     'dont use following two lines- VB crash - but you can try if you like
  545.     'HelpButtonOldProc = GetWindowLong(HelpButtonHwnd, GWL_WNDPROC)
  546.     'Call SetWindowLong(HelpButtonHwnd, GWL_WNDPROC, GetAddress(AddressOf HelpButtonProc))
  547.     
  548.  
  549.     'fill the combo box with our desired items
  550.     For i = 0 To UBound(AddItems)
  551.             'get max text width in list portion of combo box
  552.             '& set acordingly CB_SETHORIZONTALEXTENT !
  553.             'as result we have horizontal scroll bar
  554.             'on list portion of combo box
  555.             'only if needed otherwise not
  556.             Dim textsize As POINTAPI
  557.             'device context of combo box
  558.             DC = GetWindowDC(ComboBoxHwnd)
  559.             'measurements of text in pixels
  560.             GetTextExtentPoint32 DC, AddItems(i), Len(AddItems(i)), textsize
  561.             'set CB_SETHORIZONTALEXTENT !
  562.             SendMessage ComboBoxHwnd, CB_SETHORIZONTALEXTENT, textsize.x, ByVal 0&
  563.     'add our items
  564.     a = SendMessage(ComboBoxHwnd, CB_ADDSTRING, -1, ByVal CStr(AddItems(i)))
  565.     Next i
  566.     'a = SendMessage(OKButtonHwnd, BM_SETCHECK, 1, 0)
  567.     ' set focus to combobox
  568.     SetFocus ComboBoxHwnd
  569.     
  570.     
  571.     CreateWindows = (FormWindowHwnd <> 0)
  572.     
  573.     
  574.     'find text portion of CB Hwnd
  575.     'TextPortionOfComboBoxHwnd = FindWindowEx(ComboBoxHwnd, ByVal 0&, "EDIT", vbNullString)
  576.     'TextPortionOfComboBoxOldProc = GetWindowLong(TextPortionOfComboBoxHwnd, GWL_WNDPROC)
  577.     'Call SetWindowLong(TextPortionOfComboBoxHwnd, GWL_WNDPROC, GetAddress(AddressOf TextPortionOfComboBoxProc))
  578.     
  579.     
  580.     'auto drop down list
  581.     'b = SendMessage(ComboBoxHwnd, CB_SHOWDROPDOWN, &H0, &H0)
  582. End Function
  583. Public Function WndProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  584.  
  585.   ''This our default window procedure for the window. It will handle all
  586.   ''of our incoming window messages and we will write code based on the
  587.   ''window message what the program should do.
  588.  
  589.   Dim strTemp As String
  590.  
  591.     Select Case Message
  592.        Case WM_DESTROY:
  593.           ''Since DefWindowProc doesn't automatically call
  594.           ''PostQuitMessage (WM_QUIT). We need to do it ourselves.
  595.           ''You can use DestroyWindow to get rid of the window manually.
  596.           
  597.           'following two lines for HelpButton
  598.           'Call UnhookWindowsHookEx(WHook)
  599.           
  600.           'next line enables destruction of HelpButton
  601.           Call SetParent(HelpButtonHwnd, FormWindowHwnd)
  602.           
  603.           
  604.           Call PostQuitMessage(0&)
  605.       Case 132 'WM_NCPAINT = &H85
  606.          'ignore this coz it is constantly appearing in case
  607.          'mouse moving on the edge of combo box
  608.       Case 32 ' Const WM_SETCURSOR = &H20
  609.           'ignore this coz it is constantly appearing
  610.       Case 512 ' WM_MOUSEFIRST = &H200
  611.           'ignore this coz it is constantly appearing in case
  612.           'mouse moving on the edge of combo box
  613.       Case 160 ' mouse move in non client area of our form
  614.       
  615.       Case 3, 133 'WM_NCPAINT = &H85 or WM_MOVE = &H3
  616.       'reset our help button position
  617.       Dim FormWindowRect As Rect
  618.       GetWindowRect FormWindowHwnd, FormWindowRect
  619.       SetWindowPos HelpButtonHwnd, 0, FormWindowRect.Right - 40, FormWindowRect.Top + 6, 17, 14, SWP_FRAMECHANGED
  620.        Case Else
  621.        'Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  622.     End Select
  623.     
  624.  
  625.   ''Let windows call the default window procedure since we're done.
  626.   WndProc = DefWindowProc(hwnd&, Message, wParam&, lParam&)
  627.  
  628. End Function
  629. Public Function OKButtonProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  630.  
  631.     Select Case Message
  632.        Case WM_LBUTTONUP:
  633.        exitprocedure
  634.        Case Else
  635.     End Select
  636.     
  637.   ''Since in MyCreateWindow we made the default window proc
  638.   ''this procedure, we have to call the old one using CallWindowProc
  639.   OKButtonProc = CallWindowProc(OKButtonOldProc, hwnd&, Message, wParam&, lParam&)
  640.    
  641. End Function
  642. Public Function CancelButtonProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  643.  
  644.     Select Case Message
  645.        Case WM_LBUTTONUP:
  646.        DestroyWindow FormWindowHwnd 'kill our window
  647.     End Select
  648.     
  649.   ''Since in MyCreateWindow we made the default window proc
  650.   ''this procedure, we have to call the old one using CallWindowProc
  651.   CancelButtonProc = CallWindowProc(CancelButtonOldProc, hwnd&, Message, wParam&, lParam&)
  652.    
  653. End Function
  654. Public Function ComboBoxProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  655.    
  656.      
  657.      
  658.     Select Case Message
  659.  '   Case 307
  660.  '   GoTo 10
  661.     
  662.  '   CharCountNew = SendMessage(ComboBoxHwnd, WM_GETTEXTLENGTH, 0, 0)
  663.     
  664.  '   If CharCountOld >= CharCountNew Then GoTo 10 Else
  665.     
  666.  '  a = SendMessage(ComboBoxHwnd, WM_GETTEXTLENGTH, 0, ByVal 0&)
  667.  '  Dim buffer As String
  668.  '  buffer = String(a, Chr$(0))
  669.  '  b = SendMessage(ComboBoxHwnd, WM_GETTEXT, -1, ByVal buffer)
  670.     'now buffer contains our text in combo box
  671.     
  672.  '    For i = 0 To UBound(AddItems) ' loop thrue array and look at items
  673.  '    s = Left(AddItems(i), Len(buffer))
  674.  '           If Left(AddItems(i), Len(MyStr)) = buffer Then
  675.  '           SetWindowText ComboBoxHwnd, AddItems(i) ' ok set combobox text to found item
  676.  '           a = SendMessage(lParam, EM_SETSEL, LenghtOfCurrentString, Len(AddItems(i)))
  677.             'Beep
  678.             'avoid = True
  679.             
  680.             'DoEvents
  681.             'SendMessage ComboBoxHwnd, WM_UPDATEUISTATE, 0, 0
  682.             'SetFocus ComboBoxHwnd
  683.    '         Exit For
  684.    '         End If
  685.   '  Next i
  686.  '   End If 'od goto 10
  687. '10
  688.     
  689.  
  690.     'Dim buffer As String
  691.     'buffer = String(GetWindowTextLength(ComboBoxHwnd) + 1, Chr$(0))
  692.     'Get the window's text
  693.     'a = GetWindowText(ComboBoxHwnd, buffer, Len(buffer))
  694.     'Beep
  695.     'Debug.Print buffer
  696.     'Case 308 'WM_CTLCOLORLISTBOX = &H134, some action in list portion
  697.     
  698.     Case 342
  699.         ' appears after keyup and down on list portion
  700.         'emidiatly after that 343 message appears so:
  701.         trouble = True
  702.     Case 343 ' enter was pressed
  703.         If trouble = True Then
  704.         trouble = False
  705.         GoTo 9
  706.         End If
  707.     ComboBoxProc = CallWindowProc(ComboBoxOldProc, hwnd&, Message, wParam&, lParam&)
  708.     'here we use Post message instad Send mesage otherwise everything goes to hell
  709.     PostMessage OKButtonHwnd, BM_CLICK, 0, 0
  710. 9
  711.     Case 132 'WM_NCPAINT = &H85
  712.     'ignore this coz it is constantly appearing in case
  713.     'mouse moving on the edge of combo box
  714.     Case 32 ' Const WM_SETCURSOR = &H20
  715.     'ignore this coz it is constantly appearing
  716.     Case 512 ' WM_MOUSEFIRST = &H200
  717.     'ignore this coz it is constantly appearing in case
  718.     'mouse moving on the edge of combo box
  719.     Case 273 ' hex 111 WM_COMMAND, on any key press + last event after selection from list portion of CB
  720.         Select Case wParam
  721.         Case 16778217 ' got focus or something like that
  722.         Case 66536 ' after selection from list portion of combo box
  723.         Case 67109865 'key down I think
  724.             'OK we capture entire text, including last action here
  725.             CharCountNew = SendMessage(ComboBoxHwnd, WM_GETTEXTLENGTH, 0, ByVal 0&)
  726.             Dim buffer As String
  727.             buffer = String(CharCountNew, Chr$(0))
  728.             b = SendMessage(ComboBoxHwnd, WM_GETTEXT, -1, ByVal buffer)
  729.             'now buffer contains our text in combo box
  730.             'Debug.Print "273," & buffer
  731.             
  732.                 If CharCountOld < CharCountNew Then '
  733.                 'execute autofill text portion
  734.                     'get index of first item starting with "buffer" string
  735.                     a = SendMessage(ComboBoxHwnd, CB_FINDSTRING, -1, ByVal CStr(buffer))
  736.                     'get this item text lenght
  737.                     b = SendMessage(ComboBoxHwnd, CB_GETLBTEXTLEN, a, ByVal 0&)
  738.                         If b = -1 Then 'means there is nothing found in list box port
  739.                         'jump a little to avoid fatal error
  740.                         GoTo 10
  741.                         End If
  742.                     'create buffer1
  743.                     Dim buffer1 As String
  744.                     buffer1 = String(b, Chr$(0))
  745.                     Beep
  746.                     'get this item text into buffer1
  747.                     C = SendMessage(ComboBoxHwnd, CB_GETLBTEXT, a, ByVal buffer1)
  748.                     'set combobox text to our yust found string
  749.                     d = SendMessage(ComboBoxHwnd, WM_SETTEXT, 0, ByVal CStr(buffer1))
  750.                     ' select auto added portion of string, lParam = text box portion hWnd of our combo box
  751.                     e = SendMessage(lParam, EM_SETSEL, CharCountNew, 0)
  752.                     Beep
  753. 10
  754.                 'and do this
  755.                 CharCountOld = CharCountNew
  756.                 Else
  757.                 'do nothing as back space was pressed
  758.                 CharCountOld = CharCountOld - 1
  759.                 If CharCountOld < 0 Then CharCountOld = 0
  760.                 End If
  761.  
  762.         Case 50332649 ' key up I think
  763.         Case 83952617 ' limited text - i.e you typed to max extend possible, combo doesn't receive amy more keyboard inputs that is in case there is no WS_AUTOHSCROLL style
  764.         Case Else
  765.         'Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  766.         End Select
  767.     Case 307 'generaly something pressed on keyboard
  768.         Select Case wParam
  769.         'Case 1518 ' somewhere at loading
  770.         'Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  771.         Case Else
  772.         'Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  773.         End Select
  774.     Case Else
  775.     'Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  776.     End Select
  777.     
  778.     
  779.     
  780.     
  781.     
  782.     'Case 15
  783.     'ignore this one
  784.     'Case 100
  785.     '    Select Case lParam
  786.     '    Case 17
  787.     '    Case Else
  788.     '    Debug.Print Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  789.     '    End Select
  790.         
  791.     'Case 307
  792.     'first time 307 appears during loading
  793.     'lparam of 307 = TextPortionOfComboBoxHwnd
  794.     'we will make function to capture events from TextPortionOfComboBox
  795.     'We need this since inputs from keyboard doesn't go to combo box i.e.
  796.     'combobox doesn't aware which key was pressed
  797.     'We need this avareness to make autotype ability of combobox.
  798.     'If FirstTime307Passed = False Then
  799.     '    FirstTime307Passed = True
  800.     '    TextPortionOfComboBoxHwnd = lParam
  801.     '    TextPortionOfComboBoxOldProc = GetWindowLong(TextPortionOfComboBoxHwnd, GWL_WNDPROC)
  802.     '    Call SetWindowLong(TextPortionOfComboBoxHwnd, GWL_WNDPROC, GetAddress(AddressOf TextPortionOfComboBoxProc))
  803.     'End If
  804.     
  805.     
  806.     'Case 514 ' ignore this
  807.     'Case 1060 ' ignore this
  808.     'Case 7 ' ignore this
  809.     'Case 8 ' ignore this
  810.     'Case 12 ' ignore this &HC WM_SETTEXT
  811.     'Case 13 'WM_GETTEXT = &HD
  812.     
  813.     'CharCountNew = wParam
  814.     '    If CharCountNew < CharCountOld Then
  815.     '    avoid = True
  816.     '    End If
  817.     'CharCountOld = CharCountNew
  818.     'Case 14 'WM_GETTEXTLENGTH = hex &HE
  819.     
  820.     'Case 33 'ignore this
  821.     'l = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, ByVal CStr(Combo1.Text))
  822.     'Case 308 'mouse move above certain item
  823.     'a = SendMessage(ComboBoxHwnd, CB_GETCURSEL, 0, 0) 'items index
  824.     'Dim b As String
  825.     'b = SendMessage(ComboBoxHwnd, CB_GETLBTEXTLEN, a, &H0) 'items text lenght
  826.     'SetWindowText TextHwnd, b
  827.     'Case 70 ' like Combo_Change() event in VB
  828.     'Case 32 'mouse over
  829.    
  830.     'Case 307 ' hex 133 WM_CTLCOLOREDIT
  831.     'Beep
  832.     'Case 70 ' hex 46 WM_WINDOWPOSCHANGING
  833.     
  834.     'SetWindowText TextHwnd, Message & "," & wParam & "," & lParam
  835.     'If avoid Then avoid = False: GoTo 10
  836.     
  837.     
  838.     'get current text in text portion of combobox
  839.     'Dim MyStr As String
  840.     'Create a buffer
  841.     'MyStr = String(GetWindowTextLength(ComboBoxHwnd) + 1, Chr$(0))
  842.     'Get the window's text
  843.     'a = GetWindowText(ComboBoxHwnd, MyStr, Len(MyStr))
  844.     'MyStr = Left(MyStr, Len(MyStr) - 1)
  845.     'Dim LenghtOfCurrentString As Integer ' will hold typed in text lenght
  846.     'LenghtOfCurrentString = Len(MyStr)
  847.     
  848.     
  849.     'If MyStr = "" Then GoTo 10 ' not interested for our for ... next
  850.     
  851.    ' For i = 0 To UBound(AddItems) ' loop thrue array and look at items
  852.    ' s = Left(AddItems(i), Len(MyStr))
  853.     '    If Left(AddItems(i), Len(MyStr)) = MyStr Then
  854.     '    SetWindowText ComboBoxHwnd, AddItems(i) ' ok set combobox text to found item
  855.     '    a = SendMessage(lParam, EM_SETSEL, LenghtOfCurrentString, Len(AddItems(i)))
  856.         'Beep
  857.         'avoid = True
  858.         
  859.         'DoEvents
  860.         'SendMessage ComboBoxHwnd, WM_UPDATEUISTATE, 0, 0
  861.         'SetFocus ComboBoxHwnd
  862.         'Exit For
  863.         'End If
  864.     'Next i
  865.     
  866.     
  867. '10
  868.     'get first items index in combo box list portion that has starts same as MyStr
  869.     ' l = -1 if nothing found or items index if found
  870.     'l = SendMessage(ComboBoxHwnd, CB_FINDSTRING, -1, ByVal CStr(MyStr))
  871.     'If l <> -1 Then
  872.     'm = SendMessage(ComboBoxHwnd, CB_GETITEMTEXT, l, 4)
  873.     'End If
  874.     'Beep
  875.     'Beep
  876.     
  877.     'Case 343? hex 157 CB_GETDROPPEDSTATE on any ENTER key on combo box
  878.     'Case Else
  879.     'Beep
  880.      'a = SendMessage(ComboBoxHwnd, CB_ADDSTRING, -1, ByVal CStr(Message))
  881.     'SetWindowText TextHwnd, Message & "," & wParam & "," & lParam
  882.     
  883.      
  884.     'End Select
  885.     
  886.     
  887.     
  888.   ''Since in MyCreateWindow we made the default window proc
  889.   ''this procedure, we have to call the old one using CallWindowProc
  890.   ComboBoxProc = CallWindowProc(ComboBoxOldProc, hwnd&, Message, wParam&, lParam&)
  891.    
  892. End Function
  893.  
  894.  
  895.  
  896. 'Public Function TextPortionOfComboBoxProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  897. 'SendMessage ComboBoxHwnd, Message, wParam, lParam
  898. 'Select Case Message
  899. 'Case 15
  900. ''Case 257
  901. 'Case Else
  902. 'Debug.Print "aaa" & Message & ", &H" & Hex(Message) & "," & wParam & "," & lParam
  903. 'End Select
  904. ''Since in MyCreateWindow we made the default window proc
  905.   ''this procedure, we have to call the old one using CallWindowProc
  906. '  TextPortionOfComboBoxProc = CallWindowProc(TextPortionOfComboBoxOldProc, hwnd&, Message, wParam&, lParam&)
  907. 'End Function
  908.  
  909.  
  910. Public Function HelpButtonProc(ByVal hwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  911. Beep
  912. HelpButtonProc = CallWindowProc(HelpButtonOldProc, hwnd&, Message, wParam&, lParam&)
  913. End Function
  914. Public Function GetAddress(ByVal lngAddr As Long) As Long
  915.     ''Used with AddressOf to return the address in memory of a procedure.
  916.  
  917.     GetAddress = lngAddr&
  918.     
  919. End Function
  920.  
  921. Private Sub exitprocedure()
  922.  
  923.                  Dim MyStr As String
  924.                  'Create a buffer
  925.                  MyStr = String(GetWindowTextLength(ComboBoxHwnd) + 1, Chr$(0))
  926.                  'Get the window's text
  927.                  a = GetWindowText(ComboBoxHwnd, MyStr, Len(MyStr))
  928.                  If Len(MyStr) = 1 Then GoTo 11 ' if user didnt type anything
  929.                  IBCBSelectedItem = MyStr
  930.                  
  931.                  MsgBox "Selection is now waiting as Public IBCBSelectedItem for further use, you selected:" & IBCBSelectedItem
  932.                  
  933.                  'Terminate the window hooking
  934.                  'Call UnhookWindowsHookEx(WHook)
  935.                  'Call SetParent(HelpButtonHwnd, FormWindowHwnd)
  936. 11
  937.                  
  938.                  DestroyWindow FormWindowHwnd 'kill our window
  939.  
  940. End Sub
  941.  
  942. 'Public Function HelpButtonProc(ByVal nCode&, ByVal wParam&, Inf As CWPSTRUCT)
  943. '    Beep
  944. 'End Function
  945.