Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all 1492 articles
Browse latest View live

Win 10 Registry issue

$
0
0
Have struck a snag getting a vb6 prog that I've been using with Win XP to run OK in Win 10.

The problem is the Registry Class. It seems it will write a value to HKEY_CURRENT_USER but not to HKEY_LOCAL_MACHINE.
I presume this is correct (Win 10 limitation) and not some local condition I've inadvertantly got ?

I can't get around it a Reg file as the value I want to write is App.Path & App.EXEName which isn't known in advance.

The bigger picture is to add an item to the right click context menu to run app.exename.

Does a (simple) solution exist? Googling has shown this could become a bit too complex for me.
Thanks

LDB Viewer

$
0
0
I need to add a LDB/LACCDB viewer on a client site, in order to check which are the users connected to an Access DB.
I have implemented such as follow (this code was made 10 years ago)

You call it like this and gives the result in a string (No = Not connected, but information kept in the ldb file. Yes = connected)
In the real project, I manage the string to send a message to the final users to close the application

Code:

? Global_ReadAccessLockFile("D:\VB6\Test.ldb")
THIERRY(69.69.69.69):Admin ->NO
THIERRY(69.69.69.69):Admin ->YES

Code:

' #VBIDEUtils#************************************************************
' * Author          :
' * Web Site        :
' * E-Mail          :
' * Date            : 10/11/2008
' * Module Name      : LDB_Module
' * Module Filename  : ldb.bas
' * Purpose          :
' * Purpose          :
' **********************************************************************
' * Comments        :
' *
' *
' * Example          :
' *
' * See Also        :
' *
' * History          :
' *
' *
' **********************************************************************

Option Explicit

Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, _
  ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long

Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
  ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, _
  ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, _
  ByVal hTemplateFile As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function LockFile Lib "kernel32" (ByVal hFile As Long, ByVal dwFileOffsetLow As Long, _
  ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToLockLow As Long, _
  ByVal nNumberOfBytesToLockHigh As Long) As Long

Private Declare Function UnlockFile Lib "kernel32" (ByVal hFile As Long, ByVal dwFileOffsetLow As Long, _
  ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToUnlockLow As Long, _
  ByVal nNumberOfBytesToUnlockHigh As Long) As Long

Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const OPEN_EXISTING = 3
Private Const START_LOCK = &H10000001      ' *** Start of locks

Private Type HOSTENT
  hName                As Long
  hAliases            As Long
  hAddrType            As Integer
  hLength              As Integer
  hAddrList            As Long
End Type

Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal sHostName As String) As Long
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, ByVal Source As Any, ByVal Length As Long)

Public Function Global_ReadAccessLockFile(Optional sFile As String = vbNullString) As String
  ' #VBIDEUtils#***********************************************************
  ' * Author          :
  ' * Web Site        :
  ' * E-Mail          :
  ' * Date            : 10/11/2008
  ' * Module Name      : LDB_Module
  ' * Module Filename  : ldb.bas
  ' * Procedure Name  : Global_ReadAccessLockFile
  ' * Purpose          :
  ' * Parameters      :
  ' *                    Optional sFile As String = vbNullString
  ' * Purpose          :
  ' **********************************************************************
  ' * Comments        :
  ' *
  ' *
  ' * Example          :
  ' *
  ' * See Also        :
  ' *
  ' * History          :
  ' *
  ' *
  ' **********************************************************************

  ' #VBIDEUtilsERROR#
  On Error GoTo ERROR_HANDLER

  Dim hFile            As Long
  Dim nReturn          As Long
  Dim nBytesRead      As Long
  Dim sComputer        As String
  Dim sUser            As String
  Dim nUsers          As Long

  Dim sUsersLock      As String

  sUsersLock = vbNullString

  If LenB(sFile) = 0 Then GoTo EXIT_HANDLER

  ' *** Open file in protected mode
  hFile = CreateFile(ByVal sFile, _
      ByVal GENERIC_READ Or GENERIC_WRITE, _
      ByVal FILE_SHARE_READ Or FILE_SHARE_WRITE, _
      ByVal 0&, ByVal OPEN_EXISTING, ByVal 0&, ByVal 0&)

  If hFile <> -1 Then
      Do
        nUsers = nUsers + 1

        ' *** Retrieve the computer name
        sComputer = Space(32)
        nReturn = ReadFile(hFile, ByVal sComputer, 32, nBytesRead, ByVal 0&)
        sComputer = Left$(sComputer, InStr(sComputer, Chr(0)) - 1)
        If (nReturn = 0) Or (nBytesRead = 0) Then Exit Do

        ' *** Retrieve the user name
        sUser = Space(32)
        nReturn = ReadFile(hFile, ByVal sUser, 32, nBytesRead, ByVal 0&)
        sUser = Left$(sUser, InStr(sUser, Chr(0)) - 1)
        If nReturn = 0 Or nBytesRead = 0 Then Exit Do

        ' *** Check if the user is still connected by lock the file, and log with computer name, IP adress and User name
        If LockFile(hFile, START_LOCK + nUsers - 1, 0, 1, 0) = 0 Then
            ' *** An error occured, so it is still locked by the user
            sUsersLock = sUsersLock & sComputer & "(" & Global_IPFromHostName(sComputer) & "):" & sUser & " ->YES" & vbCrLf
        Else
            ' *** Nothing special, the user isn't locking
            sUsersLock = sUsersLock & sComputer & "(" & Global_IPFromHostName(sComputer) & "):" & sUser & " ->NO" & vbCrLf
            Call UnlockFile(hFile, START_LOCK + nUsers - 1, 0, 1, 1)
        End If
      Loop

      CloseHandle hFile
  End If

EXIT_HANDLER:
  On Error Resume Next

  Global_ReadAccessLockFile = sUsersLock

  Exit Function

  ' #VBIDEUtilsERROR#
ERROR_HANDLER:
  Resume EXIT_HANDLER
  Resume

End Function

Public Function Global_IPFromHostName(sHostName As String) As String
  ' #VBIDEUtils#************************************************************
  ' * Author          :
  ' * Web Site        :
  ' * E-Mail          :
  ' * Date            : 10/11/2008
  ' * Module Name      : LDB_Module
  ' * Module Filename  : ldb.bas
  ' * Procedure Name  : Global_IPFromHostName
  ' * Purpose          :
  ' * Parameters      :
  ' *                    sHostName As String
  ' * Purpose          :
  ' **********************************************************************
  ' * Comments        :
  ' *
  ' *
  ' * Example          :
  ' *
  ' * See Also        :
  ' *
  ' * History          :
  ' *
  ' *
  ' **********************************************************************
  ' #VBIDEUtilsERROR#
  On Error GoTo ERROR_HANDLER

  Dim nHostAdress      As Long
  Dim oHost            As HOSTENT
  Dim nHostIP          As Long
  Dim byIPAdress()    As Byte
  Dim nI              As Long
  Dim sIPAdress        As String

  nHostAdress = gethostbyname(sHostName)

  If nHostAdress = 0 Then GoTo EXIT_HANDLER

  CopyMemory oHost, nHostAdress, LenB(oHost)
  CopyMemory nHostIP, oHost.hAddrList, 4

  ReDim byIPAdress(1 To oHost.hLength)
  CopyMemory byIPAdress(1), nHostIP, oHost.hLength

  For nI = 1 To oHost.hLength
      sIPAdress = sIPAdress & byIPAdress(nI) & "."
  Next
  sIPAdress = Mid$(sIPAdress, 1, Len(sIPAdress) - 1)

