home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / spchauto / data1.cab / Samples / Visual_Basic / SpellCheckerDLL / VbDLL.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-16  |  5.3 KB  |  131 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Polar Spell Checker DLL Demo"
  4.    ClientHeight    =   5190
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   8040
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    ScaleHeight     =   5190
  11.    ScaleWidth      =   8040
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton btnDownload 
  14.       Caption         =   "&Download..."
  15.       Height          =   375
  16.       Left            =   6360
  17.       TabIndex        =   3
  18.       Top             =   1200
  19.       Width           =   1575
  20.    End
  21.    Begin VB.CommandButton btnCheckSel 
  22.       Caption         =   "Check &Selection..."
  23.       Height          =   375
  24.       Left            =   6360
  25.       TabIndex        =   2
  26.       Top             =   600
  27.       Width           =   1575
  28.    End
  29.    Begin VB.CommandButton btnCheckAll 
  30.       Caption         =   "&Check All..."
  31.       Height          =   375
  32.       Left            =   6360
  33.       TabIndex        =   1
  34.       Top             =   120
  35.       Width           =   1575
  36.    End
  37.    Begin VB.TextBox Text1 
  38.       Height          =   5175
  39.       Left            =   0
  40.       MultiLine       =   -1  'True
  41.       TabIndex        =   0
  42.       Text            =   "VbDLL.frx":0000
  43.       Top             =   0
  44.       Width           =   6255
  45.    End
  46. Attribute VB_Name = "Form1"
  47. Attribute VB_GlobalNameSpace = False
  48. Attribute VB_Creatable = False
  49. Attribute VB_PredeclaredId = True
  50. Attribute VB_Exposed = False
  51. Private Declare Function PS_Init Lib "polspell.dll" () As Long
  52. Private Declare Sub PS_Destroy Lib "polspell.dll" (ByVal hSpell As Long)
  53. Private Declare Function PS_OpenDictionary Lib "polspell.dll" (ByVal hSpell As Long, ByVal pszMainDictFileName As String, ByVal pszCustomDictFileName As String) As Boolean
  54. Private Declare Sub PS_CloseDictionary Lib "polspell.dll" (ByVal hSpell As Long)
  55. Private Declare Function PS_CheckText Lib "polspell.dll" (ByVal hSpell As Long, ByVal pszText As String, pnExitStatus As Integer) As Long
  56. Private Declare Function PS_DownloadDictionaries Lib "polspell.dll" (ByVal hSpell As Long, ByVal pszUpdateURL As String, ByVal pszInstallDir As String) As Boolean
  57. Private Declare Function PS_OptionsDialog Lib "polspell.dll" (ByVal pszDictionaryDir As String, ByVal pszCustomDicFileName As String, ByVal pszCurDicFileName As String, ByVal pszDownloadURL As String, ByVal bInternetSupport As Boolean) As Boolean
  58. Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
  59. Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
  60. Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
  61. Private Declare Sub CopyMemory Lib "kernel32" (Dest As Any, Source As Any, ByVal NumBytes As Long)
  62. Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpstr As Any) As Long
  63. Private Declare Sub lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal Dest As Any, ByVal src As Any)
  64. Dim g_strMainDictFileName As String
  65. Dim g_strCustomDictFileName As String
  66. Dim g_hSpell As Long
  67. Private Sub btnCheckAll_Click()
  68.     Dim Text As String
  69.     Dim hglbMem As Long
  70.     Dim psz As Long
  71.     Dim ExitStatus As Integer
  72.     ' Open dictionary
  73.     If PS_OpenDictionary(g_hSpell, App.Path + "\" + g_strMainDictFileName, g_strCustomDictFileName) <> False Then
  74.        Text = Text1.Text
  75.        ' Check text
  76.        hglbMem = PS_CheckText(g_hSpell, Text, ExitStatus)
  77.        psz = GlobalLock(hglbMem)
  78.        Text = Space$(lstrlen(psz) + 1)
  79.        lstrcpy Text, psz
  80.        GlobalUnlock hglbMem
  81.        GlobalFree hglbMem
  82.        ' Set checked text to text box
  83.        Text1.Text = Text
  84.        ' Close dictionary
  85.        PS_CloseDictionary (g_hSpell)
  86.     Else
  87.        MsgBox ("Cannot open dictionary " + App.Path + "\" + g_strMainDictFileName)
  88.     End If
  89. End Sub
  90. Private Sub btnCheckSel_Click()
  91.     Dim Text As String
  92.     Dim hglbMem As Long
  93.     Dim psz As Long
  94.     Dim ExitStatus As Integer
  95.     Text = Text1.SelText
  96.     If (Text = "") Then
  97.         MsgBox "Nothing is selected."
  98.         Exit Sub
  99.     End If
  100.     ' Open dictionary
  101.     If PS_OpenDictionary(g_hSpell, App.Path + "\" + g_strMainDictFileName, g_strCustomDictFileName) <> False Then
  102.        ' Check text
  103.        hglbMem = PS_CheckText(g_hSpell, Text, ExitStatus)
  104.        psz = GlobalLock(hglbMem)
  105.        Text = Space$(lstrlen(psz))
  106.        lstrcpy Text, psz
  107.        GlobalUnlock hglbMem
  108.        GlobalFree hglbMem
  109.        ' Set checked text to text box
  110.        Text1.SelText = Text
  111.        ' Close dictionary
  112.         PS_CloseDictionary (g_hSpell)
  113.     Else
  114.        MsgBox ("Cannot open dictionary " + App.Path + "\" + g_strMainDictFileName)
  115.     End If
  116. End Sub
  117. Private Sub btnDownload_Click()
  118.    PS_DownloadDictionaries g_hSpell, "http://www.polarsoftware.com/install/dictionaries.ins", App.Path
  119. End Sub
  120. Private Sub btnOptions_Click()
  121.    PS_OptionsDialog App.Path, g_strCustomDictFileName, g_strMainDictFileName, "http://www.polarsoftware.com/install/dictionaries.ins", True
  122. End Sub
  123. Private Sub Form_Load()
  124.    g_strMainDictFileName = "SpellUs.lex"
  125.    g_strCustomDictFileName = App.Path + "\custom.dic"
  126.    g_hSpell = PS_Init()
  127. End Sub
  128. Private Sub Form_Unload(Cancel As Integer)
  129.    PS_Destroy (g_hSpell)
  130. End Sub
  131.