Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Verification Word generation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Verification Word generation

    Just a month ago, a thread was started in Cafe PowerBASIC Forum related with the bogus or false members that join to a forum. See Bogus members joining forums. Normally these entries are caused by 'bots' or automated operators.

    One of methods to avoid or minimize this problem is require some manual (human) intervention. A verification word is one of this. Some of benefits to use a verification word can be:

    - Website Registration more protected
    - Protection againts search Engine Bots
    - Online surveys and polls
    - Prevent automated comments Spam in Blogs
    etc...

    If a verification word is created and sent to user like an masked image is very difficult that a normal program can 'see' correctly the word and reenter this. Provide 'some' protection and privacity.

    This is the program written with that purpose.

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' VerifyWord.bas                     Jordi Vallès      version 1b     12/12/2008
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' This program is a CAPTCHA.
    '
    ' A CAPTCHA is a program that protects websites against bots by generating and
    ' grading tests that humans can pass but current computer programs cannot.
    '
    ' Explanation, history, details and several references in:
    ' [URL="http://en.wikipedia.org/wiki/Captcha"]CAPTCHA, references[/URL]
    '
    ' This program generates a verification word created as an image with each
    ' random character with different font, excluding the symbols and confusing
    ' characters over a little variable grid with different colours and format.
    ' Also background color changes lightly on each generation.
    '
    ' - Characters are created in normal, bold or italic style, at random.
    ' - By average, one of each five chars is a number.
    ' - Excluded fontname list that generates symbols, strange or confusing chars.
    '   List based on fonts found on my PC with Vista SP1 and Office 2000 and
    '   must be maintained by user.
    ' - A filter for 0's, O's and I's can be selected.
    ' - Word length can be from 3 to 12 characters.
    ' - Image created can be saved on disk as BMP file with the adequate length in
    '   same program folder. The file name is the same verification word.
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '  - Program developed, compiled and tested with PowerBASIC for Windows 9.00 on
    '    a PC HP Pavilion m7760 1.80 GHz with Windows Vista Home Premium SP1.
    '  - Code posted here is released to the Public Domain. Use at your own risk.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' SED_PBWIN
    
    #Compiler PBWin 9
    #Compile Exe "VerifyWord.exe"
    #Dim All
    
    #Include "Win32Api.inc"
    #Include "CommCtrl.inc"
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    %ID_SAVE      = 1011
    %ID_GENER     = 1012
    %ID_EXIT      = 1013
    %ID_ABOUT     = 1014
    %ID_CLEAR     = 1015
    %ID_CHARS     = 1016
    %ID_NCHARS    = 1017
    %ID_AVOID     = 1018
    %ID_WORD      = 1019
    %ID_GRAPHIC   = 1041
    %ID_FONTS     = 1080        'be aware with this value
    
    %SOMEBLACK    = &h232425???
    %CANVAS       = &hD0FCFD???
    
    $TITLE        = "Verification Word generation - 1b"      'title on caption
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Global gW, gH, gWtmp         As Long
    Global gColors()           As Long
    Global gnChars, gAvoid     As Long
    Global gFonts(), gBad()       As String
    Global gWord                As String
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function PBMain () As Long
       Local hDlg As Dword
       Local signature As Asciiz * 120
        Local i As Long
    
       '--- only one instance of this program is allowed ---
       signature = $TITLE + $TITLE + $TITLE
       If CreateMutex(ByVal 0, 1, signature) Then
          If GetLastError = %ERROR_ALREADY_EXISTS Then Exit Function
       End If
    
       '--- create dialog window ---
       Dialog New Pixels, 0, $TITLE, , , 410, 291, %WS_CAPTION OR %WS_SYSMENU, 0 To hDlg
    
       Control Add Graphic,  hDlg, %ID_GRAPHIC,"", 5, 5, 400, 54, %SS_NOTIFY Or %WS_BORDER
       Control Get Client    hDlg, %ID_GRAPHIC To gW, gH        'get client (canvas) size
       Graphic Scale (0, 0) - (gW, gH)                          'scale to pixel coordinate system
    
       Graphic Attach hDlg, %ID_GRAPHIC, ReDraw
       Graphic Color %SOMEBLACK, %CANVAS
       Graphic Clear
    
       Control Add Line,     hDlg, -1,         "",                        0, 264, 430,  1, %SS_BLACKFRAME
       Control Add Button,   hDlg, %ID_EXIT,   "Exit",                    0, 266,  82, 24, %WS_TABSTOP Or %BS_OWNERDRAW
       Control Add Button,   hDlg, %ID_ABOUT,  "About",                  82, 266,  82, 24, %WS_TABSTOP Or %BS_OWNERDRAW
       Control Add Button,   hDlg, %ID_CLEAR,  "Clear",                 164, 266,  82, 24, %WS_TABSTOP Or %BS_OWNERDRAW
       Control Add Button,   hDlg, %ID_SAVE,   "Save Image",            246, 266,  82, 24, %WS_TABSTOP Or %BS_OWNERDRAW
       Control Add Button,   hDlg, %ID_GENER,  "Generate",              328, 266,  82, 24, %WS_TABSTOP Or %BS_OWNERDRAW
    
       Control Add CheckBox, hDlg, %ID_AVOID,  "avoid 0's, O's and I's",  5, 184, 150, 16
       Control Add Label,    hDlg, -2,         "number of chars to",     46, 204, 150, 14
       Control Add Label,    hDlg, -3,         "generate (3-12)",        46, 218, 100, 14
       Control Add TextBox,  hDlg, %ID_NCHARS, "",                        5, 208,  42, 22, %ES_CENTER, %WS_EX_CLIENTEDGE
       Control Add "msctls_updown32", hDlg, %ID_CHARS, "",                0,   0,  44, 24, _
                                      %WS_CHILD OR %WS_VISIBLE OR 
    S_SETBUDDYINT OR 
    S_ALIGNRIGHT
       Control Send hDlg, %ID_CHARS, 
    M_SETBUDDY, GetDlgItem(hDlg, %ID_NCHARS), 0
       Control Send hDlg, %ID_CHARS, 
    M_SETRANGE, 0, MakLng(12,3)
       Control Send hDlg, %ID_CHARS, 
    M_SETPOS, 0, 8
    
       Control Add Label,    hDlg, -6, "Word generated :",                5,  68,  88, 14
       Control Add Label,    hDlg, %ID_WORD, " ",                        95,  68, 120, 14
    
        ExcludeFontList
       FillFontList hDlg
       Control Add Label,    hDlg, -4, "Valid fonts :" + $Tab + Str$(Ubound(gFonts)), 5,  84, 130, 14
       Control Add Label,    hDlg, -5, "Invalid fonts :" + $Tab + Str$(Ubound(gBad)), 5, 100, 130, 14
    
        For i = 1 to 12
           Control Add Label, hDlg, %ID_FONTS +i, " ",                       240, 52+i*16, 160, 14
        Next i
    
       Dialog Show Modal hDlg Call DlgProc
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CallBack Function DlgProc() As Long
       Local i As Long
       Local buffer, txt As String
    
       Select Case As Long Cb.Msg
          Case %WM_INITDIALOG
                Control Send Cb.Hndl, %ID_CHARS, 
    M_GETPOS, 0, 0 To gnChars
                Control Set Check Cb.Hndl, %ID_AVOID, 1
                gAvoid = 1
                Control Disable Cb.Hndl, %ID_SAVE
                CreateColorsList
                DrawGrid
    
          Case %WM_COMMAND
             Select Case Cb.Ctl
                    Case %ID_AVOID
                        Control Get Check Cb.Hndl, %ID_AVOID To gAvoid
                Case %ID_NCHARS
                   Control Get Text Cb.Hndl, %ID_NCHARS To buffer
                   gnchars = Val(buffer)
                Case %ID_EXIT
                        If Cb.CtlMsg = %BN_CLICKED Then Dialog End Cb.Hndl
                Case %ID_GENER
                        GenerateWord Cb.Hndl
                Case %ID_SAVE
                        SaveOnFile Cb.Hndl
                Case %ID_CLEAR
                        Control Disable Cb.Hndl, %ID_SAVE
                        Graphic Clear
                        'resize the graphic space to original size
                        MoveWindow GetDlgItem(Cb.Hndl, %ID_GRAPHIC), 5, 5, gW, gH, %TRUE
                        DrawGrid
                        gWord = ""
                        For i = 1 To 12
                            Control Set Text Cb.Hndl, %ID_FONTS+i, " "
                        Next i
                        Control Set Text Cb.Hndl, %ID_WORD, " "
                    Case %ID_ABOUT
                        ShowAboutText
             End Select
    
          Case %WM_NCACTIVATE
             Static hWndSaveFocus As Dword
             If IsFalse Cb.WParam Then
                hWndSaveFocus = GetFocus()
             ElseIf hWndSaveFocus Then
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
             End If
    
          Case %WM_DRAWITEM
             Control Get Text Cb.Hndl, Cb.Ctl To txt
             DrawButtons Cb.Lparam, txt
    
       End Select
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' This procedure is the main. Is the generation word.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub GenerateWord(hWnd As Dword)
        Register i As Long
        Local hFont As Dword
        Local j, k, s, c, w, h As Long
        Local buf, fname As String
        Static ncolour As Long
    
       Randomize Timer
        CreateColorsList            'color list shuffled
        Incr ncolour  :  If ncolour = 45 Then ncolour = 1
        Graphic Color %SOMEBLACK+ncolour, %CANVAS-ncolour
        Graphic Clear
        gWord = ""
        For i = 1 To 12
            Control Set Text hWnd, %ID_FONTS+i, " "
        Next i
    
        i = 0
        Do
          'generate random letter
            'one of each five times is a number
            c = Rnd(65, 90)
          If Rnd(1, 5) = 1 Then c = Rnd(48, 57)
          buf = UCase$(Chr$(c))
            If gAvoid And (buf = "O"  Or buf = "0" Or buf = "I") Then Iterate Do
            gWord += buf
    
            'get font name
            j = Rnd(1, Ubound(gFonts))
            fname = gFonts(j)    'get font name from list
    
            'put char on graphic space
            s = Rnd(0,3)            'normal, bold, italic or bold/italic style
            Font New fname, 30, s, 0, 0, 0 To hFont    '30 points char size
            Graphic Set Font hFont
          Graphic Set Pos (2+k, 0)
          Graphic Print buf
            Font End hFont
    
            'prepare next offset
            Graphic Text Size buf To w, h
            k += w+3+s*2
    
            'display char and font name
            Control Set Text hWnd, %ID_FONTS+i+1, buf + " = " + fname
            Incr i
        Loop Until i = gnChars
    
        gWtmp = k+4                  'needed graphic width
        Control Set Text hWnd, %ID_WORD, gword
        Control Enable hWnd, %ID_SAVE
    
        'adjust graphic space to size of word generated
        MoveWindow GetDlgItem(hWnd, %ID_GRAPHIC), 5, 5, gWtmp, gH, %TRUE
    
        Drawgrid
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Draw horizontal and vertical lines
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub DrawGrid()
        Register i As Long
        Local j, k As Long
    
       For i = 1 To 4
          Graphic Line (0,i*10) - (gW,i*10), gColors(i) + 1001*i
       Next j
        k = Choose(Rnd(1,8), 40, 35, 30, 25, 20, 15, 10, 5)
       For i = 1 To 30
            j = Rnd(1,Ubound(gColors))
          Graphic Line (i*14 , 0) - (i*14-k, gH), gColors(j)
       Next j
        Graphic Redraw
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' OwnerDrawn for buttons, part of %WM_DRAWITEM
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub DrawButtons(lParam As Long, Txt As String)
       Local lpdis  As DRAWITEMSTRUCT Ptr
       Local tRect  As RECT
       Local hBrush As Dword
    
       lpdis = lParam
       tRect = @lpdis.rcItem
    
       If (@lpdis.itemState And %ODS_SELECTED) Then
          hBrush = CreateSolidBrush(Rgb(208,208,208))
          @lpdis.rcItem.nTop = 3
       Else
          hBrush = CreateSolidBrush(Rgb(228,228,228))
       End If
       FillRect @lpdis.hDc, @lpdis.rcItem, hBrush
       DrawEdge @lpdis.hDC, @lpdis.rcItem, %EDGE_RAISED, %BF_RECT
       SetBkMode @lpdis.hDc, %TRANSPARENT
    
       If (@lpdis.itemState And %ODS_DISABLED) Then
          SetTextColor @lpdis.hDc, GetSysColor(%COLOR_GRAYTEXT)
       Else
          SetTextColor @lpdis.hDc, GetSysColor(%COLOR_BTNTEXT)
       End If
    
       DrawText @lpdis.hDC, ByVal StrPtr(Txt), -1, ByVal VarPtr(@lpdis.rcItem), _
                   %DT_SINGLELINE Or %DT_CENTER Or %DT_VCENTER
       DeleteObject hBrush
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Fill a combo box with the names of all fonts of a certain type
    ' Based on a sample by Borje Hagsten
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub FillFontList(hWnd As Dword)
       Local hDC As Dword
    
       hDC = GetDC(%HWND_DESKTOP)
          EnumFontFamilies hDC, ByVal %NULL, CodePtr(EnumFontName), ByVal VarPtr(hWnd)
       ReleaseDC %HWND_DESKTOP, hDC
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Enumerate the names of all the fonts. Note the difference between
    ' how to enumerate them.
    ' Simplified version based on a example supplied by Borje Hagsten.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function EnumFontName(lf As LOGFONT, tm As TEXTMETRIC, ByVal FontType As Long, hWnd As Dword) As Long
        Static fnum As Long
    
       If (FontType And %TRUETYPE_FONTTYPE) Or ((FontType And %TMPF_FIXED_PITCH) = 0) Then
            If ValidateFont(lf.lfFaceName) Then
                Incr fnum
                Redim Preserve gFonts(1 To fnum)
                gFonts(fnum) = lf.lfFaceName
            End If
       End If
       Function = %TRUE
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Check if fontname obtained is in exclude fontname list
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function ValidateFont(fname As Asciiz) As Long
        Register i As Long
        Local buf As String
    
        buf = Lcase$(Remove$(fname," "))
        For i = 1 To Ubound(gBad)
            If buf = gBad(i) Then
                Function = %FALSE
                Exit Function
            End If
        Next i
        Function = %TRUE
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Fill an array with grey colors
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub CreateColorsList()
        Register i As Long, j As Long
        Local k As Long
    
        Redim gColors(1 To 14)
        k = 526344 * 10           'skip first obscure greys
       For i = 1 To Ubound(gColors)
          k += 526344          '526344 = &h080808???
          gColors(i) = k
       Next i                  'skip last light greys
    
       'shuffle color array (by John Gleason)
       For j = LBound(gColors) To UBound(gColors)
          i = Rnd(j, UBound(gColors))
          Swap gColors(j), gColors(i)
       Next
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Fontname list that generates symbols, strange or confusing characters
    ' List based on fonts found on my PC with Vista SP1 and Office 2000.
    ' Must be maintained by the user.
    ' To consider: list in a separate text file.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub ExcludeFontList()
        Register i As Long
    
       ReDim gBad(1 To DataCount) As String
    
        For i = 1 To Ubound(gBad)
            gBad(i) = Read$(i)
        Next i
    
       'exclude list in lowercase and without embeded spaces
        Data blackadderitc, bradleyhanditc, cambriamath, curlzmt, dokchampa
        Data edwardianscript, edwardianscriptitc, estrangeloedessa, frenchscript
       Data frenchscriptmt, gautami, jokerman, juiceitc, latha
        Data mangal, marlett, matisseitc, mistral, modern, msoutlook, mspmincho
       Data msreference, msreferencespecialty, msreference1, msreference2
        Data msserif, mtextra, mvboli,ocraextended, opensymbol, papyrus, raavi, roman
       Data script, shruti, smallfonts, symbol, tempussansitc, tunga, vivaldi
        Data webdings, wingdings, wingdings2, wingdings3
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Save the image as BMP file on same directory with filename as the word
    ' generated. Image on file has the appropriate width.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub SaveOnFile(hWnd As Dword)
        Local hBmp As Dword
    
        If gWord = "" Then Exit Sub
        Graphic Box (0,0) -(gWtmp,gH)
        Graphic Bitmap New gWtmp, gH To hBmp
       If hBmp Then
            Graphic Attach hBmp, 0
            Graphic Copy GetDlgItem(hWnd, %ID_GRAPHIC), 0, (0,0) - (gWtmp,gH) To (0,0)
            Graphic Save EXE.PATH$ + gWord + ".bmp"
            Graphic Bitmap End
            Beep
          Graphic Attach hWnd, %ID_GRAPHIC, ReDraw
        End If
    End Sub
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Sub ShowAboutText()
       Local txt As String
    
       txt  = "Verification Word generation" + $CrLf
       txt += "Version 1b" + $CrLf
       txt += "December 2008" + $CrLf + $CrLf
       txt += "This program generates a verification word created as an" + $CrLf
        txt += "image with each random character with different font," + $CrLf
        txt += "excluding the symbols and confusing characters over a" + $CrLf
        txt += "light variable grid with different colours and format." + $CrLf + $CrLf
    
       txt += "Some details and characteristics:" + $CrLf
        txt += " - Characters are in normal, bold or italic style, at random." + $CrLf
        txt += " - By average, one of each five chars is a number." + $CrLf
        txt += " - Excluded fontname list that generates symbols, strange" + $CrLf
        txt += "    or confusing chars. List based on fonts found on my PC" + $CrLf
        txt += "    with Vista SP1 and Office 2000 and must be maintained" + $CrLf
        txt += "    by user." + $CrLf
        txt += " - Background color changes lightly on each generation." + $CrLf
        txt += " - A filter for 0's, O's and I's can be selected." + $CrLf
        txt += " - Word length can be from 3 to 12 characters." + $CrLf
        txt += " - Image created can be saved on disk as BMP file with" + $CrLf
        txt += "    adequate length in same program folder. File name is" + $CrLf
        txt += "    the same verification word." + $CrLf + $CrLf
        txt += "Program placed in the Public Domain by author." + $CrLf
       txt += "Use at your own risk."
    
       MsgBox txt, %MB_ICONINFORMATION OR %MB_OK OR %MB_SYSTEMMODAL, $TITLE
    End Sub
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    'eof
    Attached Files
    Last edited by Jordi Vallès; 12 Dec 2008, 04:11 AM.
Working...
X