EXIT_HANDLER:
  On Error Resume Next

  Global_IPFromHostName = sIPAdress

  Exit Function

  ' #VBIDEUtilsERROR#
ERROR_HANDLER:
  Resume EXIT_HANDLER
  Resume

End Function

[VB6] Exclude file types from Open/Save Dialogs ('all except...'): IShellItemFilter

$
0
0

IShellItemFilter Demo

Normally with an Open/Save dialog, you supply filters of a list of file types you want to display. But what if instead of 'only x', you wanted to filter by 'all except x' or similar, excluding only a specific file type? Or even show all files of a particular type, except those that met some other criteria (like created before a certain date)? It's entirely possible to get this level of control using a backend filter supported on the newer IFileDialog, the .SetFilter method with the IShellItemFilter class.

This is a followup to an earlier project that used a similar principle on the SHBrowseForFolder dialog: [VB6] SHBrowseForFolder - Custom filter for shown items: BFFM_IUNKNOWN/IFolderFilter

You can do this on Open/Save (and the new folder picker too) also, using a different but similar interface: IShellItemFilter.

IFileDialog includes a .SetFilter method, this project shows how to create the class for it. It uses a return so has to be swapped out, so the class itself is small:
Code:

Option Explicit

Implements IShellItemFilter
Private mOld4 As Long

Private Sub Class_Initialize()
Dim pVtable As IShellItemFilter
Set pVtable = Me
mOld4 = SwapVtableEntry(ObjPtr(pVtable), 4, AddressOf IncludeItemVB)

End Sub

Private Sub Class_Terminate()
Dim pVtable As IShellItemFilter
Set pVtable = Me
mOld4 = SwapVtableEntry(ObjPtr(pVtable), 4, mOld4)

End Sub

Private Sub IShellItemFilter_IncludeItem(ByVal psi As IShellItem)
End Sub
Private Sub IShellItemFilter_GetEnumFlagsForItem(ByVal psi As IShellItem, pgrfFlags As SHCONTF)
End Sub

The IncludeItem function is what we're interested in. Each item to be displayed is passed to this first by a pointer to its IShellItem, so you can easily decide to exclude/include it based on any criteria you want. In this demo, we exclude if it matches the filter on the form's textbox, but the options are limitless. Note that unlike normal filters, this cannot be overridden by the user typing in their own filter; items hidden by the IncludeItem function will always be hidden. They can still be selected by manually entering their name†, but will never be shown in the list.
Code:

Public Function IncludeItemVB(ByVal this As IShellItemFilter, ByVal psi As IShellItem) As Long
Dim lpName As Long, sName As String
Dim dwAtr As Long

If (psi Is Nothing) = False Then
    psi.GetAttributes SFGAO_FILESYSTEM Or SFGAO_FOLDER, dwAtr
    If ((dwAtr And SFGAO_FILESYSTEM) = SFGAO_FILESYSTEM) And ((dwAtr And SFGAO_FOLDER) = 0) Then 'is in normal file system, is not a folder
        psi.GetDisplayName SIGDN_PARENTRELATIVEPARSING, lpName
        sName = LPWSTRtoStr(lpName)
'        Debug.Print "IShellItemFilter_IncludeItem?" & sName & "|" & gSpec
        If PathMatchSpecW(StrPtr(sName), StrPtr(gSpec)) Then
            IncludeItemVB = S_FALSE 'should not show
        Else
            IncludeItemVB = S_OK 'should show
        End If
    End If
Else
    Debug.Print "IncludeItemVB.NoItem"
End If
End Function

Think of the other possibilities here... instead of the file name, you could exclude by attribute, or by date, or anything you want.

Also note that this overrides the normal 'include' filters that you're used to using, like if instead of all files *.* you had *.exe, then set the exclude filter to *a*.exe, the dialog would show all .exe files except for ones with an 'a' in their name.

Adding the filter to a normal Open call is simple:
Code:

Dim fod As New FileOpenDialog
Set cSIFilter = New cShellItemFilter 'declared as a Public in the module
Dim psi As IShellItem
Dim tFilt() As COMDLG_FILTERSPEC
ReDim tFilt(0)
tFilt(0).pszName = "All Files"
tFilt(0).pszSpec = "*.*"
With fod
    .SetFileTypes UBound(tFilt) + 1, VarPtr(tFilt(0))
    .SetTitle "Browse away"
    .SetOptions FOS_DONTADDTORECENT
    .SetFilter cSIFilter
    .Show Me.hWnd
    .GetResult psi
    If (psi Is Nothing) = False Then
        Dim lp As Long, sRes As String
        psi.GetDisplayName SIGDN_FILESYSPATH, lp
        Label2.Caption = LPWSTRtoStr(lp)
    End If
End With

And that's all there is to it. You can use the .SetFilter method whether it's an Open dialog or Save dialog.

