Hi all,

following is a sample on how to create matrix lcd display simulations with VB that look like my signature line using a third party library. You need to download the library from here http://www.inside.net/matrixlcd/MatrixLCD.zip. This zip file also contains this sample.

The basic steps involved are:
- Initialize the matrix LCD library
- Setup the parameters for the given display (any number of displays is possible on a form)
- set the text / optionally also make it scroll.

Create a new project with a form and two buttons on that form, do not change the default names of the buttons.

Add a module (for instance modMatrixLCD.bas) to the project and paste this code:

VB Code:
  1. Public Type POINTAPI
  2.   x As Long
  3.   y As Long
  4. End Type
  5.  
  6. Const WS_CUSTOM = 0
  7. Const WS_NORMAL = 1
  8. Const WS_HEAVY = 2
  9. Const WS_HIGH = 3
  10. Const WS_WIDE = 4
  11. Const WS_TINY = 5
  12. Const WS_HUGE = 6
  13.  
  14. Const CS_CUSTOM = 0
  15. Const CS_GREEN_LCD = 1
  16. Const CS_ORANGE_LCD = 2
  17. Const CS_BLUE_LCD = 3
  18. Const CS_RED_LED = 4
  19. Const CS_ORANGE_LED = 5
  20. Const CS_YELLOW_LED = 6
  21. Const CS_GREEN_LED = 7
  22. Const CS_WHITE_LED = 8
  23. Const CS_BLUE_LED = 9
  24.  
  25. Const FT_6x9 = 0
  26. Const FT_5x7 = 1
  27.  
  28. Public Type MatrixLCDSettings
  29.   lWeightScheme As Long     'WS_ consts
  30.   lColorScheme As Long      'CS_ consts
  31.   lFontSize As Long         'FT_ consts
  32.  
  33.   lDotX As Long             'x size for custom weight scheme
  34.   lDotY As Long             'y size for custom weight scheme
  35.   lXDots As Long            'how many x dots
  36.   lYDots As Long            'how many y dots
  37.   lDotSpacing As Long       'spacing between dots
  38.   lDot1Color As Long        'RGB value for active dot color
  39.   lDot0Color As Long        'RGB value for inactive dot
  40.   lBackColor As Long        'RGB value for background color
  41.   lElementSpacingX As Long  'Horiz spacing between elements
  42.   lElementSpacingY As Long  'Vertical spacing between elements
  43.   lElementsX As Long        'X dimensions of display (how many elements)
  44.   lElementsY As Long        'Y dimentions of display (how many lines)
  45.   sText As String * 1024    'text to display
  46.   Scrolling As Long         '> 0 indicates number of milliseconds for scroll timer
  47.  
  48.   'output
  49.   ClientPixelsX As Long        'the calculated X size for the control client area
  50.   ClientPixelsY As Long        'the calculated Y size for the control client area
  51.  
  52. End Type
  53.  
  54. Declare Function InitializeMatrixLCD Lib "MatrixCtrl.dll" Alias "INITIALIZEMATRIXLCD" (hWnd As Long, sSerial As String) As Long
  55. Declare Function SetupMatrixWindow Lib "MatrixCtrl.dll" Alias "SETUPMATRIXWINDOW" (hWnd As Long, udtMatSet As Long) As Long
  56. Declare Function CreateMatrixWindow Lib "MatrixCtrl.dll" Alias "CREATEMATRIXWINDOW" (hWnd As Long, CtrlID As Long) As Long
  57. Declare Sub MoveMatrixWindow Lib "MatrixCtrl.dll" Alias "MOVEMATRIXWINDOW" (hWnd As Long, pt As POINTAPI)
  58. Declare Sub MatrixPrint Lib "MatrixCtrl.dll" Alias "MATRIXPRINT" (hWnd As Long, ByVal sText As String)
  59. Declare Sub DestroyMatrixWindow Lib "MatrixCtrl.dll" Alias "DESTROYMATRIXWINDOW" (hWnd As Long)
  60. Declare Sub ToggleDisplayScrolling Lib "MatrixCtrl.dll" Alias "TOGGLEDISPLAYSCROLLING" (hWnd As Long, lInterval As Long)
  61.  
  62. 'this only pertains to this sample:
  63. Global hWndCtrl As Long

Open the code section for form1 and paste this code:

VB Code:
  1. Private Sub Command1_Click()
  2.   ToggleDisplayScrolling hWndCtrl, 150
  3. End Sub
  4.  
  5. Private Sub Command2_Click()
  6. Dim pt As POINTAPI
  7. Dim x As Long
  8. Dim y As Long
  9. Dim udtMS As MatrixLCDSettings
  10. Dim pUDT As Long
  11. Dim sText As String
  12.  
  13.   If hWndCtrl > 0 Then
  14.     DestroyMatrixWindow hWndCtrl
  15.   End If
  16.  
  17.   hWndCtrl = CreateMatrixWindow(Form1.hWnd, 505)
  18.  
  19.   udtMS.lWeightScheme = WS_NORMAL
  20.   udtMS.lColorScheme = CS_ORANGE_LCD
  21.   udtMS.lFontSize = FT_6x9
  22.  
  23.   udtMS.lElementsX = 35
  24.   udtMS.lElementsY =  4
  25.  
  26.   pUDT = SetupMatrixWindow(hWndCtrl, VarPtr(udtMS))
  27.  
  28.   pt.x = 0
  29.   pt.y = 30
  30.  
  31.   MoveMatrixWindow hWndCtrl, pt
  32.  
  33.   MatrixPrint hWndCtrl, "VBFORUMS.COM rocks!"
  34.    
  35. End Sub
  36.  
  37. Private Sub Form_Load()
  38.  
  39.   Call InitializeMatrixLCD(Form1.hWnd, "1234-DEMO")
  40.    
  41. End Sub

Discussion on what is done where:
1. When the form is loaded, matrixLCD needs to be initialized with the parent window handle and the license key by calling the InitializeMatrixLCD API. Check the website http://www.inside.net/matrixlcd for information on how to obtain a valid license code.

2. The Command2 button is then used to start the matrix display: first, any existing matrix window is destroyed using DestroyMatrixWindow. Then, a new one is created using the CreateMatrixWindow function with the parent window handle and the control ID which you choose, it should be unique on that form. Then, some standard settings are set up for that instance of the control and applied using the SetupMatrixWindow API. This function returns a pointer to the UDT containing for instance the by then automatically calculated size in X and Y in pixels.
Finally, we want to position and display the text: Simply assign a valid X and Y coordinate to the POINT type and use the MoveMatrixWindow API accordingly. Then to print text use the MatrixPrint API giving the text ByVal (!) and the matrix window handle as parameters.

All done!

3. Finally, if you wish to scroll the text automatically, simply use the ToggleDisplayScrolling API which lets you specify which matrix window to scroll and the interval in milliseconds between each update.

Enjoy!