if your intrested see below code that might help casuse it does something
similar
it runs on WM5 and on WM6.
code begins
'program to test tray and eventualy run
'scanwedge using forms
'Common Constants
'For The Registry
' Registry root keys. Everything else is based on these
Const HKEY_CLASSES_ROOT = &H0
Const HKEY_CURRENT_USER = &H1
Const HKEY_LOCAL_MACHINE = &H2
Const HKEY_USERS = &H3
Const HKEY_PERFORMANCE_DATA = &H4
Const HKEY_CURRENT_CONFIG = &H5
Const HKEY_DYN_DATA = &H6
'Registry types supported by this object
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_DWORD_LITTLE_ENDIAN = 4
Const REG_DWORD_BIG_ENDIAN = 5
Const REG_LINK = 6
Const REG_MULTI_SZ = 7
'Constants for conversion to keyboard for
'NSBasic.win32.API sendkey method
Const characters_in =
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz...@3#4$5%6^7&8*9(0)+-./"
Const characters_out =
"sAsBsCsDsEsFsGsHsIsJsKsLsMsNsOsPsQsRsSsTsUsVsWsXsYsZ1s2s3s4s5s6s7s8s9s0skmno"
Const characters_shift =
"AnBnCnDnEnFnGnHnInJnKnLnMnNnOnPnQnRnSnTnUnVnWnXnYnZnn1n2n3n4n5n6n7n8n9n0nnnn"
Dim i 'Universal counter temporary varible etc
Dim lWnd 'local window handle
Dim firststart 'set to allow back from form2 to form1
Dim Scanner, Scanner_Settings, Scanner_EOL, Scan_Terminator 'Read from
registry port number and parameters for scanner
Dim Scanner_initialise 'flag to indicate dump initial data
Dim Com_source 'Tracks number of Coms Events and which port
' ******** Create the Tray object
'Used to hide show icon in system tray
AddObject "NSBasic.win32.Tray", "Tray"
' ******** Create the API object
'Used to hide show window and bring to foregroumd etc
AddObject"NSBasic.win32.API","API"
' ******** Create the registry object
'Used to manipulate registry
AddObject "NSBasic.win32.Registry", "Registry"
'used for serial comms to scanner
AddObject "comm","commscanner",0,0,0,0
'get handle for program window used in hiding and making visible
'this program
lWnd = API.ForegroundWindow
Com_source = 1 ' initialises Coms Events
'Default Scanner port
Scanner = 1
Scanner_Settings = "9600,N,8,1"
Scanner_EOL = 13
Scan_Terminator = 13
Scanner_initialise = True
' ******** Create HKEY_CURRENT_USER\Software\Aidan_Curtis\acscanwedge path
Registry.Key = HKEY_CURRENT_USER
Registry.Path = "Software\Aidan_Curtis\acwedge8"
Registry.CreatePath
'*******have we an empty key?
i = 0
On Error resume next
While Err.number = 0
i = i + 1
Registry.GetValueName( i )
WEnd
On Error Goto 0
'If not then get the values
If i > 1 Then
'************Get Current Values of connection****
Registry.Name = "Scanner_Port" ' Set Scanner_Port
Registry.ValueType = REG_SZ ' Setting a string
Scanner = Registry.Value 'Get value
Registry.Name = "Scanner_Settings" ' Set Scanner coms Settings
Registry.ValueType = REG_SZ ' Setting a string
Scanner_Settings = Registry.Value 'Get value
Registry.Name = "Scanner_EOL" ' Set Scanner End Of Line
Registry.ValueType = REG_SZ ' Setting a string
Scanner_EOL = Registry.Value 'Get value
Registry.Name = "Scan_Terminator" ' Set Scanner output terminator
Registry.ValueType = REG_SZ ' Setting a string
Scan_Terminator = Registry.Value 'Get value
Else
'************set default Values of connection****
Registry.Name = "Scanner_Port" ' Set Scanner_Port
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner 'Set value
Registry.Name = "Scanner_Settings" ' Set Scanner coms Settings
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner_Settings 'Set value
Registry.Name = "Scanner_EOL" ' Set Scanner End Of Line
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner_EOL 'Set value
Registry.Name = "Scan_Terminator" ' Set Scanner output terminator
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scan_Terminator 'Set value
End If
' Initialize the Scanner Coms port:
commscanner.commPort = Scanner
commscanner.Settings = Scanner_Settings
commscanner.Rthreshold = 1 'event on every character in
commscanner.InputMode = 0 'text mode
commscanner.handshaking=1 '0=none, 1=XON/XOFF, 2=HW
commscanner.RTSEnable = True
commscanner.DTREnable = True
commscanner.inputLen = 1
' Open the Scanner port to start communications:
commscanner.PortOpen = True
firststart = 1 'first time load of form1
cpath= Mid(CurrentPath,1,(InStrRev(CurrentPath,"\")))
'-------------------------------------------------------------------
'Start of the subs functions etc
'Deal with click of trayicon by showing application window
Sub Tray_Click( image )
API.showWindow lWnd, 5 'Show
API.ForegroundWindow = lWnd
End Sub
'load initial screen and tray object
' then minimize to the tray
Sub Form1_Load
If firststart = 1 Then
Tray.AddImage (cpath &"\tray.bmp") 'set img
Tray.Image = 1 'load tray
API.showWindow lWnd, 0 'Hide application
End If
End Sub
' Click hide button form 1
Sub Form1_Button1_Click
API.showWindow lWnd, 0 'Hide
End Sub
' Click Exit button form 1
Sub Form1_Button2_Click
' Close ports to Stop communications:
commscanner.PortOpen = False
Tray.Image = 0 'remove tray icon
Bye
End Sub
' Click Settings button form 1
' to go to settings page form 2
Sub Form1_Button3_Click
commscanner.PortOpen = False
Form1_Hide
Form2_Show
End Sub
' Click Back button form 2
' to go to main page form 1
Sub form2_Button1_Click
firststart = 0 'dont hide application automaticaly
Scanner_initialise = True
commscanner.commPort = Scanner
commscanner.Settings = Scanner_Settings
commscanner.PortOpen = True
Form2_Hide
Form1_Show
End Sub
' Click Save button form 2 to save tare and weigh
'commands and barcodes and any other settings to the registry
Sub Form2_Button2_Click
'************Save Current Values Connection****
Scanner = Scaner_Port_Box.Text
Scanner_Settings = Scanner_Port_Settings_Box.Text
Scanner_EOL = Scanner_EOL_Box.Text
Scan_Terminator = Scan_Terminator_Box.Text
Registry.Name = "Scanner_Port" ' Set Scanner_Port
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner 'Set value
Registry.Name = "Scanner_Settings" ' Set Scanner coms Settings
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner_Settings 'Set value
Registry.Name = "Scanner_EOL" ' Set Scanner End Of Line
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scanner_EOL 'Set value
Registry.Name = "Scan_Terminator" ' Set Scanner output terminator
Registry.ValueType = REG_SZ ' Setting a string
Registry.Value = Scan_Terminator 'Set value
End Sub
'When form 2 settings page put
'current values In approapiate boxes
Sub Form2_Load
Scaner_Port_Box.Text = Scanner
Scanner_Port_Settings_Box.Text = Scanner_Settings
Scanner_EOL_Box.Text = Scanner_EOL
Scan_Terminator_Box.Text = Scan_Terminator
End Sub
Function Asciitokey (Ascii)
' to convert ascii to sendkey keycode find position of character
'in constant characters_in then find the equivalent positioned
'character In characters_out .
'If this is "s" then you need to look in characters_shift the shifted
'keys.
' to put the keyboard to a shifted state put a Chr (&H10) in front of
'character again after it to return the keyboard to its normal state.
' the select case takes care of some exceptions.
Dim Pos
Dim St
Pos = 0
St = ""
Asciitokey = ""
Select Case Ascii
Case Chr(&H0) 'Drop Nulls
St = ""
Case Chr(&H09) 'HT is Tab
St = Chr(&H09)
Case Chr(&H0D) 'cr's are enters
St = Chr(&H0D)
Case Chr(&H0a) 'drop line feeds
St = ""
Case Chr(&H20) 'Space is space
St = Chr(&H20)
Case Else
Pos = InStr (characters_in, Ascii)
If Pos = 0 Then
'MsgBox(Asc(Ascii))
MsgBox ("Sorry Character (" & Ascii & ") not convertable")
St = ""
Else
St = Mid (characters_out, Pos, 1)
If St = "s" Then
St = Chr(&H10) + Mid (characters_shift, Pos, 1)+ Chr(&H10)
End If
End If
End Select
Asciitokey = St
End Function
'event setup to occour when data is recieved from scanner
Private Sub commscanner_OnComm()
Select Case commscanner.CommEvent
Case 2 ' character In
Com_source = Com_source + 1
If Com_source = 1 Then
Incoming_coms
End If
Case Else
'MsgBox "Other CommEvent Received:" & commscanner.commEvent
End Select
End Sub
'Deal With comms from the 2 com ports untill the chain of interupt events
'is empty
Private Sub Incoming_coms
Dim InString 'Incoming data character
Dim Key_Press 'key to send
Dim Inconvert 'Counter
Dim Inlen 'lenght of incomming data
Dim Scanner_endstr 'Character that is the Scanner Eol
Dim Tmp
Dim Tmpcntr
Dim Bfrlen ' Number of chars left in the buffer
Scanner_endstr = Chr(Scanner_EOL)
'while there are events in the queue
While Com_source > 0
Sleep (100)
Instring =""
Bfrlen = commscanner.inBufferCount
While Bfrlen > 0
Tmp = commscanner.Input
InString = InString + Tmp 'read char
If Tmp = Scanner_endstr Then
Bfrlen = 0
Else
Bfrlen = commscanner.inBufferCount
End If
WEnd
'This causes the Initial stuff in the buffer to be droped
If Scanner_initialise = False Then
Inlen = Len(Instring)
If Inlen > 1 Then ' ignore strings with only 1 character those funny lfs
Inconvert = 1
While Inconvert <= Inlen
Tmp = Mid(InString,Inconvert,1)
If Tmp = Scanner_endstr Then
Tmp = Chr(Scan_Terminator)
Inconvert = Inlen
End If
'convert char to key sequence
Key_Press = Asciitokey (Tmp)
If Key_Press <> "" Then
API.SendKeys Key_Press ,1
Sleep (1)
End If
Inconvert = Inconvert + 1
WEnd
End If
End If
Scanner_initialise = False
'remove com event from queue
Com_source = Com_source - 1
WEnd
End Sub
'*** Begin Generated Code ***
Dim AppCompanyName: AppCompanyName = "Aidan_Curtis"
Dim AppMajor: AppMajor = "8"
Dim AppMinor: AppMinor = "1"
AppTitle = "acwedge"
Form1_Show 'Default Form
Dim Form1_Temp
Sub Form1_Show
On Error Resume Next
UpdateScreen
If IsEmpty(Form1_Temp) Then
AddObject "Frame", "Form1_Form", 0, 0, Output.Width, Output.Height
Form1_Form.Visible = False
Form1_Form.BackColor = 12632256
AddObject "PictureBox", "Form1", 0, 0, 0, 0, Form1_Form
Form1.BorderStyle = 0
Form1.Move 0, 0, Form1_Form.Width * 15, Form1_Form.Height * 15
Set Form1_Temp = Form1
Form1_Form.Caption = "Form1"
AddObject "CommandButton", "Form1_Button1", 60, 68, 108, 21, Form1_Form
Form1_Button1.Caption = "Hide"
Form1_Button1.FontSize = 8.25
Form1_Button1.BackColor = 12632256
'--------
AddObject "CommandButton", "Form1_Button2", 60, 128, 108, 21, Form1_Form
Form1_Button2.Caption = "Exit"
Form1_Button2.FontSize = 8.25
Form1_Button2.BackColor = 12632256
'--------
AddObject "CommandButton", "Form1_Button3", 60, 180, 108, 21, Form1_Form
Form1_Button3.Caption = "Settings"
Form1_Button3.FontSize = 8.25
Form1_Button3.BackColor = 12632256
'--------
End If
On Error Goto 0
Form1_Form.Visible = True
callIfExists("Form1_Load")
End Sub 'Form1_Show
Sub Form1_Hide
If IsEmpty(Form1_Temp) Then
Err.Raise 44000, , "Form not loaded"
Exit Sub
End If
Form1_Form.Visible = False
callIfExists("Form1_Unload")
End Sub 'Form1_Hide
Dim Form2_Temp
Sub Form2_Show
On Error Resume Next
UpdateScreen
If IsEmpty(Form2_Temp) Then
AddObject "Frame", "Form2_Form", 0, 0, Output.Width, Output.Height
Form2_Form.Visible = False
Form2_Form.BackColor = 12632256
AddObject "PictureBox", "Form2", 0, 0, 0, 0, Form2_Form
Form2.BorderStyle = 0
Form2.Move 0, 0, Form2_Form.Width * 15, Form2_Form.Height * 15
Set Form2_Temp = Form2
Form2_Form.Caption = "Form2"
AddObject "CommandButton", "form2_Button1", 4, 232, 108, 21, Form2_Form
form2_Button1.Caption = "Back"
form2_Button1.FontSize = 8.25
form2_Button1.BackColor = 12632256
'--------
AddObject "CommandButton", "Form2_Button2", 128, 232, 108, 21, Form2_Form
Form2_Button2.Caption = "Save"
Form2_Button2.FontSize = 8.25
Form2_Button2.BackColor = 12632256
'--------
AddObject "Label", "Label3", 16, 16, 76, 20, Form2_Form
Label3.BackColor = 12632256
Label3.Caption = "Scanner Port"
Label3.FontSize = 8.25
'--------
AddObject "TextBox", "Scaner_Port_Box", 108, 16, 69, 21, Form2_Form
Scaner_Port_Box.BackColor = 16777215
Scaner_Port_Box.FontSize = 8.25
Scaner_Port_Box.NumbersOnly = True
Scaner_Port_Box.Text = "1"
'--------
AddObject "Label", "Label4", 16, 48, 76, 28, Form2_Form
Label4.BackColor = 12632256
Label4.Caption = "Scanner Port Settings"
Label4.FontSize = 8.25
'--------
AddObject "TextBox", "Scanner_Port_Settings_Box", 108, 48, 69, 21,
Form2_Form
Scanner_Port_Settings_Box.BackColor = 16777215
Scanner_Port_Settings_Box.FontSize = 8.25
Scanner_Port_Settings_Box.Text = "9600,N,8,1"
'--------
AddObject "Label", "Label8", 16, 92, 76, 32, Form2_Form
Label8.BackColor = 12632256
Label8.Caption = "Scanner EOL Character"
Label8.FontSize = 8.25
'--------
AddObject "TextBox", "Scanner_EOL_Box", 108, 92, 69, 21, Form2_Form
Scanner_EOL_Box.BackColor = 16777215
Scanner_EOL_Box.FontSize = 8.25
Scanner_EOL_Box.NumbersOnly = True
Scanner_EOL_Box.Text = "13"
'--------
AddObject "Label", "Label11", 16, 136, 64, 32, Form2_Form
Label11.BackColor = 12632256
Label11.Caption = "Scan Terminator"
Label11.FontSize = 8.25
'--------
AddObject "TextBox", "Scan_Terminator_Box", 108, 136, 69, 21, Form2_Form
Scan_Terminator_Box.BackColor = 16777215
Scan_Terminator_Box.FontSize = 8.25
Scan_Terminator_Box.NumbersOnly = True
Scan_Terminator_Box.Text = "13"
'--------
End If
On Error Goto 0
Form2_Form.Visible = True
callIfExists("Form2_Load")
End Sub 'Form2_Show
Sub Form2_Hide
If IsEmpty(Form2_Temp) Then
Err.Raise 44000, , "Form not loaded"
Exit Sub
End If
Form2_Form.Visible = False
callIfExists("Form2_Unload")
End Sub 'Form2_Hide
Sub CallIfExists(theSub)
Dim s
If ScriptEngineMajorVersion < 5 Then
Execute("On Error Resume Next:"&theSub) 'attempt to execute it
Else
On Error Resume Next
Set s = GetRef(theSub)
If err.Number <> 0 Then Exit Sub 'it does not exist
On Error GoTo 0
Execute (theSub) 'execute it
End If
End Sub
'*** End Generated Code ***
--- In [email protected], "phlipsmsu" <phill...@...> wrote:
>
> Has anyone had success with using the Tray object on a WM5 device? Is it
> even supported?
>
> I would like to load an image in the tray so that when it's clicked on, it
> shows/maximizes the forms again (after using the little X to minimize).
> MyApp is declared as a global and I know that the FindWindow works (have used
> it before). The problem is the imageIndex = 0 after adding the image. The
> image is at the location specified.
>
> Thanks in advance!
>
> In Form1_Load
> AddObject "NSBasic.win32.Tray", "MyTray"
> imageIndex = MyTray.AddImage("\FIDO_1.0\Forms.bmp")
> MyTray.Image = imageIndex
>
> Sub MyTray_Click
> Dim wnd
> wnd=API.FindWindow(MyApp)
>
> If wnd > 0 Then
> API.ShowWindow wnd,1
> End If
> End Sub
>
> In Output_Close
> MyTray.RemoveImage(MyTray.Image)
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nsb-ce" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nsb-ce?hl=en
-~----------~----~----~----~------~----~------~--~---