Requirements
-Windows Vista or newer (the new dialogs weren't available in XP)
-oleexp v4.0 or newer (only for the IDE, not needed for compiled exe)


† - If you wanted to refuse to let the user select an excluded file, even manually, you could also do that without closing the dialog by using an events class, and not allowing the dialog to close on the OnFileOk event. See the original IFileDialog project which implements the event sink.
Attached Files

[VB6] VBZeep: An abandoned SOAP Client written in VB6

$
0
0
VBZeep is completely unrelated to the "Zeep: Python SOAP client" which it predates by many, many years.

VBZeep is basically some "abandonware" - code I was developing over 6 years ago but never got around to completely finishing and certainly never got around to cleaning up. Ideally the numerous ZeepXXX classes within it would have been radically cleaned up and then moved into a separate DLL Project.

Rather than just let it continue to molder away in my backup server I thought I might throw it out here for others to take a look at. After all, though it has many small things that are incomplete it does work after a fashion - at least with some kinds of SOAP services.

If nothing else it might help others understand a little more about SOAP and why most people have completely abandoned it in favor for RESTful and REST-like techniques that don't have all of the horrible issues of SOAP.


The VBZeep Project attached contains Zeep itself (those classes) wrapped up in a "testbed" Project with a user interface. This VBZeep testbed has a settings.dat text file that contains its main window size and position as well as a list of some known web services to test against. That list gets loaded into a ComboBox at the top of the Form.

Sample run:

Name:  sshot1.png
Views: 60
Size:  11.6 KB

Name:  sshot2.png
Views: 50
Size:  8.7 KB


Take a look. Have fun. Cringe at the very rough code, and the gymnastics required of an interpretive SOAP client.

One thing not attempted in VBZeep is generation of SOAP Proxy classes to be compiled into VB6 applications. But as far as I can tell few people ever bothered to do that even using the old unsupported Microsoft SOAP Toolkits anyway.

Almost everything needed to create proxy classes after digesting a WSDL is here though. But note that Zeep doesn't handle all of the kinds of WSDL that exist and doesn't handle any of the advanced kinds of SOAP security and authentication.
Attached Images
  
Attached Files

VB6 - SimpleServer Stress Test

$
0
0
I have been fairly satisfied with the performance of SimpleSock, but even though SimpleServer is being used successfully in a couple of server routines, I have not been able to stress test it. I would like to thank dilettante for providing the test routine for MSWinSck. After modifying the routines to use SimpleSock and SimpleServer, the SimpleServer routine failed the test miserably. It ran fine when tested with the default conditions (5 Clients, 100 Sends, same machine), but when I moved the client to a different machine, it failed at 3 Clients. The mode of failure was an incorrect calculation of the record length, which left the server waiting for the rest of the record. The point at which the failure occurred was not consistent, which made it difficult to troubleshoot. This is the relative debug output from one such failure.
-----------------------------------------------
FD_READ 664 = (socket 3)
InBuff 0
OK Bytes obtained from buffer: 5840 (4 x 1460)
Header:
01 01 00 00 00 00 28 57 (10327)
FD_READ 860 (socket 1)
InBuff 5832
OK Bytes obtained from buffer: 8192
Header:
87 88 89 8A 8B 8C 8D 8E
FD_READ 664 = (socket 3)
InBuff 3689
OK Bytes obtained from buffer: 4495
-----------------------------------------------
Socket 3 received 5,840 bytes. This represents 4 packets of 1,460 bytes each. Socket 1 then received 8,192 bytes. This represents the maximum Winsock buffer size this particular machine can handle. But that buffer already contained 5,832 bytes. This is equal to what socket 3 received less the header bytes.

To understand this situation better, I ran a packet sniffer and captured a different failure.
Code:

socket packet
65460 398 - sending 10327 bytes -  1513-61 = 1452 bytes
65460 399 - 1513-53 = 1460 bytes
65460 401 - 1513-53 = 1460 bytes
65460 402 - 1513-53 = 1460 bytes
65460 404 - 1513-53 = 1460 bytes
65460 405 - 1513-53 = 1460 bytes
65460 407 - 1513-53 = 1460 bytes
65460 408 - 168-53 = 115 bytes    Total = 10327 bytes

65461 416 - sending 10327 bytes -  1513-61 = 1452 bytes
65459 417 - sending 10768 bytes -  1513-61 = 1452 bytes
65459 418 - 1513-53 = 1460 bytes
65459 420 - 1513-53 = 1460 bytes
65459 421 - 1513-53 = 1460 bytes
65459 423 - 1513-53 = 1460 bytes
65459 424 - 1513-53 = 1460 bytes
65459 426 - 1513-53 = 1460 bytes
65459 427 - 609-53 = 556 bytes    Total = 10768 bytes
65461 429 - 1513-53 = 1460 bytes
65461 437 - 1513-53 = 1460 bytes
65461 438 - 1513-53 = 1460 bytes
65461 440 - 1513-53 = 1460 bytes
65461 441 - 1513-53 = 1460 bytes
65461 443 - 1513-53 = 1460 bytes
65461 444 - 168-53 = 115 bytes    Total = 10327 bytes

The first transfer (socket 65460) represents a normal transfer (8 packets totaling 10,327 bytes. On the second transfer, socket 65461 received a single packet, and was then interrupted by a transfer to socket 65459. This is what caused the failure, and is a real world scenario. This is because the sending programs are 3 separate applications operating independently.

SimpleServer originally extracted all the bytes received by a socket, and accumulated and analyzed them in the "DataArrival" routine. Any left over bytes were retained, to be included in the next record. This worked well in SimpleSock because it only supported a single socket. Even though there are independent routines for each socket (defined by Index), the variables defined within each routine appear to be common. The solution was to define those variables (RecLen/Type) as an array, and let the local buffer in the class instance (m_bRecvBuffer) accumulate bytes until the entire record is received. This uses a feature that has always existed in SimpleServer that allows you to extract a restricted number of bytes (maxLen). This is used to extract the header, which I used to define the length of the following record. If you decide that the length will include the header, a routine called PeekData was added that allows you to copy the number of bytes needed, but leave them in place.

J.A. Coutts
Attached Files

.HLP file loader

$
0
0
There's some issues when loading Help files in windows 10.

I upgraded from windows 7 to 10, and maybe this is where this problem lies. But I saw all over the same questions on the internet how to fix it.

You can convert it, with a lot of trouble and in the end you're just more frustrated than when you started.

Or you can download winhlp32.exe and open the help files trough it. The problem is, you have to open the exe first, then search for the help file you want to open.

This is what I have done:
I have placed the winhlp32.exe file in my own "Help Loader" folder.
Then I right clicked on any .hlp file and select the "Opened with..."
I set the program to "Always open" with the Help Loader

Just a simple program (with Option Explicit (pun intended)). The form will never been seen anyway, as just after the help file was loaded, the Loader end.

...and Sam, I still love my chr$(34)...:D

Help Loader.zip

The Readme file will give more info where the winhelp32.exe can be downloaded from one of my domains.

Oh. I forgot: No attachments.

So here it is:

Code:

Option Explicit

Private Sub Form_Load()
     
  Dim BlaV As String, aD$, aKa$, xX, MP$, i
     
  If Right$(App.Path, 1) = "\" Then
      MP$ = App.Path
  Else
      MP$ = App.Path + "\"
  End If
 
  If Len(Command) > 4 Then
      If Command = "" Then
        End
      End If
     
      aD$ = Chr$(34)
     
      If Left$(Command, 1) = aD$ Then
        aKa$ = Mid$(Command, 2, Len(Command) - 2)
      Else
        aKa$ = Command
      End If
  Else
      End
  End If
 
  xX = Shell(MP$ + "winhlp32.exe " + aKa$, vbNormalFocus)
 
  End

End Sub


...and forgot again:

Quote:

Winhelp is here and can be downloaded as is, or as a zip file:

http://thezir.com/winhelp/winhlp32.exe
http://thezir.com/winhelp/winhlp32.zip

Paste the winhelp file into the same folder as the help loader. It will not work otherwise, unless of course, if you change the program accordingly.

Coding will be here:

http://thezir.com/winhelp/Help Loader.zip (This file have a normal space between the words. VBForums does not accept it as an URL)
http://thezir.com/winhelp/Help%20Loader.zip (This file have two words splitted by a chr$(255). VBForums accept it as one URL. Funny? No. Just a fact)

Attached Files

VB^ - SimpleServer

$
0
0
CSocket was originally developed by Oleg Gdalevich as a replacement for MSWinSck. Emiliano Scavuzzo improved upon it with CSocketMaster, and I converted it to support IPv6 with cSocket2. With NewSocket, I attempted to streamline the code. SimpleSock is a complete rewrite designed to further simplify and streamline socket code. SimpleServer is designed to allow a single listening socket to support multiple connections without having to resort to using a control array. Like all socket tools, it must be used properly to be effective.

In theory, SimpleServer could be used for all socket access, but for only a few sockets, SimpleSock is simpler and easier to use. Understanding how SimpleServer works will allow you to make better use of it. There are 8 events or call-backs associated with a socket.
1. CloseSck
2. Connect
3. ConnectionRequest
4. DataArrival
5. EncrDataArrival
6. Error
7. SendComplete
8. SendProgress
In SimpleServer, there is another one called WndProc, but it is not used and only provides access to the other events. With one exception (CloseSck), these routines are not called directly. They simply provide information to the calling program.

The calling program Implements SimpleServer. That means that any procedure declared as Public in SimpleServer will be implemented in the calling program, and that includes the 8 routines noted above. When SimpleServer is first implemented, the individual routines have to be activated. This is accomplished by clicking on each one. As you do so, they will go from plain to bold text. Routines that we want to access from the calling program but we do not want to implement, are declared as Friend instead of Public.

When we add an instance of a class with call-backs, we simply define the procedure "WithEvents" and add a new instance. With Implements, we can't do that. So we have to do the following instead:
Code:

Implements SimpleServer
Private mServer() As New SimpleServer

    Dim lNum As Long
    ReDim mServer(MaxClients)
    For lNum = 0 To MaxClients
        Set mServer(lNum).Callback(lNum) = Me
        mServer(lNum).IPvFlg = 4
    Next
    ReDim RecLen(MaxClients)
    ReDim RecType(MaxClients)

Adding the IPvFlg is not strictly necessary, because SimpleServer defaults to IPv4. But it is a good practice to get into. With SimpleServer, the listening socket is always the first instance.
Code:

mServer(0).Listen(PortListen)
If SimpleServer was to be used to make a connection to another host, it would call "mServer(lIndex).TCPConnect Destination, PortConnect". Once the connection is established, SimpleServer would receive an "FD_CONNECT" and fire off a "Connect" message to the calling program. That would leave the calling program ready to start sending data.

When a client attempts to connect, an "FD_ACCEPT" is received by SimpleServer, and it fires off a "ConnectionRequest" message to the calling program. If acceptable, the calling program sends "mServer(lIndex).Accept(requestID, RemotePort, RemoteHostIP)". If it is not acceptable, it sends "mServer(lIndex).Accept(requestID, 0, "")", and SimpleServer interprets the "0" port as invalid.

Data is received by a socket in packets of approximately 1500 bytes. Of this, a maximum of 1460 bytes is actual data. Winsock assembles those packets into blocks of data that vary with the system. Windows Vista has a block size of 8,192 bytes, and Win 8.1 has a block size of 65,536 bytes. Winsock doesn't necessarily use all that space, it is just a maximum. Whatever criteria the OS uses, when it is ready it will send an "FD_READ" message to SimpleServer. For TCP, SimpleServer will add that data to it's own buffer (m_bRecvBuffer) and remove it from the Winsock buffer. It then fires off a "DataArrival"/"EncrDataArrival" message to the calling program along with the number of bytes just received. For UDP, SimpleServer will leave the data in the Winsock buffer, and notify the calling program of the bytes received.

How the calling program handles this information depends on the program itself. SimpleServer will keep adding data to "m_bRecvBuffer" (TCP) until the calling program gives it instructions. In the sample program I have provided, I have used a header to provide more information about the data being sent. It includes a Record Type and Record Length. The Record Length tells the receiving program how much data to expect. Because the data length does not include the header itself, the header is removed from the buffer using the statements "Call mServer(Index).RecoverData(8)" & "RecHeader = mServer(Index).bInBuffer". The (8) is an optional number telling SimpleServer to only remove 8 bytes. If it was left out, SimpleServer would remove all bytes. If the Record Length includes the header, it can be recovered using the "PeekData" command and left in the buffer.

All the data could be removed and analyzed in the "DataArrival"/"EncrDataArrival" routines, but that would mean separate buffers would be required for each connection, and I don't know how to create an array of byte arrays. Instead, we simply allow the data to accumulate in the "m_bRecvBuffer" in each instance of SimpleServer, and remove the desired amount when it is exceeded.

Sending of data is similar. All the data is added to "m_bSendBuffer" regardless of size. When the calling program issues a TCPSend, it enters a loop. SimpleServer copies from "m_bSendBuffer" a maximum of the block size of the Winsock output buffer and forwards it to the Winsock API. If the API is successful in sending the data, it returns the number of bytes sent and they are removed from "m_bSendBuffer". It remains in the loop until all the bytes are sent. Should the API return an error "WSAEWOULDBLOCK", it means that the API is still busy sending the previous block. A message is sent to "SendProgress" with the total bytes sent and the bytes remaining, and the loop exited. When the Winsock output buffer is once again ready to send data, it sends an "FD_WRITE" message to SimpleServer, and SimpleServer calls TCPSend once again. When all the data has been sent, messages are sent to both "SendProgress" and "SendComplete".

All SimpleServer errors (with the exception of "WSAEWOULDBLOCK") are forwarded to the calling program for action. Normally, in a server application errors are logged, so as to prevent holding up the program itself.

That leaves the "CloseSck" event. There are 2 ways of closing the socket. Should the far end close the socket, Winsock will send an "FD_CLOSE" message to SimpleServer. SimpleServer will forward a message to "CloseSck" and change the socket state to "sckClosing". CloseSck will call "mServer(Index).CloseSocket" which will actually close the socket on the server side and change the socket state to "sckClosed". To close the socket from the server end, users should refrain from calling "CloseSocket" directly. This can cause the socket to remain in the "sckClosing" state and become unusable. Always call "CloseSck" in the calling program. As an added note, always include a routine in the "Form_Unload" event to close all sockets. Failure to do so can cause a port to become unusable.

J.A. Coutts
Attached Files

[VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the fly

$
0
0

One of the features of the Vista and newer Explorer views is the icon size slider; you can do more than just pick between a couple sizes- you can set it to any value in the icon range. Previously to do this in VB was quite a lot of work; you'd have to manually resize each image and rebuild each ImageList since you can't scale up without quality loss... so it's not something that could be rapidly changed without any lag. This project, however, takes advantage of a feature of the new IImageList2 COM interface: it has a .Resize command that can scale down the entire ImageList at once with the speed of Windows API. To avoid quality loss, we load the maximum size images into a primary ImageList, then we dynamically generate the API-made duplicate in the smaller size that the user is looking for, always scaling down instead of up.

Right now this project is focused on standard image file thumbnails; really small images that need to be grey-boxed and standard file icons will be addressed in a future version of this demo.

Here's the key function:
Code:

Private Sub ResizeThumbView(cxNew As Long)
ImageList_Destroy himl
himl = ImageList_Duplicate(himlMax)
HIMAGELIST_QueryInterface himl, IID_IImageList2, pIML
If (pIML Is Nothing) = False Then
    pIML.Resize cxNew, cxNew
End If
himl = ObjPtr(pIML)
bSetIML = True
ListView_SetImageList hLVS, himl, LVSIL_NORMAL
bSetIML = False
ListView1.Refresh
End Sub

While it's certainly possible to forgo the standard HIMAGELIST and entirely use IImageList, I wanted to retain some (hopefully) more familiar territory by using that and the 5.0 VB ListView control. As the API HIMAGELIST_QueryInterface indicates, they're pretty much interchangable anyway, as the ObjPtr returns the same handle as when we made it with ImageList_Create.

Requirements
-Windows Vista or newer
-Common Controls 6.0 Manifest - The demo project has a manifest built into its resource file. Your IDE may have to be manifested to run it from there. If you need to manifest your IDE or a new project, see LaVolpe's Manifest Creator
-oleexp.tlb v4.0 or newer - Only needed in the IDE; not needed once compiled.
-oleexp addon mIID.bas - Included in the oleexp download. Must be added to the demo project the first time you open it.

Scrolling
To make it truly like Explorer, where it sizes while you move the mouse, you can move the code in Slider1_Change over to Slider1_Scroll:
Code:

Private Sub Slider1_Change()
'cxThumb = Slider1.Value
'Label1.Caption = cxThumb & "x" & cxThumb
'ResizeThumbView cxThumb
End Sub

Private Sub Slider1_Scroll()
cxThumb = Slider1.Value
Label1.Caption = cxThumb & "x" & cxThumb
ResizeThumbView cxThumb
End Sub

It works perfectly with the small number of images currently there, but I'm hesitant to trust the stability if there's hundreds or thousands of list items, at least without it being a virtual ListView. I'll take a look at it for future versions; if anyone experiments with it before then let me know! :)
Attached Files

Add a little Pizazz to Your Menus & Toolbar Dropdowns

$
0
0
Here's a project to add Menu Bitmaps and Toolbar Dropdown bitmaps.
I have included a companion project to create menu bitmaps (14x14) from
other graphic file types and icons (24 bit & lower)

Enjoy.


Name:  ScreenShot.JPG
Views: 48
Size:  12.8 KB
Attached Images
 
Attached Files

A small, no fancy checkbox

$
0
0
Someone ask for a simple checkbox with click and value. Nothing professional...
Small and to the point:

Code:

Option Explicit

Const m_def_Value = True
Dim m_Value As Boolean
Event Click()
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Event Change()


Public Property Get Value() As Boolean
  Value = m_Value
End Property

Public Property Let Value(ByVal New_Value As Boolean)
  m_Value = New_Value
  PropertyChanged "Value"
  True_or_False
End Property

Private Sub FalseVal_Click()
 
  RaiseEvent Click
  True_or_False

End Sub

Private Sub TrueVal_Click()
 
  RaiseEvent Click
  True_or_False
 
End Sub

Private Sub UserControl_Initialize()

  UserControl.Width = TrueVal.Width
  UserControl.Height = TrueVal.Height
     
  TrueVal.Visible = False

End Sub

Function True_or_False()

  If TrueVal.Visible = False Then
      TrueVal.Visible = True
      FalseVal.Visible = False
      m_Value = False
  Else
      TrueVal.Visible = False
      FalseVal.Visible = True
      m_Value = True
  End If

End Function

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

  m_Value = PropBag.ReadProperty("Value", m_def_Value)
 
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

  Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
 
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub

Private Sub FalseVal_Change()
  RaiseEvent Change
End Sub

Private Sub TrueVal_Change()
  RaiseEvent Change
End Sub

I have two .gif's, created within excel, Paste it into Irfanview, Auto crop, save as .GiF

The pictures can be any size of your choice. One picture have a mark (TrueVal) and the other just an open block(FalseVal).
Place the images to 0,0 No matter which is above or not.

Others can make the code more useful as I'm not experienced in this kind of coding :)

Splitter;- or Separator lines Control

$
0
0
I get tired of making splitter lines for programs, therefore I decided to make a control.

Very basic as it's not really my field of expertise, but something that I can use horizontal as well as vertical. What I mean is this:

Name:  Seperator.png
Views: 31
Size:  2.3 KB

This is what's on the form:
Name:  Image 045.png
Views: 23
Size:  4.5 KB
Name:  Image 046.png
Views: 23
Size:  4.5 KB

The code is:

Code:


'Default Property Values:
Const m_def_DarkColour = &H0&
Const m_def_LightColour = &HC0C0C0
Const m_def_Horizonthal = -1
'Property Variables:
Dim m_DarkColour As OLE_COLOR
Dim m_LightColour As OLE_COLOR
Dim m_Horizonthal As Boolean

Private Sub UserControl_Resize()
 
  If Horizonthal = True Then
      Line1.X1 = 0
      Line1.X2 = UserControl.Width
      Line1.Y1 = 0
      Line1.Y2 = 0
     
      Line2.X1 = 0
      Line2.X2 = UserControl.Width
      Line2.Y1 = 20
      Line2.Y2 = 20
      UserControl.Height = 40
  ElseIf Horizonthal = False Then
      Line1.X1 = 0
      Line1.X2 = 0
      Line1.Y1 = 0
      Line1.Y2 = UserControl.Height
     
      Line2.X1 = 20
      Line2.X2 = 20
      Line2.Y1 = 0
      Line2.Y2 = UserControl.Height
      UserControl.Width = 40
  End If
 
End Sub

Public Property Get Enabled() As Boolean
  Enabled = UserControl.Enabled
End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)
  UserControl.Enabled() = New_Enabled
  PropertyChanged "Enabled"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,&H00000000&
Public Property Get DarkColour() As OLE_COLOR
  DarkColour = m_DarkColour
End Property

Public Property Let DarkColour(ByVal New_DarkColour As OLE_COLOR)
  m_DarkColour = New_DarkColour
  PropertyChanged "DarkColour"
  Line1.BorderColor = m_DarkColour
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,&H00C0C0C0&
Public Property Get LightColour() As OLE_COLOR
  LightColour = m_LightColour
End Property

Public Property Let LightColour(ByVal New_LightColour As OLE_COLOR)
  m_LightColour = New_LightColour
  PropertyChanged "LightColour"
  Line2.BorderColor = m_LightColour
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,-1
Public Property Get Horizonthal() As Boolean
  Horizonthal = m_Horizonthal
End Property

Public Property Let Horizonthal(ByVal New_Horizonthal As Boolean)
  m_Horizonthal = New_Horizonthal
  PropertyChanged "Horizonthal"
End Property

'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
  m_DarkColour = m_def_DarkColour
  m_LightColour = m_def_LightColour
  m_Horizonthal = m_def_Horizonthal
End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

  UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
  m_DarkColour = PropBag.ReadProperty("DarkColour", m_def_DarkColour)
  m_LightColour = PropBag.ReadProperty("LightColour", m_def_LightColour)
  m_Horizonthal = PropBag.ReadProperty("Horizonthal", m_def_Horizonthal)
End Sub

'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

  Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
  Call PropBag.WriteProperty("DarkColour", m_DarkColour, m_def_DarkColour)
  Call PropBag.WriteProperty("LightColour", m_LightColour, m_def_LightColour)
  Call PropBag.WriteProperty("Horizonthal", m_Horizonthal, m_def_Horizonthal)
End Sub

Attached Images
   

Value Counter User Control

$
0
0
A small value counter:
Name:  Image 047.png
Views: 27
Size:  373 Bytes

What's on the form:
Name:  Image 049.png
Views: 25
Size:  458 Bytes

What is it?
Name:  Image 048.png
Views: 24
Size:  2.9 KB

The coding:
Code:


'Default Property Values:
Const m_def_Value = 0
'Property Variables:
Dim m_Value As Integer
'Event Declarations:
Event DownClick(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=ThisCountDown,ThisCountDown,-1,MouseUp
Event UpClick(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=ThisCountUp,ThisCountUp,-1,MouseUp

Public Property Get Value() As Integer
  Value = m_Value
End Property

Public Property Let Value(ByVal New_Value As Integer)
  m_Value = New_Value
  PropertyChanged "Value"
  CounterLabel.Text = m_Value
End Property

Private Sub UserControl_InitProperties()
  m_Value = m_def_Value
  UserControl.Height = ThisCountUp.Height - 20
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

  m_Value = PropBag.ReadProperty("Value", m_def_Value)
  CounterLabel.BackColor = PropBag.ReadProperty("BackColor", &H80000005)
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

  Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
  Call PropBag.WriteProperty("BackColor", CounterLabel.BackColor, &H80000005)
End Sub

Public Property Get BackColor() As OLE_COLOR
  BackColor = CounterLabel.BackColor
End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
  CounterLabel.BackColor() = New_BackColor
  PropertyChanged "BackColor"
End Property

Private Sub ThisCountDown_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  RaiseEvent DownClick(Button, Shift, X, Y)
  CounterLabel.Text = Val(CounterLabel.Text) - 1
  m_Value = Val(CounterLabel.Text)

End Sub

Private Sub ThisCountUp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  RaiseEvent UpClick(Button, Shift, X, Y)
  CounterLabel.Text = Val(CounterLabel.Text) + 1
  m_Value = Val(CounterLabel.Text)
End Sub

The user can enlarge the textbox size manually or add code to it, as well as forecolor which I did not need.
Attached Images
   

Extra Info Storer User Control

$
0
0
In-visible at run time, it can store up to 20 values per control for use in a program.

There are nothing on the form. It's not a container for other controls either.

How does it look inside the properties?
Name:  Image 050.png
Views: 33
Size:  4.1 KB

The Code:
Code:

'Default Property Values:
Const m_def_F1a = 0
Const m_def_F1b = 0
Const m_def_F2a = 0
Const m_def_F2b = 0
Const m_def_F3a = 0
Const m_def_F3b = 0
Const m_def_F4a = 0
Const m_def_F4b = 0
Const m_def_F5a = 0
Const m_def_F5b = 0
Const m_def_F6a = 0
Const m_def_F6b = 0
Const m_def_F7a = 0
Const m_def_F7b = 0
Const m_def_F8a = 0
Const m_def_F8b = 0
Const m_def_F9a = 0
Const m_def_F9b = 0
Const m_def_F0a = 0
Const m_def_F0b = 0
'Property Variables:
Dim m_F1a As Variant
Dim m_F1b As Variant
Dim m_F2a As Variant
Dim m_F2b As Variant
Dim m_F3a As Variant
Dim m_F3b As Variant
Dim m_F4a As Variant
Dim m_F4b As Variant
Dim m_F5a As Variant
Dim m_F5b As Variant
Dim m_F6a As Variant
Dim m_F6b As Variant
Dim m_F7a As Variant
Dim m_F7b As Variant
Dim m_F8a As Variant
Dim m_F8b As Variant
Dim m_F9a As Variant
Dim m_F9b As Variant
Dim m_F0a As Variant
Dim m_F0b As Variant

Public Property Get F1a() As Variant
  F1a = m_F1a
End Property

Public Property Let F1a(ByVal New_F1a As Variant)
  m_F1a = New_F1a
  PropertyChanged "F1a"
End Property

Public Property Get F1b() As Variant
  F1b = m_F1b
End Property

Public Property Let F1b(ByVal New_F1b As Variant)
  m_F1b = New_F1b
  PropertyChanged "F1b"
End Property

Public Property Get F2a() As Variant
  F2a = m_F2a
End Property

Public Property Let F2a(ByVal New_F2a As Variant)
  m_F2a = New_F2a
  PropertyChanged "F2a"
End Property

Public Property Get F2b() As Variant
  F2b = m_F2b
End Property

Public Property Let F2b(ByVal New_F2b As Variant)
  m_F2b = New_F2b
  PropertyChanged "F2b"
End Property

Public Property Get F3a() As Variant
  F3a = m_F3a
End Property

Public Property Let F3a(ByVal New_F3a As Variant)
  m_F3a = New_F3a
  PropertyChanged "F3a"
End Property

Public Property Get F3b() As Variant
  F3b = m_F3b
End Property

Public Property Let F3b(ByVal New_F3b As Variant)
  m_F3b = New_F3b
  PropertyChanged "F3b"
End Property

Public Property Get F4a() As Variant
  F4a = m_F4a
End Property

Public Property Let F4a(ByVal New_F4a As Variant)
  m_F4a = New_F4a
  PropertyChanged "F4a"
End Property

Public Property Get F4b() As Variant
  F4b = m_F4b
End Property

Public Property Let F4b(ByVal New_F4b As Variant)
  m_F4b = New_F4b
  PropertyChanged "F4b"
End Property

Public Property Get F5a() As Variant
  F5a = m_F5a
End Property

Public Property Let F5a(ByVal New_F5a As Variant)
  m_F5a = New_F5a
  PropertyChanged "F5a"
End Property

Public Property Get F5b() As Variant
  F5b = m_F5b
End Property

Public Property Let F5b(ByVal New_F5b As Variant)
  m_F5b = New_F5b
  PropertyChanged "F5b"
End Property

Public Property Get F6a() As Variant
  F6a = m_F6a
End Property

Public Property Let F6a(ByVal New_F6a As Variant)
  m_F6a = New_F6a
  PropertyChanged "F6a"
End Property

Public Property Get F6b() As Variant
  F6b = m_F6b
End Property

Public Property Let F6b(ByVal New_F6b As Variant)
  m_F6b = New_F6b
  PropertyChanged "F6b"
End Property

Public Property Get F7a() As Variant
  F7a = m_F7a
End Property

Public Property Let F7a(ByVal New_F7a As Variant)
  m_F7a = New_F7a
  PropertyChanged "F7a"
End Property

Public Property Get F7b() As Variant
  F7b = m_F7b
End Property

Public Property Let F7b(ByVal New_F7b As Variant)
  m_F7b = New_F7b
  PropertyChanged "F7b"
End Property

Public Property Get F8a() As Variant
  F8a = m_F8a
End Property

Public Property Let F8a(ByVal New_F8a As Variant)
  m_F8a = New_F8a
  PropertyChanged "F8a"
End Property

Public Property Get F8b() As Variant
  F8b = m_F8b
End Property

Public Property Let F8b(ByVal New_F8b As Variant)
  m_F8b = New_F8b
  PropertyChanged "F8b"
End Property

Public Property Get F9a() As Variant
  F9a = m_F9a
End Property

Public Property Let F9a(ByVal New_F9a As Variant)
  m_F9a = New_F9a
  PropertyChanged "F9a"
End Property

Public Property Get F9b() As Variant
  F9b = m_F9b
End Property

Public Property Let F9b(ByVal New_F9b As Variant)
  m_F9b = New_F9b
  PropertyChanged "F9b"
End Property

Public Property Get F0a() As Variant
  F0a = m_F0a
End Property

Public Property Let F0a(ByVal New_F0a As Variant)
  m_F0a = New_F0a
  PropertyChanged "F0a"
End Property

Public Property Get F0b() As Variant
  F0b = m_F0b
End Property

Public Property Let F0b(ByVal New_F0b As Variant)
  m_F0b = New_F0b
  PropertyChanged "F0b"
End Property

Private Sub UserControl_InitProperties()
  m_F1a = m_def_F1a
  m_F1b = m_def_F1b
  m_F2a = m_def_F2a
  m_F2b = m_def_F2b
  m_F3a = m_def_F3a
  m_F3b = m_def_F3b
  m_F4a = m_def_F4a
  m_F4b = m_def_F4b
  m_F5a = m_def_F5a
  m_F5b = m_def_F5b
  m_F6a = m_def_F6a
  m_F6b = m_def_F6b
  m_F7a = m_def_F7a
  m_F7b = m_def_F7b
  m_F8a = m_def_F8a
  m_F8b = m_def_F8b
  m_F9a = m_def_F9a
  m_F9b = m_def_F9b
  m_F0a = m_def_F0a
  m_F0b = m_def_F0b
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

  m_F1a = PropBag.ReadProperty("F1a", m_def_F1a)
  m_F1b = PropBag.ReadProperty("F1b", m_def_F1b)
  m_F2a = PropBag.ReadProperty("F2a", m_def_F2a)
  m_F2b = PropBag.ReadProperty("F2b", m_def_F2b)
  m_F3a = PropBag.ReadProperty("F3a", m_def_F3a)
  m_F3b = PropBag.ReadProperty("F3b", m_def_F3b)
  m_F4a = PropBag.ReadProperty("F4a", m_def_F4a)
  m_F4b = PropBag.ReadProperty("F4b", m_def_F4b)
  m_F5a = PropBag.ReadProperty("F5a", m_def_F5a)
  m_F5b = PropBag.ReadProperty("F5b", m_def_F5b)
  m_F6a = PropBag.ReadProperty("F6a", m_def_F6a)
  m_F6b = PropBag.ReadProperty("F6b", m_def_F6b)
  m_F7a = PropBag.ReadProperty("F7a", m_def_F7a)
  m_F7b = PropBag.ReadProperty("F7b", m_def_F7b)
  m_F8a = PropBag.ReadProperty("F8a", m_def_F8a)
  m_F8b = PropBag.ReadProperty("F8b", m_def_F8b)
  m_F9a = PropBag.ReadProperty("F9a", m_def_F9a)
  m_F9b = PropBag.ReadProperty("F9b", m_def_F9b)
  m_F0a = PropBag.ReadProperty("F0a", m_def_F0a)
  m_F0b = PropBag.ReadProperty("F0b", m_def_F0b)
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

  Call PropBag.WriteProperty("F1a", m_F1a, m_def_F1a)
  Call PropBag.WriteProperty("F1b", m_F1b, m_def_F1b)
  Call PropBag.WriteProperty("F2a", m_F2a, m_def_F2a)
  Call PropBag.WriteProperty("F2b", m_F2b, m_def_F2b)
  Call PropBag.WriteProperty("F3a", m_F3a, m_def_F3a)
  Call PropBag.WriteProperty("F3b", m_F3b, m_def_F3b)
  Call PropBag.WriteProperty("F4a", m_F4a, m_def_F4a)
  Call PropBag.WriteProperty("F4b", m_F4b, m_def_F4b)
  Call PropBag.WriteProperty("F5a", m_F5a, m_def_F5a)
  Call PropBag.WriteProperty("F5b", m_F5b, m_def_F5b)
  Call PropBag.WriteProperty("F6a", m_F6a, m_def_F6a)
  Call PropBag.WriteProperty("F6b", m_F6b, m_def_F6b)
  Call PropBag.WriteProperty("F7a", m_F7a, m_def_F7a)
  Call PropBag.WriteProperty("F7b", m_F7b, m_def_F7b)
  Call PropBag.WriteProperty("F8a", m_F8a, m_def_F8a)
  Call PropBag.WriteProperty("F8b", m_F8b, m_def_F8b)
  Call PropBag.WriteProperty("F9a", m_F9a, m_def_F9a)
  Call PropBag.WriteProperty("F9b", m_F9b, m_def_F9b)
  Call PropBag.WriteProperty("F0a", m_F0a, m_def_F0a)
  Call PropBag.WriteProperty("F0b", m_F0b, m_def_F0b)
End Sub

No extra coding to dimension fields or declaring of values etc.
Plain and simple.
Attached Images
 

A little bit of MSDN .CHM files info

$
0
0
I did this this afternoon, for myself and others. Just an idea - nothing fancy:

Name:  Image 052.jpg
Views: 55
Size:  51.9 KB

The form (only one), with the .frx with pictures and icon: Project MSDN.zip

The main code to load the .chm file was not mine, but was taken from this site. I see the code here posted in 2004 by someone (http://www.vbforums.com/showthread.p...t=shellexecute #2, by RobDog888).

...which was then changed by Shaitan00 #3, which I took and inserted into my program:

Code:

By RobDog888
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
 
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2

& by: Shaitan00

Dim lRet As Long
lRet = ShellExecute(Me.hwnd, vbNullString, "Help.pdf", vbNullString, "C:\", SW_SHOWNORMAL)

The rest was just magic - on the outside :D


Project: Project MSDN.zip
Attached Images
 
Attached Files

Home Budget-Slip System

$
0
0
My first successful home budget program written was back in QuickBasic 7, in the late 1980's and Early 1990's.

The name "Law" stick from the first time till now.

I upgraded (actually, re-written) to VB3 in the old Win 3.11 system and when Win98 came along, I upgraded it to VB5 and later change a bit here-and-there to VB6.

The face did not changed a lot over these years, but currently have changed (still busy) it completely, re-building everything in some of the forms.

Some people who (try) to use it says it's too difficult, but a recent acquaintance who is in business for more than 30 years feels this is exactly what he need.

There's a smaller, quicker version I wrote for my wife, in a similar layout but with only a few pages (forms), but that will be discussed later.

So, before I change everything and forget what I have done, let me give this one for you.

There are still some errors (after all this time :) ), as can been seen in the Accumulative and Report form...

(( Uncle Sam Brown (and many others) will hate this code... :D :D ))

LAW8: (Yes, the .vbp says LAW9)
Name:  Image 060.jpg
Views: 40
Size:  38.3 KB

Law9.zip
Attached Images
 
Attached Files

[VB6] Speech Recognition via SAPI

$
0
0
This is a trivial demo of bare bones use of SAPI for speech recognition.

The documentation can be found at MSDN:

Automation Interfaces and Objects (SAPI 5.4)

There is much more you can do than is shown in this tiny example, which uses the first audio input source found and uses defaults for many other things (such as free dictation).

Code:

Option Explicit

'See "Automation Interfaces and Objects (SAPI 5.4)" at MSDN.

Private WithEvents RC As SpeechLib.SpInProcRecoContext
Private RG As SpeechLib.ISpeechRecoGrammar

Private Sub Form_Load()
    With New SpeechLib.SpInprocRecognizer
        Set RC = .CreateRecoContext()
        Set .AudioInput = .GetAudioInputs().Item(0)
    End With
    With RC
        .EventInterests = SRERecognition Or SREFalseRecognition
        Set RG = .CreateGrammar()
    End With
    RG.DictationSetState SGDSActive
End Sub

Private Sub Form_Resize()
    If WindowState <> vbMinimized Then
        Text1.Move 0, 0, ScaleWidth, ScaleHeight
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    RG.DictationSetState SGDSInactive
End Sub

Private Sub RC_FalseRecognition( _
    ByVal StreamNumber As Long, _
    ByVal StreamPosition As Variant, _
    ByVal Result As SpeechLib.ISpeechRecoResult)

    With Text1
        .SelStart = &H7FFF
        .SelText = "False Rec: "
        .SelText = Result.PhraseInfo.GetText()
        .SelText = vbNewLine
    End With
End Sub

Private Sub RC_Recognition( _
    ByVal StreamNumber As Long, _
    ByVal StreamPosition As Variant, _
    ByVal RecognitionType As SpeechLib.SpeechRecognitionType, _
    ByVal Result As SpeechLib.ISpeechRecoResult)

    With Text1
        .SelStart = &H7FFF
        .SelText = "Rec: "
        .SelText = Result.PhraseInfo.GetText()
        .SelText = vbNewLine
    End With
End Sub

Name:  sshot.png
Views: 67
Size:  1.3 KB

SAPI 5.4 requires the dying Windows 7 or later. SAPI 5.3 is highly compatible on the dead Windows Vista. Those are part of Windows and preinstalled. You may limp along even on the dead Windows XP, 98, 2000, etc. if you install the SAPI 5.1 SDK. SAPI 5.2 was a special release only used on an old MS Speech Server product.
Attached Images
 
Attached Files

VB6 2D Physic Engine

$
0
0
VB6 port of 2D Impulse Engine
by Randy Gaul:
http://www.randygaul.net/projects-op...mpulse-engine/
and Philip Diffenderfer:
https://github.com/ClickerMonkey/ImpulseEngine

+ (Experimental) Joints by the Author

Author: Roberto Mior (aka reexre,miorsoft)
Contibutors: yet none.

Never found a VB6 implementation of a simple 2D physic engine. So I come to a VB6 version starting from
Randy Gaul 2D impulse engine (and Philip Diffenderfer java port).

I also added other things such as
  • +Joints (Not so perfect, look for someone to suggest better implementation)
  • +Collision Groups (To make some objects not collide with every objects)
  • +collsions callback events
  • +Polygon Chamfer



This is the old thread of this project , Since it works quite well I decided to put it in the CodeBank session.
Now instead of a number of modules I compacted them to 1 class and 1 module.

Suggestions and improvements are wellcome !


(Later I'll put the code on GitHub)


Requires:
* vbRichClient (for Render) http://vbrichclient.com/#/en/About/


LICENSE: BSD. (https://opensource.org/licenses/BSD-2-Clause)


Copyright © 2017 by Roberto Mior (Aka reexre,miorsoft)






UPDATE: 1.0.147
Better Joints:
(see "1.0.147" comments)
Attached Files

vbrichclient5.dll examples

$
0
0
hi. very interested to find out where to go to see active discussions on using vbrichclient5.dll.
I have see some posted here but wondered if there was something like planetsourcecode
where users etc can upload code examples of how to do stuff.

I know there is http://www.vbrichclient.com/#/en/About/ but dont see any easy to follow
code examples. ie step by step.

I have searched the internet and only real resource is this site.
many thanks in advance.

k_zeon

URL Save

$
0
0
A program I written a while back, which can save all the important (and not :) ) URL's.

Especially needed to have these URL's at hand when re-installing windows, moving to a new pc or for whatever reason.

Simple code. Straight forward. Nothing special. It's all about the idea.

Included RTF help.

Name:  Image 081.jpg
Views: 56
Size:  25.5 KB

The Program:
URL Save.zip
Attached Images
 
Attached Files

W10 Accounts

$
0
0
When we grow older we tend to forget passwords and user names etc.

Not entirely true. In this day and age, when roaming the internet and became part and participate within the w.w.w. , we create so many different accounts, passwords etc. we WILL forget some of the less-used passwords and/or accounts.

Some users use programs that store these info for them, but are you sure some info is not send when on-line with such so-and-so-password-storer program?

This was the solution to my own security problems.
A program originally written for "Need for speed world" accounts (which I have a lot of :) ), and later it become part of my everyday internet life:

W10 Accounts:
Name:  Image 082.jpg
Views: 83
Size:  24.6 KB

The program:
W10 Accounts.zip
Attached Images
 
Attached Files
Viewing all 1492 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>