home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / VBWRAP.ZIP / VBMAGIC.BAS < prev    next >
BASIC Source File  |  1994-02-04  |  17KB  |  569 lines

  1. ' Visual Basic Magic Wrappers
  2. ' Copyright (c) 1992, 1993, 1994
  3. ' Big Dog Software
  4. ' 25 Shirley Parkway
  5. ' Piscataway, N.J. 08854-4444
  6. ' ALL RIGHTS RESERVED
  7.  
  8. Option Explicit
  9. DefInt A-Z
  10. Const nuls$ = ""
  11. Const zero = 0
  12. Const one = 1
  13. Const two = 2
  14. Global winver% ' e.g. 300, 310...
  15. Declare Sub cascadechildw300 Lib "User" Alias "CascadeChildWindows" (ByVal parentwin%)
  16. Declare Sub cascadechildw310 Lib "User" Alias "CascadeChildWindows" (ByVal parentwin%, ByVal style%)
  17. Declare Sub tilechildw300 Lib "User" Alias "TileChildWindows" (ByVal parentwin%)
  18. Declare Sub tilechildw310 Lib "User" Alias "TileChildWindows" (ByVal parentwin%, ByVal style%)
  19. Declare Function GetActiveWindow% Lib "User" ()
  20. Declare Function setactivewindow% Lib "User" (ByVal hWnd%)
  21. Declare Function APIsetfocus% Lib "User" Alias "SETFOCUS" (ByVal hWnd%)
  22. Declare Function APIgetversion% Lib "Kernel" Alias "GETVERSION" ()
  23. Declare Function BringWindowToTop Lib "User" (ByVal hWnd%) As Integer
  24. Declare Function SendMessage Lib "User" (ByVal hWnd, ByVal wMsg, ByVal wParam, ByVal lParam As Any)
  25. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpAppName$, ByVal lpKeyname$, ByVal nDefault%, ByVal file$) As Integer
  26. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpAppName$, ByVal lpKeyname$, ByVal lpDefault$, ByVal lpReturn$, ByVal nSize%, ByVal file$) As Integer
  27. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpAppName$, ByVal lpKeyname$, ByVal lpString$, ByVal file$) As Integer
  28. Declare Function ShowWindow Lib "User" (ByVal hWnd%, ByVal nCmdShow%) As Integer
  29. Declare Function FindWindow Lib "User" (ByVal class&, ByVal caption&) As Integer
  30. Declare Function Findwindowbyclass Lib "User" Alias "FINDWINDOW" (ByVal class$, ByVal caption$) As Integer
  31. Declare Function GetWindow Lib "User" (ByVal hWnd%, ByVal wCmd%) As Integer
  32. Declare Function GetNextWindow Lib "User" (ByVal hWnd%, ByVal wCmd%) As Integer
  33. Declare Function GetWindowText Lib "User" (ByVal hWnd%, ByVal Buf$, ByVal lBuf%) As Integer
  34. Declare Function getwindowlong Lib "User" (ByVal hWnd%, ByVal nIndex%) As Long
  35. Declare Function setwindowlong Lib "User" (ByVal hWnd%, ByVal nIndex%, ByVal dwNewLong&) As Long
  36. Declare Function APIGetWinDir Lib "KERNEL" Alias "GETWINDOWSDIRECTORY" (ByVal buvver$, ByVal buflen%) As Integer
  37. Declare Function APIGetSysDir Lib "KERNEL" Alias "GETSYSTEMDIRECTORY" (ByVal buvver$, ByVal buflen%) As Integer
  38. Declare Function winexec% Lib "KERNEL" (ByVal cmdstr$, ByVal mode%)
  39. Declare Function GetSysColor Lib "USER" (ByVal key%) As Long
  40. Declare Function SetWindowWord% Lib "USER" (ByVal myhwnd%, ByVal cmd%, ByVal poppa%)
  41.  
  42. Const SWW_HPARENT = -8
  43. Const GW_HWNDfirst = 0
  44. Const GW_HWNDNEXT = 2
  45. Const WM_USER = &H400
  46.  
  47. ' edit box messages
  48. Const ES_PASSWORD = &H20
  49. Const EM_LIMITTEXT = WM_USER + 21
  50. Const EM_SETPASSWORDCHAR = WM_USER + 28
  51. Const EM_SETREADONLY = WM_USER + 31
  52. Const EM_LINEFROMCHAR = WM_USER + 25
  53. Const EM_LINEINDEX = WM_USER + 11
  54. Const EM_LINELENGTH = WM_USER + 17
  55. Const EM_GETLINECOUNT = WM_USER + 10
  56. Const em_getline = WM_USER + 20
  57.  
  58. Global Const GWL_STYLE = -16
  59. Global Const LB_SETTABSTOPS = &H400 + 19
  60.  
  61. ' list box messages
  62. Const CB_LIMITTEXT = WM_USER + 1
  63. Const CB_ADDSTRING = WM_USER + 3
  64. Const CB_INSERTSTRING = WM_USER + 10
  65. Const CB_RESETCONTENT = WM_USER + 11
  66. Const CB_SHOWDROPDOWN = WM_USER + 15
  67. Const CB_GETITEMDATA = WM_USER + 16
  68. Const CB_SETITEMDATA = WM_USER + 17
  69. Const CB_FINDSTRING = WM_USER + 12
  70. Const CB_FINDSTRINGEXACT = WM_USER + 24
  71. Const CB_SELECTSTRING = WM_USER + 13
  72. Const LB_ADDSTRING = WM_USER + 1
  73. Const LB_RESETCONTENT = WM_USER + 5
  74. Const LB_SETITEMDATA = WM_USER + 27
  75. Const LB_GETITEMDATA = WM_USER + 26
  76. Const LB_FINDSTRINGEXACT = WM_USER + 35
  77. Const LB_FINDSTRING = WM_USER + 16
  78. Const LB_INSERTSTRING = WM_USER + 2
  79. Const LB_SELECTSTRING = WM_USER + 13
  80.  
  81. Global white3d As Long
  82. Global black3d As Long
  83. Dim line3d As Integer
  84. Dim init3d As Integer
  85. Dim appname As String
  86.  
  87. Function addlistitem (ctl As Control, Text$, index%, dataval&)
  88. On Error Resume Next
  89. ctl.AddItem Text, index
  90. ctl.ItemData(index) = dataval
  91. addlistitem = index
  92. End Function
  93.  
  94. Function addslistitem (ctl As Control, Text As String, dvalue As Long) As Integer
  95. On Error Resume Next
  96. ctl.AddItem Text
  97. ctl.ItemData(ctl.NewIndex) = dvalue
  98. addslistitem = ctl.NewIndex
  99. End Function
  100.  
  101. Sub boxtrack (tb As TextBox, lb As Control)
  102. Dim stringsrch$, index%
  103. stringsrch = Trim$(tb.Text)
  104. If Len(stringsrch) Then
  105.     index = findstring(lb, zero, stringsrch)
  106. Else
  107.     index = -1
  108. End If
  109. If index < lb.ListCount Then
  110.     lb.ListIndex = index
  111. End If
  112. End Sub
  113.  
  114. Sub cascadechildren (Parent%, style%)
  115. Dim i%
  116. i = getversion()
  117. Select Case winver
  118.     Case 300
  119.         cascadechildw300 Parent
  120.     Case 310
  121.         cascadechildw310 Parent, style
  122. End Select
  123. End Sub
  124.  
  125. Sub center (fname As Form)
  126. fname.Move (screen.Width - fname.Width) / two, (screen.Height - fname.Height) / two
  127. End Sub
  128.  
  129. Sub clearlistbox (alistbox As Control)
  130. ' VB1.0
  131. Dim flag As Integer, i%
  132. If TypeOf alistbox Is ListBox Then flag = True
  133. If flag Then
  134.     i = sendmessagetocontrol(alistbox, LB_RESETCONTENT, zero, zero)
  135. ElseIf TypeOf alistbox Is ComboBox Then
  136.     i = sendmessagetocontrol(alistbox, CB_RESETCONTENT, zero, zero)
  137. Else
  138.     MsgBox "Improper use of ClearListBox", 48, "BUG!!"
  139. End If
  140. End Sub
  141.  
  142. Function crypt$ (action$, key$, src$)
  143. 'trivial perturbed encription algorithm
  144. Dim count%, keypos%, keylen%, srcasc%, dest$, srcpos%, xtest$
  145. keylen = Len(key)
  146. If UCase$(action) = "E" Then
  147.     For srcpos = one To Len(src)
  148.         srcasc = Asc(Mid$(src, srcpos, one))
  149.         If keypos < keylen Then keypos = keypos + one Else keypos = one
  150.         xtest = Hex$(srcasc Xor Asc(Mid$(key, keypos, one)))
  151.         dest = dest + Format$(xtest, "@@")
  152.     Next srcpos
  153. ElseIf UCase$(action) = "D" Then
  154.     For srcpos = one To Len(src) Step two
  155.         srcasc = Val("&H" + Trim$(Mid$(src, srcpos, two)))
  156.         If keypos < keylen Then keypos = keypos + one Else keypos = one
  157.         dest = dest & Chr$(srcasc Xor Asc(Mid$(key, keypos, one)))
  158.     Next srcpos
  159. End If
  160. crypt = dest
  161. End Function
  162.  
  163. Function em_getlinetext$ (eb As Control, lineno%)
  164. Dim linelen%, firstchar%, buffer$, ret%
  165. firstchar = sendmessagetocontrol(eb, EM_LINEINDEX, lineno, zero)
  166. If firstchar < zero Then
  167.     em_getlinetext = nuls
  168.     MsgBox "Programmer attempted to select text for line" + Str$(lineno) + ".  This line does not exist.", 48, "BUG ALERT"
  169.     Exit Function
  170. End If
  171. linelen = sendmessagetocontrol(eb, EM_LINELENGTH, firstchar, zero)
  172. If linelen < zero Then
  173.     em_getlinetext = nuls
  174.     MsgBox "Unable to determine line length", 48, "BUG ALERT"
  175.     Exit Function
  176. End If
  177. If linelen > zero Then
  178.     buffer = Space(linelen + one)
  179.     ret = sendstringtocontrol(eb, em_getline, lineno, buffer)
  180.     em_getlinetext = Left$(buffer, linelen)
  181. Else
  182.     em_getlinetext = nuls
  183. End If
  184. End Function
  185.  
  186. Function em_getnumlines& (eb As Control)
  187. em_getnumlines = sendmessagetocontrol(eb, EM_GETLINECOUNT, zero, zero)
  188. End Function
  189.  
  190. Function findstring% (ctl As Control, start%, Text As String)
  191. If TypeOf ctl Is ListBox Then
  192.     findstring = sendstringtocontrol(ctl, LB_FINDSTRING, start, Text)
  193. ElseIf TypeOf ctl Is ComboBox Then
  194.     findstring = sendstringtocontrol(ctl, CB_FINDSTRING, start, Text)
  195. Else
  196.     MsgBox "findstring may only be used with listbox, combobox or multilist."
  197.     findstring = -1
  198. End If
  199. End Function
  200.  
  201. Function findstringexact% (ctl As Control, Text As String)
  202. If TypeOf ctl Is ListBox Then
  203.     findstringexact = sendstringtocontrol(ctl, LB_FINDSTRINGEXACT, zero, Text)
  204. ElseIf TypeOf ctl Is ComboBox Then
  205.     findstringexact = sendstringtocontrol(ctl, CB_FINDSTRINGEXACT, zero, Text)
  206. Else
  207.     MsgBox "findstringexact may only be used with listbox, combobox or multilist."
  208.     findstringexact = -1
  209. End If
  210. End Function
  211.  
  212. Function getblack3d& ()
  213. getblack3d = black3d
  214. End Function
  215.  
  216. Function getlistdata% (alistbox As Control, index%)
  217. Dim flag As Integer, rogue&, i%
  218. If TypeOf alistbox Is ListBox Then flag = True
  219. If flag Then
  220.     i = sendmessagetocontrol(alistbox, LB_GETITEMDATA, index, 0&)
  221. ElseIf TypeOf alistbox Is ComboBox Then
  222.     i = sendmessagetocontrol(alistbox, CB_GETITEMDATA, index, 0&)
  223. Else
  224.     MsgBox "Improper use of getlistdata", 48, "BUG!!"
  225.     i% = -1
  226. End If
  227. getlistdata = i
  228. End Function
  229.  
  230. Function getprofileint (sect$, entry$, def%) As Integer
  231. If Trim$(appname) = nuls Then
  232. Beep
  233. MsgBox "Application name not specified in getprofileint", 48, "ERROR"
  234. getprofileint = zero
  235. Exit Function
  236. End If
  237. getprofileint = GetPrivateProfileInt(sect, entry, def, appname)
  238. End Function
  239.  
  240. Function getprofilename$ ()
  241. getprofilename = appname
  242. End Function
  243.  
  244. Function getprofilestring (section$, entry$, default$, buffer$, size%) As Integer
  245. Dim a$, i%
  246. '
  247. ' prepare the string with nulls, and make sure it is big enough
  248. '
  249. If Trim$(appname) = nuls Then
  250. Beep
  251. MsgBox "Application name not specified in getprofilestring", 48, "ERROR"
  252. getprofilestring = zero
  253. Exit Function
  254. End If
  255. a = String$(size + two, zero)
  256. i = GetPrivateProfileString(section, entry, default, a, size + one, appname)
  257. a = Left$(a, i)
  258. i = InStr(a, Chr$(zero))
  259. If i Then
  260.     If i = one Then
  261.         a = nuls
  262.     Else
  263.         a = Left$(a, i - one)
  264.     End If
  265. End If
  266. a = Trim$(a)
  267. i = Len(a)
  268. If i > size Then i = size
  269.  
  270. buffer = Left$(a, i)
  271. getprofilestring = i
  272. End Function
  273.  
  274. Function GetSystemDirectory$ ()
  275. Dim workspace As String, i%, j%
  276. workspace = "  "
  277. i = APIGetSysDir(workspace, one)
  278. If i > zero Then
  279.     workspace = String$(i + one, Chr$(zero))
  280.     j = APIGetSysDir(workspace, i)
  281.     If j > zero Then
  282.         GetSystemDirectory = Left$(workspace, j)
  283.         Exit Function
  284.     End If
  285. End If
  286. GetSystemDirectory = "ERROR"
  287. End Function
  288.  
  289. Function getversion% ()
  290. Dim intver%
  291. intver = APIgetversion()
  292. winver = (intver And &HFF) * 100 + (intver And &HFF00) / 256
  293. getversion = winver
  294. End Function
  295.  
  296. Function getwhite3d& ()
  297. getwhite3d = white3d
  298. End Function
  299.  
  300. Function getwindowsdirectory$ ()
  301. Dim workspace As String, i%, j%
  302. workspace = "  "
  303. i = APIGetWinDir(workspace, one)
  304. If i > zero Then
  305.     workspace = String$(i% + one, Chr$(zero))
  306.     j = APIGetWinDir(workspace, i)
  307.     If j > zero Then
  308.         getwindowsdirectory = Left$(workspace, j)
  309.         Exit Function
  310.     End If
  311. End If
  312. getwindowsdirectory = "ERROR"
  313. End Function
  314.  
  315. Sub notelaunch (filename$)
  316. Dim s$, i%, j%, l%, w$, sep$, comstr$, temps$
  317. Const SW_SHOW = 5
  318. Const SW_RESTORE = 4
  319. s = Trim$(filename)
  320. i = InStr(s, Chr$(zero))
  321. If i Then s = Left$(s, i - one)
  322. i = InStr(s, " ")
  323. If i Then s = Left$(s, i - one)
  324. i = InStr(s, Chr$(9))
  325. If i Then s = Left$(s, i - one)
  326. i = InStr(s, ".")
  327. If i Then s = Left$(s, i - one)
  328. l = Len(s)
  329. If l = zero Then
  330.     s = "TEMP.TXT"
  331. Else
  332.     s = s + ".TXT"
  333. End If
  334. i = InStr(s, "\")
  335. If i = zero Then
  336.     w = getwindowsdirectory()
  337.     i = Len(w)
  338.     sep = Right$(w$, one)
  339.     If sep <> "\" Then w$ = w$ + "\"
  340. Else
  341.     w = nuls
  342. End If
  343. w = w + s
  344. comstr = "NOTEPAD.EXE " + w
  345. temps = "Notepad - " + s
  346. i = Findwindowbyclass("Notepad", temps)
  347. If i Then
  348.     j = ShowWindow(i, SW_RESTORE)
  349.     j = BringWindowToTop(i)
  350. Else
  351.     i = winexec(comstr, SW_SHOW)
  352.     If i < 32 Then
  353.         MsgBox "Unable to activate the notepad.", 48, "WARNING"
  354.     End If
  355. End If
  356. End Sub
  357.  
  358. Sub relatemeto (baby As Form, poppa As Form)
  359. Dim ret%
  360. ret = SetWindowWord(baby.hWnd, SWW_HPARENT, poppa.hWnd)
  361. End Sub
  362.  
  363. Function SearchWindow% (search$)
  364. Dim capt As String, wnd%, length%, source$
  365. Dim dest As String
  366.     dest = UCase$(search)
  367.     wnd = FindWindow(zero, zero)
  368.     wnd = GetWindow(wnd, GW_HWNDfirst)
  369.     While wnd
  370.         capt = String$(256, zero)
  371.         length = GetWindowText(wnd, capt, 255)
  372.         If length > zero Then
  373.             source = UCase$(Left$(capt, length))
  374.             If InStr(source, dest) Then
  375.                 capt = nuls
  376.                 source = nuls
  377.                 dest = nuls
  378.                 SearchWindow = wnd
  379.                 Exit Function
  380.             End If
  381.         End If
  382.         capt = nuls
  383.         wnd = GetNextWindow(wnd, GW_HWNDNEXT)
  384.     Wend
  385.     source = nuls
  386.     dest = nuls
  387.     SearchWindow = zero
  388. End Function
  389.  
  390. Function selectstring% (ctl As Control, start%, Text As String)
  391. If TypeOf ctl Is ListBox Then
  392.     selectstring = sendstringtocontrol(ctl, LB_SELECTSTRING, zero, Text)
  393. ElseIf TypeOf ctl Is ComboBox Then
  394.     selectstring = sendstringtocontrol(ctl, CB_SELECTSTRING, zero, Text)
  395. Else
  396.     MsgBox "findstring may only be used with listbox, combobox or multilist."
  397.     selectstring = -1
  398. End If
  399.  
  400. End Function
  401.  
  402. Function sendmessagetocontrol% (ctl As Control, wMsg, wParam, lParam&)
  403. sendmessagetocontrol = SendMessage(ctl.hWnd, wMsg, wParam, lParam)
  404. End Function
  405.  
  406. Function sendstringtocontrol (ctl As Control, wMsg%, wParam%, lParam$)
  407. sendstringtocontrol = SendMessage(ctl.hWnd, wMsg, wParam, lParam)
  408. End Function
  409.  
  410. Sub set_3d (white&, black&, boldness%)
  411. init3d = one
  412. If getversion() = 300 Then
  413.     black = &H808080
  414.     white = &HE0E0E0
  415. Else
  416. If black = zero Then black = GetSysColor(16)
  417. If white = zero Then white = GetSysColor(20)
  418. End If
  419. white3d = white
  420. black3d = black
  421. line3d = boldness
  422. End Sub
  423.  
  424. Sub setappname (appstring As String)
  425. Dim errno As Integer, s As String
  426. s = Trim$(appstring)
  427. If s = nuls Then errno = one
  428. If InStr(s, Chr$(9)) Then errno = one
  429. If InStr(s, " ") Then errno = one
  430. If errno Then
  431.     appname = nuls
  432. Else
  433.     appname = s
  434. End If
  435. End Sub
  436.  
  437. Function setemreadonly (ctl As Control, bool As Integer)
  438. Dim i%
  439. i = sendmessagetocontrol(ctl, EM_SETREADONLY, bool, 0&)
  440. setemreadonly = i
  441. End Function
  442.  
  443. Sub setlbtabs (lb As Control, tablist%())
  444. Dim styleword&, ret%, cnt%, jnk&, i%, tabstr$
  445. tabstr = nuls
  446. styleword = getwindowlong(lb.hWnd, GWL_STYLE)
  447. If Not styleword And &H80& Then
  448.     styleword = styleword + &H80&
  449.     jnk = setwindowlong(lb.hWnd, GWL_STYLE, styleword)
  450. End If
  451. For i = LBound(tablist) To UBound(tablist)
  452.     If tablist(i) > zero Then
  453.         cnt = cnt + one
  454.         tabstr = tabstr + Chr$(tablist(i) And 255) + Chr$(Int(tablist(i) / 256))
  455.     Else
  456.         i = UBound(tablist) + one
  457.     End If
  458. Next i
  459. If cnt = zero Then Exit Sub
  460. ret = sendstringtocontrol(lb, &H400 + 19, cnt, tabstr)
  461.  
  462. End Sub
  463.  
  464. Function setlistdata% (alistbox As Control, index%, value&)
  465. Dim dataval&
  466. dataval = value
  467.  
  468. If TypeOf alistbox Is ListBox Then
  469.     setlistdata = sendmessagetocontrol(alistbox, LB_SETITEMDATA, index, dataval)
  470. ElseIf TypeOf alistbox Is ComboBox Then
  471.     setlistdata = sendmessagetocontrol(alistbox, CB_SETITEMDATA, index, dataval)
  472. Else
  473.     MsgBox "Improper use of setlistdata", 48, "BUG!!"
  474.     setlistdata = -1
  475. End If
  476. End Function
  477.  
  478. Function setpasswordstyle (ctl As Control, parm%) As Integer
  479. Dim Styleflags As Long
  480. Dim hWind As Integer
  481. If TypeOf ctl Is TextBox Then
  482.     hWind = ctl.hWnd
  483.     Styleflags = getwindowlong(hWind, GWL_STYLE)
  484.     Styleflags = Styleflags Or ES_PASSWORD
  485.     Styleflags = setwindowlong(hWind, GWL_STYLE, Styleflags)
  486.     Styleflags = SendMessage(hWind, EM_SETPASSWORDCHAR, parm, 0&)
  487. Else
  488.     MsgBox "SetPassWordStyle: wrong control type passed.", 48, "DEBUG"
  489. End If
  490. End Function
  491.  
  492. Function settextlength (ctl As Control, size%) As Integer
  493. Dim i%
  494. If TypeOf ctl Is TextBox Then
  495.     i = sendmessagetocontrol(ctl, EM_LIMITTEXT, size, 0&)
  496. ElseIf TypeOf ctl Is ComboBox Then
  497.     i = sendmessagetocontrol(ctl, CB_LIMITTEXT, size, 0&)
  498. Else
  499.     MsgBox "Settextlength: wrong control type", 48
  500.     i = -1
  501. End If
  502. settextlength = i
  503. End Function
  504.  
  505. Sub three_dee (box As Control, style As Integer)
  506. Dim smode As Integer
  507. If init3d = zero Then
  508. set_3d zero, zero, 4
  509. End If
  510.  
  511. smode = box.Parent.ScaleMode
  512. box.Parent.ScaleMode = 3
  513. Dim white&, black&, t%, h%, w%, l%, i%
  514. If style = zero Then ' recessed
  515.     white = black3d
  516.     black = white3d
  517. Else
  518.     white = white3d
  519.     black = black3d
  520. End If
  521. For i = one To line3d
  522.     t = box.Top - i
  523.     l = box.Left - i
  524.     h = box.Height + two * i
  525.     w = box.Width + two * i
  526.     box.Parent.Line (l, t)-Step(zero, h), white
  527.     box.Parent.Line (l, t)-Step(w, zero), white
  528.     box.Parent.Line (l + w, t)-Step(zero, h), black
  529.     box.Parent.Line (l, t + h)-Step(w, zero), black
  530. Next i
  531. box.Parent.Line (box.Left - line3d, box.Top - line3d)-(box.Left, box.Top), box.Parent.BackColor
  532. box.Parent.ScaleMode = smode
  533. End Sub
  534.  
  535. Sub tilechildren (Parent%, style%)
  536. Dim i%
  537. i = getversion()
  538. Select Case winver
  539.     Case 300
  540.         tilechildw300 Parent
  541.     Case 310
  542.         tilechildw310 Parent, style
  543. End Select
  544. End Sub
  545.  
  546. Sub undrop (ctl As Control)
  547. Dim i%
  548. i = sendmessagetocontrol(ctl, CB_SHOWDROPDOWN, zero, 0&)
  549. End Sub
  550.  
  551. Function wndcaption$ (hWnd)
  552. Dim ss As String, length
  553.     ss = String$(256, zero)
  554.     length = GetWindowText(hWnd, ss, 255)
  555.     If length > -1 Then wndcaption = Left$(ss, length)
  556.     ss = nuls
  557. End Function
  558.  
  559. Function writeprofilestring (section As String, entry As String, value As String) As Integer
  560. If Trim$(appname) = nuls Then
  561. Beep
  562. MsgBox "Application name not specified in writeprofilestring", 48, "ERROR"
  563. writeprofilestring = zero
  564. Exit Function
  565. End If
  566. writeprofilestring = WritePrivateProfileString(section, entry, value, appname)
  567. End Function
  568.  
  569.