Category Archives: Visual Basic 6 (VB6)

Kill a Program Process

This will allow you kill running tasks or processes, provided the account you are running it under has the permissions to do so. This could be useful if you want to write your own version of Task Manager. ‘——————————————————-Type PROCESSENTRY32    dwSize As Long    cntUsage As Long    th32ProcessID As Long    th32DefaultHeapID As Long    th32ModuleID As Long    cntThreads As Long    th32ParentProcessID As Long    pcPriClassBase As Long    dwFlags As Long    szexeFile… Read More »

Implement chm Help in Visual Basic

Give your app a more polished appearance by using .chm files for your help system. First place a existing chm File in the project path. You must know what name your htm pages have to work correct. Module Option ExplicitPrivate Declare Function HtmlHelpTopic Lib “hhctrl.ocx” Alias _    “HtmlHelpA” (ByVal hWnd As Long, ByVal lpHelpFile As String, _    ByVal wCommand As… Read More »

Move a non-caption form using no API, no DLL

Paste the following code in a module and call it from the mousemove routine of the form that you like to move as: mousemove [form.name],x,y,button. Drag the form to move it, use same calling code if you need to move the form dragging over a control in the form (pay attention to click_routine potential conflict). Sub moveform(ff As Form,… Read More »

Form Management

This module will help you manage the minimize/maximize buttons, the forms system menu, and the position of your form. Option Explicit Private Declare Function DeleteMenu Lib “user32.dll” (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As LongPrivate Declare Function GetSystemMenu Lib “user32.dll” (ByVal hWnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function… Read More »

Progress Bar Inside Status Bar

This great chunk of code shows how to leverage the Windows API to put a progress bar inside of a status bar, on an MDI form. Option Explicit’*******************************************************************’API’******************************************************************* ‘SetParentPrivate Declare Function SetParent Lib “user32.dll” _   (ByVal hWndChild As Long, _ByVal hWndNewParent As Long) As Long’SendMessagePrivate Declare Function SendMessage Lib “user32.dll” Alias “SendMessageA” _   (ByVal hWnd As Long, _   ByVal wMsg As… Read More »

Add a OnMoving Event to your Forms

With this example, you can have “stuff happen” when a form is moved on the screen. Option Explicit ‘API TypesPublic Type RECT   Left As Long   Top As Long   Right As Long   Bottom As LongEnd Type ‘API ConstantsConst WM_MOVING = 534Const GWL_WNDPROC = (-4) ‘API declarationsPrivate Declare Function SetWindowLong Lib “user32.dll” Alias “SetWindowLongA” (ByVal hWnd As Long, ByVal nindex As Long, ByVal dwnewlong… Read More »

Layered Windows in VB6

Makes a nice layered window effect, with adjustable transparency. Option ExplicitDeclare Function GetWindowLong Lib “user32.dll” Alias “GetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long) As LongDeclare Function SetWindowLong Lib “user32.dll” Alias “SetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function SetLayeredWindowAttributes Lib “user32.dll” (ByVal hWnd As Long, ByVal crKey As… Read More »

INI File Class

This class module will allow you to easily work with INI files. This will let you store settings and preferences for your program that are persistent between runs. You can download the attachment above, or copy and paste the below chunk of code to a new class module in your project. Option Explicit ‘APIPrivate Declare Function GetPrivateProfileInt Lib… Read More »

Simple Fixed Array, Part 2

In the last tutorial (Simple Fixed Array, Part 1) we had a fixed Array of Elements (Animals), and when we selected one of the Radio Buttons a Label would show us which number the Element was. But what if we had more than just six Elements as in our Array, say we had 500 Elements and we needed… Read More »

Simple Fixed Array, Part 1

When I started programming the one thing that would trick me was Arrays. So, with this in mind, I have decided to write 3 tutorials to try and help other beginners. What follows is a fixed array, an array is simply a container for a list of elemants in the case of this example it is a list… Read More »