Velmex    |    BiSlide    |    XSlide
Image Fade Right
 
VXM Driver Documentation - PowerBasic - Examples
 
Image - VXM Image - Example

All functions assume you followed directions in the "How To Add To Your Project"

Examples

Code to create dialog and controls

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Declares
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
#COMPILE EXE
#INCLUDE "WIN32API.INC"
#INCLUDE "VXMDRIVER.INC"
'----------------------------------------------------------------------
GLOBAL hDlg AS LONG
%CmdMoveMotor = %WM_USER + 1
%CmdMoveMotorWait = %WM_USER + 2
%TxtMotorPosition = %WM_USER + 3
'----------------------------------------------------------------------

DECLARE CALLBACK FUNCTION DlgProc() AS LONG
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Program entrance
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
FUNCTION WINMAIN (BYVAL hInst AS LONG, BYVAL hPrevInstance AS LONG, _
     lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG
     LOCAL hCtl AS LONG

     DIALOG NEW 0, "VXM Driver Examples", , , 187, 53, _
     %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN OR %WS_CAPTION OR _
     %WS_SYSMENU OR %WS_THICKFRAME OR %WS_MINIMIZEBOX OR _
     %WS_MAXIMIZEBOX, _
     %WS_EX_APPWINDOW OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE TO hDlg

     'For icon from resource, instead use something like, LoadIcon(hInst, "APPICON")
     DIALOG SEND hDlg, %WM_SETICON, %ICON_SMALL, LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
     DIALOG SEND hDlg, %WM_SETICON, %ICON_BIG, LoadIcon(%NULL, BYVAL %IDI_APPLICATION)

     CONTROL ADD BUTTON, hDlg, %CmdMoveMotor, "Move Motor", 5, 5, 50, 20,%BS_MULTILINE
     CONTROL ADD BUTTON, hDlg, %CmdMoveMotorWait, "Move Motor and Wait for Program Finish", 60, 5, 125, 20, %BS_MULTILINE
     CONTROL ADD LABEL, hDlg, -1, "Motor Position", 5, 30, 175, 10
     CONTROL ADD TEXTBOX, hDlg, %TxtMotorPosition, "", 5, 40, 175, 10
     CONTROL DISABLE hDlg, %TxtMotorPosition

     LoadDriver "VxmDriver.dll"

     DIALOG SHOW MODAL hDlg, CALL DlgProc
'     DIALOG SHOW MODeLess hDlg, CALL DlgProc
END FUNCTION

Code for Dialog Callbacks (Windows events)

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Main Dialog procedure
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
CALLBACK FUNCTION DlgProc() AS LONG
     DIM hWnd AS LONG
     DIM ReportToWindow AS LONG
     SELECT CASE CBMSG
           CASE %WM_CREATE
                    'First message - a good place to initiate things, declare variables,
                    'create controls and read/set settings from a file, etc.
                    '-------------------------------------------------------------------
           CASE %WM_COMMAND
                    'Messages from controls and menu items are handled here.
                    '-------------------------------------------------------
                    SELECT CASE CBCTL

Minimal Code WITHOUT Wait

                                                                                                    

                         CASE %CmdMoveMotor
                               hWnd = GetDesktopWindow()
                               DriverTerminalShowState %True, hWnd
                               PortOpen 8, 9600
                               PortSendCommands "F,C,I1M400,I1M-400,R"
                               PortClose
                               DriverTerminalShowState 0, hWnd

                                                                                                    



Minimal Code WITH Wait

                                                                                                    

                         CASE %CmdMoveMotorWait
                               hWnd = GetDesktopWindow()
                               DriverTerminalShowState 1, hWnd
                               PortOpen 8, 9600
                               PortSendCommands "F,C,I1M400,I1M-400,R"
'*** Use below line if just wanting to wait for VXM program to end
'                               PortWaitForChar "^", 0
'*** Use below line if wanting to wait for VXM program to end, and report back motor positions while waiting
                               PortWaitForCharWithMotorPosition("^", 1, GetDlgItem(hDlg, %TxtMotorPosition), 0)
                               PortClose
                               DriverTerminalShowState 0, hWnd
                                   CASE %TxtMotorPosition
                                        SELECT CASE CBCTLMSG
                                             CASE %EN_CHANGE
                                                  InvalidateRect GetDlgItem(hDlg, %TxtMotorPosition), BYVAL %NULL, 0
                                                  UpdateWindow GetDlgItem(hDlg, %TxtMotorPosition)
                                        END SELECT

                                                                                                    

                    END SELECT
                    EXIT FUNCTION                          'Exit so function not called twice
                CASE %WM_DESTROY
                    'is sent when program ends - a good place to delete created
                    'objects and store settings in file for next run, etc.
                    '-------------------------------------------------------------
                    ReleaseDriver
          END SELECT
END FUNCTION

Image Fade Bottom Image Fade Right Bottom