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

mBox Reader

$
0
0
Hi this is a mail message box reader I made to read old usenet message box files. if you want any mail box files you can find a load on wayback machine. with this little app it makes it easyer to read each message. anyway hope you like it.

Name:  logo.jpg
Views: 59
Size:  40.6 KB

Download Source Project:

mBox.zip
Attached Images
 
Attached Files

Text To Picture

$
0
0
Hi
This is a project I made sometime ago, it allows you to encrypt text and save as a bitmap, You can then load the bitmap and with the right encrypt key you used you can decrypt the text.
Hope you find it usfull.

Name:  logo.jpg
Views: 23
Size:  153.9 KB

Download Project
Text2Pic.zip
Attached Images
 
Attached Files

Random Password Generator

$
0
0
Hi,
This is a password generator I made a few months back with the help of a friend who added a few featires. it contains many options skins and more hope you like it.

Name:  logo.jpg
Views: 57
Size:  50.7 KB

Download Source Code:
PwsGenStd.zip
Attached Images
 
Attached Files

Radial Busy GIF

$
0
0
I was looking for a simple rotary graphic to indicate that a program was busy performing a task. I found such an image at this Web site:
http://www.ajaxload.info/
You can change the color combinations to produce and download the Animated GIF file. I have included 2 circular busy GIFs, one with a white background and one with a light yellow background.

Unfortunately, VB6 does not directly support animated GIF files. Based on an Animated GIF Control by Jen Sam Lam, I put together the attached User Control. An animated GIF is a layered structure consisting of a number of frames. Because none of the picture based controls in VB6 support the layered structure, it is broken up into the individual frames in an Image array. In this case there are 8 frames controlled by a timer.

The individual frames are converted into a temporary file and loaded to the image array. I was wondering if there was a more direct way of loading the individual frames. Feedback is welcome.

J.A. Coutts
Attached Images
 
Attached Files

ColorPicker similar to PhotoShop's (Learn vbRichClient5.Cairo drawing step by step)

$
0
0
There are several good ColorPickers in the CodeBank, for example:

(1) ColinE66's ColourPicker[vbRichClient]: http://www.vbforums.com/showthread.p...r-vbRichClient
(2) Eduardo's Wheel Color Picker: http://www.vbforums.com/showthread.p...l-Color-Picker

But I need a ColorPicker similar to PhotoShop's, because PhotoShop is the most widely used drawing tool in the world.

wqweto wrote a very good ColorPicker similar to PhotoShop's 18 years ago, but its UI is so old that I can't use it in my projects. So I decided to rewrite wqweto's ColorPicker with vbRichClient5.Cairo.

Although I've used RC5.Cairo in my Spread and CodeEditor, Cairo's syntax is completely different from VB6 GDI, so that as long as I don't use Cairo for 6 months, I'll completely forget Cairo's usage, and I need to start learning it from scratch. Therefore, I think it necessary to record the process of rewriting wqweto's ColorPicker with RC5.Cairo for others interested in learning Cairo drawing.

It will take some time to rewrite wqweto's ColorPicker, because I need to spend a lot of time to search for information and test the usage of Cairo. Fortunately, Olaf has left a large number of Cairo examples on this forum. Searching these examples can solve almost all Cairo drawing problems.

wqweto's real-time PhotoShop like color-picker
http://www.planet-source-code.com/vb...xtCodeId=36529

Note:
My ultimate goal is to use RC5.Cairo to develop a professional and modern ColorPicker similar to PhotoShop's, which will be named vbColorPicker. If I have more time in the future, I'll rewrite Eduardo's Wheel Color Picker with Cairo and add it to vbColorPicker to form vbColorPickerPro. As for cwColorPicker, I need Olaf's help and guidance to complete it. Maybe ColinE66 is a better candidate to develop it.

List of revisions:
Code:

2020-06-25
- First released learning/rewriting framework

Attached Files

mBox Reader

$
0
0
Hi this is a mail message box reader I made to read old usenet message box files. if you want any mail box files you can find a load on wayback machine. with this little app it makes it easyer to read each message. anyway hope you like it.

Name:  logo.jpg
Views: 140
Size:  40.6 KB

Download Source Project:

mBox.zip
Attached Images
 
Attached Files

Text To Picture

$
0
0
Hi
This is a project I made sometime ago, it allows you to encrypt text and save as a bitmap, You can then load the bitmap and with the right encrypt key you used you can decrypt the text.
Hope you find it usfull.

Name:  logo.jpg
Views: 125
Size:  153.9 KB

Download Project
Text2Pic.zip
Attached Images
 
Attached Files

Random Password Generator

$
0
0
Hi,
This is a password generator I made a few months back with the help of a friend who added a few featires. it contains many options skins and more hope you like it.

Name:  logo.jpg
Views: 141
Size:  50.7 KB

Download Source Code:
PwsGenStd.zip
Attached Images
 
Attached Files

Radial Busy GIF

$
0
0
I was looking for a simple rotary graphic to indicate that a program was busy performing a task. I found such an image at this Web site:
http://www.ajaxload.info/
You can change the color combinations to produce and download the Animated GIF file. I have included 2 circular busy GIFs, one with a white background and one with a light yellow background.

Unfortunately, VB6 does not directly support animated GIF files. Based on an Animated GIF Control by Jen Sam Lam, I put together the attached User Control. An animated GIF is a layered structure consisting of a number of frames. Because none of the picture based controls in VB6 support the layered structure, it is broken up into the individual frames in an Image array. In this case there are 8 frames controlled by a timer.

The individual frames are converted into a temporary file and loaded to the image array. I was wondering if there was a more direct way of loading the individual frames. Feedback is welcome.

J.A. Coutts

Updated: 06/20/2020 - See later post for details
Attached Images
 
Attached Files

ColorPicker similar to PhotoShop's (Learn vbRichClient5.Cairo drawing step by step)

$
0
0
There are several good ColorPickers in the CodeBank, for example:

(1) ColinE66's ColourPicker[vbRichClient]: http://www.vbforums.com/showthread.p...r-vbRichClient
(2) Eduardo's Wheel Color Picker: http://www.vbforums.com/showthread.p...l-Color-Picker

But I need a ColorPicker similar to PhotoShop's, because PhotoShop is the most widely used drawing tool in the world.

wqweto wrote a very good ColorPicker similar to PhotoShop's 18 years ago, but its UI is so old that I can't use it in my projects. So I decided to rewrite wqweto's ColorPicker with vbRichClient5.Cairo.

Although I've used RC5.Cairo in my Spread and CodeEditor, Cairo's syntax is completely different from VB6 GDI, so that as long as I don't use Cairo for 6 months, I'll completely forget Cairo's usage, and I need to start learning it from scratch. Therefore, I think it necessary to record the process of rewriting wqweto's ColorPicker with RC5.Cairo for others interested in learning Cairo drawing.

It will take some time to rewrite wqweto's ColorPicker, because I need to spend a lot of time to search for information and test the usage of Cairo. Fortunately, Olaf has left a large number of Cairo examples on this forum. Searching these examples can solve almost all Cairo drawing problems.

wqweto's real-time PhotoShop like color-picker
http://www.planet-source-code.com/vb...xtCodeId=36529

Note:
My ultimate goal is to use RC5.Cairo to develop a professional and modern ColorPicker similar to PhotoShop's, which will be named vbColorPicker. If I have more time in the future, I'll rewrite Eduardo's Wheel Color Picker with Cairo and add it to vbColorPicker to form vbColorPickerPro. As for cwColorPicker, I need Olaf's help and guidance to complete it. Maybe ColinE66 is a better candidate to develop it.

List of revisions:
Code:

2020-07-06
- vbColorPicker Final

2020-07-02
- Add PopupPosition parameter to ShowEx function.
- Improved FrmColorPicker

Note:
Now the vbColorPicker is basically completed.

2020-07-01
- Completely rewrote FrmColorPicker

2020-06-30
- Add CreateBarSat (DreamManor -- RC5.Cairo)
- Add CreateRectSat (DreamManor -- RC5.Cairo)
- Add CreateRectSatAccelerate (DreamManor -- RC5.Cairo)
- Add CreateBarBri (DreamManor -- RC5.Cairo)
- Add CreateRectBri (DreamManor -- RC5.Cairo)
- Add CreateRectBriAccelerate (DreamManor -- RC5.Cairo)
- Add Only-Web-Colors Test-Option
- Improved SpinBox
- Add vbColorPicker: FrmColorPicker(Beta)

2020-06-28
- Add cUpDown.cls (DreamManor -- RC5.Cairo)
- Add SpinBox User Control (DreamManor)
- Add SpinBox Test Page (DreamManor)

2020-06-27 a.m.
- Create Rect Hue (DreamManor -- RC5.Cairo)
- Create Rect Hue (Acclerate) (DreamManor -- RC5.Cairo)
- Create Rect RGB (DreamManor -- RC5.Cairo)
- Add Speed Compare Module

2020-06-26
- Create Bar Hue (DreamManor -- RC5.Cairo)
- Create Bar RGB (DreamManor -- RC5.Cairo)
- Create Rect RGB (Acclerate) (DreamManor -- RC5.Cairo)

2020-06-25 p.m.
- Draw border on a picture(DreamManor -- RC5.Cairo)
- Draw bar selector (DreamManor -- RC5.Cairo)
- Draw bar selector (Olaf -- Best Practice)
- Draw rect marker (DreamManor -- RC5.Cairo)

2020-06-25
- First released learning/rewriting framework

Attached Images
 
Attached Files

Simulate TLS 1.3

$
0
0
To understand TLS 1.3, https://tls13.ulfheim.net/ is useful, but unfortunately it contains several discrepancies if you want to follow it in detail (eg. labels are not complete). For the detail, https://tools.ietf.org/html/rfc8448 is better. Unfortunately, Win 8.1 does not support x25519, so the best I could come up with was a simulation without generating the Agreed Secret.

Like previous cryptographic protocols, TLS 1.3 uses a Session Hash. Unlike previous protocols, it uses 2 sets of keys and encrypts part of the handshake. The Session Hash uses the decrypted data, and Write keys on the Server are Read keys on the Client (and visa versa).

The attached program attempts to duplicate the steps in the IETF trace example for the Simple 1-RTT Handshake, separating the Client steps from the Server. In the Client and Server portions, the Hash is not calculated or shown, as it is included in the Info. Clicking "Client" or "Server" takes you to the first step of calculating the "Early Secret". Using the "Enter" key advances through each step until the keys are summarized at the end.

The Key options on the other hand don't show all the information used, the Session Hash is calculated, and calculations are made as soon as the information is available.

The next step will be to add the actual encryption/decryption as well as the application data.

J.A. Coutts
Attached Images
 
Attached Files

Programmatically adding and using buttons on a VB form.

$
0
0
Put this code in Form1, and make sure to set the form's AutoRedraw property to True (you won't want printed text disappearing permanently if it's below the form and you just need to resize it).
Code:

Private Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32.dll" (ByVal hWnd As Long) As Long

Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_CHILD As Long = &H40000000


Public IsRunning As Boolean


Private Sub Form_Load()
    'set the BUTTON window class function
    hButton = CreateWindowEx(0, "BUTTON", "", 0, 0, 0, 0, 0, 0, 0, 0, ByVal 0&)
    OldWndProc = SetClassLong(hButton, GCL_WNDPROC, AddressOf WndProc)
    DestroyWindow hButton
   
    'create buttons
    hButton = CreateWindowEx(0, "BUTTON", "Test Button 1", WS_VISIBLE Or WS_CHILD, 50, 20, 120, 30, hWnd, 0, 0, ByVal 0&)
    hButton2 = CreateWindowEx(0, "BUTTON", "Test Button 2", WS_VISIBLE Or WS_CHILD, 50, 20 + 30, 120, 30, hWnd, 0, 0, ByVal 0&)
   
    'make sure the button class function knows the program is running
    IsRunning = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'make sure the button class function knows the program is not running
    IsRunning = False
   
    'restore original BUTTON window class function
    SetClassLong hButton, GCL_WNDPROC, OldWndProc
   
    'remove buttons
    DestroyWindow hButton
    DestroyWindow hButton2
End Sub


Put this code in Module1.
Code:

Public Declare Function SetClassLong Lib "user32.dll" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Const GCL_WNDPROC As Long = -24

Public Const WM_LBUTTONDOWN As Long = &H201
Public Const WM_LBUTTONDBLCLK As Long = &H203
Public Const WM_LBUTTONUP As Long = &H202


Public OldWndProc As Long

Public hButton As Long
Public hButton2 As Long

'function to handle all button messages
Public Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If Form1.IsRunning Then
        'If (uMsg = WM_LBUTTONDOWN) Or (uMsg = WM_LBUTTONDBLCLK) Then ButtonClick hWnd
        If uMsg = WM_LBUTTONUP Then ButtonClick hWnd
    End If
    WndProc = CallWindowProc(OldWndProc, hWnd, uMsg, wParam, lParam)
End Function


'function to handle all button clicks
Private Sub ButtonClick(ByVal hWnd As Long)
    Select Case hWnd
        Case hButton
            Button1Clicked
        Case hButton2
            Button2Clicked
    End Select
End Sub


'click handler for button 1
Private Sub Button1Clicked()
    Form1.Print "123"
End Sub


'click handler for button 2
Private Sub Button2Clicked()
    Form1.Print "ABC"
End Sub


When the program is run, two buttons will appear on the form. If you click the one called Test Button 1, it will print "123" on Form1. If you click the button called Test Button 2, it will print "ABC" on Form1.

Each button will respond after releasing it from a click. If you want it to respond at the instant it's clicked, instead of waiting to be released, comment out the line of code:
Code:

If uMsg = WM_LBUTTONUP Then ButtonClick hWnd
and uncomment out the line of code:
Code:

'If (uMsg = WM_LBUTTONDOWN) Or (uMsg = WM_LBUTTONDBLCLK) Then ButtonClick hWnd

Anchor Control

$
0
0
This code example is so that the controls can be anchored to the Form to be resized.

Although there are several examples of anchoring, I noticed that when placing the controls inside the FormChild, the anchoring becomes irregular at runtime and, with that, the anchored controls do not appear as in the design mode, and overlap each other.

To get around this I created this example based on the example of colleague SeabrookStan.

Follow link ... http://www.vbforums.com/showthread.p...king-made-Easy

In VB.Net there is a form property called AutoScaleMode and so this problem is corrected but in VB6 this property is not. So the present example corrects the problem.
Attached Files

[VB6] Another "magnifier"

$
0
0
The topic of writing screen magnifiers came up the other day, and I thought I might trot out this old approach.

Basically it shows simple use of a GDI Region object with StretchBlt. I had another example using StretchBlt then MaskBlt, but this is actually far simpler and less code.

A Timer is used here only to catch any movement at 5 frames/sec to keep overhead low, but even 10 fps shouldn't be too expensive on most PCs. The demo does a "4x" magnification.

Name:  sshot.png
Views: 92
Size:  1.7 KB

Here "DrawGrid" was just a simple program with some colors for me to magnify.

The "MagnifyX4" program is the grey square with the red arrow pointing at the magnified region, which can be dragged around to magnify different parts of the screen.

The circular GDI Region was only used to produce the "clever" circular magnification. You could just use StretchBlt without it to get a square magnifier.

Code:

Option Explicit
'
'Form1 is borderless, mainly to help draw an "arrow" to indicate the captured area of the
'desktop in this demo.  With a border the arrow would be off a bit (too low by the caption
'bar height and outline).
'
'We use a Timer control here in order to accomodate magnifying anything animated or moving.
'
'Assumptions:
'
'  o Form1's client area is square.
'

Private Const WIN32NULL As Long = 0

Private Declare Function CreateEllipticRgn Lib "gdi32" ( _
    ByVal nLeftRect As Long, _
    ByVal nTopRect As Long, _
    ByVal nRightRect As Long, _
    ByVal nBottomRect As Long) As Long

Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" ( _
    ByVal hWnd As Long, _
    ByRef RECT As RECT) As Long

Private Declare Function ReleaseDC Lib "user32" ( _
    ByVal hWnd As Long, _
    ByVal hDC As Long) As Long

Private Declare Function SelectClipRgn Lib "gdi32" ( _
    ByVal hDC As Long, _
    ByVal hRgn As Long) As Long

Private Declare Function StretchBlt Lib "gdi32" ( _
    ByVal hdcDest As Long, _
    ByVal nXOriginDest As Long, _
    ByVal nYOriginDest As Long, _
    ByVal nWidthDest As Long, _
    ByVal nHeightDest As Long, _
    ByVal hdcSrc As Long, _
    ByVal nXOriginSrc As Long, _
    ByVal nYOriginSrc As Long, _
    ByVal nWidthSrc As Long, _
    ByVal nHeightSrc As Long, _
    Optional ByVal dwRop As RasterOpConstants = vbSrcCopy) As Long

Private CaptureWH As Long
Private GrabX As Single
Private GrabY As Single
Private MagnifyWH As Long

Private Sub Peek()
    Dim hDCScreen As Long
    Dim hRgn As Long
    Dim RECT As RECT

    hDCScreen = GetDC(WIN32NULL)
    hRgn = CreateEllipticRgn(0, 0, MagnifyWH, MagnifyWH)
    SelectClipRgn hDC, hRgn
    GetWindowRect hWnd, RECT
    With RECT
        StretchBlt hDC, _
                  0, _
                  0, _
                  MagnifyWH, _
                  MagnifyWH, _
                  hDCScreen, _
                  .Left - CaptureWH, _
                  .Top - CaptureWH, _
                  CaptureWH, _
                  CaptureWH
    End With
    SelectClipRgn hDC, WIN32NULL
    DeleteObject hRgn
    ReleaseDC WIN32NULL, hDCScreen
    Set Picture = Image
End Sub

Private Sub Form_Load()
    AutoRedraw = True
    ScaleMode = vbTwips
    BackColor = &H808080
    ForeColor = vbRed
    DrawWidth = 3
    Line (30, 30)-(360, 360)
    Line (30, 30)-(360, 30)
    Line (30, 30)-(30, 360)
    MagnifyWH = ScaleX(ScaleWidth, ScaleMode, vbPixels)
    CaptureWH = MagnifyWH / 4

    Show
    DoEvents
    Peek
    MsgBox "Left-click and drag to move, shift-left-click to exit"
    With Timer1
        .Interval = 200 '5 fps capture.
        .Enabled = True
    End With
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Shift And vbShiftMask Then
        Unload Me
    ElseIf Button = vbLeftButton Then
        GrabX = X
        GrabY = Y
    End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim NewLeft As Single
    Dim NewTop As Single

    If Button = vbLeftButton Then
        NewLeft = Left + X - GrabX
        NewTop = Top + Y - GrabY
        Move NewLeft, NewTop
        'Commented out since we're using Timer1 to magnify anything animated
        'such as a video we're watching:
        'Peek
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
    Peek
End Sub

Attached Images
 
Attached Files

[VB6] GDI Path clipping

$
0
0
I don't see a lot here on this topic. Perhaps it's a bit "forgotten" or maybe not that useful to most people. This example is a bit silly but it might be enough to get you started using GDI Paths for a certain kind of graphics effects.

Code:

Option Explicit

Private Const OUTPUT_TEXT As String = "Some Text"

Private Declare Function AbortPath Lib "gdi32" (ByVal hDC As Long) As Long

Private Declare Function BeginPath Lib "gdi32" (ByVal hDC As Long) As Long

Private Declare Function EndPath Lib "gdi32" (ByVal hDC As Long) As Long

Private Enum CombineRgnStyles
    RGN_AND = 1    'The new clipping region includes the intersection (overlapping areas)
                    'of the current clipping region and the current path.
    RGN_OR = 2      'The new clipping region includes the union (combined areas) of the
                    'current clipping region and the current path.
    RGN_XOR = 3    'The new clipping region includes the union of the current clipping
                    'region and the current path but without the overlapping areas.
    RGN_DIFF = 4    'The new clipping region includes the areas of the current clipping
                    'region with those of the current path excluded.
    RGN_COPY = 5    'The new clipping region is the current path.
End Enum

Private Declare Function SelectClipPath Lib "gdi32" ( _
    ByVal hDC As Long, _
    ByVal Mode As CombineRgnStyles) As Long

Private Sub Paint()
    Static TickTock As Integer
    Dim N As Single

    If TickTock = 0 Then ForeColor = vbYellow Else ForeColor = vbRed
    For N = 0 To ScaleHeight Step 12
        Line (0, N)-(ScaleWidth, N)
    Next
    If TickTock = 1 Then ForeColor = vbYellow Else ForeColor = vbRed
    For N = 4 To ScaleHeight Step 12
        Line (0, N)-(ScaleWidth, N)
    Next
    If TickTock = 2 Then ForeColor = vbYellow Else ForeColor = vbRed
    For N = 8 To ScaleHeight Step 12
        Line (0, N)-(ScaleWidth, N)
    Next
    TickTock = (TickTock + 1) Mod 3
End Sub

Private Sub Form_Load()
    AutoRedraw = True
    BeginPath hDC
    Circle (40, 30), 20
    Circle (150, 35), 10
    Circle (250, 20), 5
    CurrentX = (ScaleWidth - TextWidth(OUTPUT_TEXT)) / 2
    CurrentY = (ScaleHeight - 1.25 * TextHeight(OUTPUT_TEXT)) / 2
    Print OUTPUT_TEXT;
    Circle (260, 140), 15
    Circle (75, 160), 10
    Circle (200, 180), 5
    EndPath hDC
    SelectClipPath hDC, RGN_COPY
    DrawWidth = 4
    Paint
    Timer1.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
    AbortPath hDC
End Sub

Private Sub Timer1_Timer()
    Paint
End Sub

Name:  sshot.png
Views: 5
Size:  1.5 KB

Run it to see the effect animation.
Attached Images
 
Attached Files

3d with vb6 (dx7 - rmcontrol.ocx) - SpaceX's Starship SN5

File and/or String Comparisons

$
0
0
CompareFiles

This program highlights four different modules that allow you to compare files or strings for changes. In each case I shell to another program to do the file or string comparison. Rather than re-create the comparison routines, I take advantage of a) the comparisons and presentation are already done and we don’t care whether the user has the 32 or 64-bit versions of the programs installed.

You don’t need all 4 modules. I included them in this sample program so that you could test each one and see which one you prefer. My personal preference is Notepad++, a free text editor available from here that comes in 32/64 bits for Windows.. Another option is ExamDiff, a freeware program available here. It has a Pro version that is not free but this utility uses the free version which is 32-bit.

Another option is WinMerge, a free utility in 32and 64-bit available here. Finally there is Microsoft Word, which is part of the paid Office suite or as a standalone product here. It is not free but is available in 32 and 64-bits. I think it has the ugliest file comparison features but it has the advantage that it can compare files that are not just text files.

I am guessing that OpenOffice and LibreOffice have file comparison routines similar to MS Word but I haven’t checked them out. Word’s routine is sufficiently ugly that I stopped there.

Compare Text on the Clipboard with a File

Use of Notepad++ has an added feature you may find useful. Normally you enter the 2 filenames and the procedure compares the files. However, if you leave one of the filenames blank the comparison will be made between the one file and whatever text is on the clipboard.

Compare Strings

Each of the modules contains a comparison routine for files and a comparison routine for strings. The utility only uses the CompareFiles routines but the CompareStrings routines are available for your use as well.
There are some differences in how the CompareStrings routines work.
When you use Notepad++ to compare 2 strings, no temporary files are made.
When using ExamDiff to compare strings, 2 temporary file are made in the TEMP folder.
When you use WinMerge to compare two strings, no temporary files are made.
When you use MS Word to compare 2 strings, one temporary file is created/used in the TEMP folder.
Sample
In the zip file are File1.txt and File2.txt that are deliberately different in a few areas. Below are the results of doing a comparison in each of the 4 external programs.

Notepad++:
Name:  NotepadPlusPlus.jpg
Views: 38
Size:  24.1 KB

WinMerge:
Name:  WinMerge.jpg
Views: 37
Size:  21.6 KB

ExamDiff:
Name:  ExamDiff.jpg
Views: 37
Size:  19.2 KB

MS Word:
Name:  MSWord.jpg
Views: 37
Size:  23.7 KB
Attached Images
    
Attached Files

A Tooltips Class

$
0
0
ToolTip Class for VB6 Forms

The attached file contains a replacement (or augment) to the ANSI-only, boxy, single-line tooltips provided by VB6. Features of the new class include:

  • Full Unicode support.
  • RightToLeft support for tooltips on controls and the form itself.
  • Multi-line tooltips.
  • Tooltips can have titles.
  • Tooltips can be rectangular or balloons with stems.
  • Some instrinsic controls can have tooltips that cannot be set in traditional VB6 including the form itself, CheckBox, HScrollBar and VScrollBar.
  • If you are not using VisualStyles, you can set tooltip text and background colors and the margins between the edge of the tooltip and the text.
  • You can set the maximum width of the toolbar and if your line of text is wider than that, Windows will determine where to break lines.
  • You can set how long to delay before pop-up, how long to display the tooltip and how long to re-display the tooltip when yo move away and come back.
  • You can quickly update the text n a tooltip.
  • You can deactivate/reactivate any tooltip at any time.
  • You can put a hyperlink in a tooltip and it will show up as such. I haven’t yet figured out to be able to click on it because the tooltip either moves away or disappears when I go after it. I’ll figure it out soon. I suspect I have to fix the tooltip position and keep it displayed a bit.
  • This system is very simple to use. It requires no special files of any kind.
  • No hooks, callbacks or sub-classing is used (Windows does some but we re protected from it) so using these tooltip functions within the IDE is perfectly safe.
  • The module is very small, adding only 16k to your file.


Name:  In IDE.jpg
Views: 23
Size:  25.5 KB

Name:  Compiled.jpg
Views: 20
Size:  23.3 KB

Usage

Include the class module clToolTips in your project. At the top of each form declare it such as this:

Code:

Private myToolTips As clToolTips
Then in your Form_Load procedure set the module and call the NewSetUp procedure:

Code:

Set myToolTips = New clToolTips
myToolTips.NewSetUp Me

At this point, the class module knows all about your form and its controls. It has set default values for each of the variables discussed below. You have several ways of setting tooltips now or at any point in the run. Many controls have a ToolTipText property which you can set at design-time or at run-time. The system used in this class module doesn’t make use of any of those because VB6 uses a different method for showing tooltips. But you have the option of using those old ToolTipText values to set the new tooltips. You can do it for one control using the Sub UseToolTipText or use the sub DoAllToolTips to make new tooltips out of any controls that have a value set for ToolTipText.

The main procedure in the class module is SetToolTip and it allows you to specify the tooltip, whether you want an icon shown and optionally a title.

One of the nifty things about this tooltip system is that you can have multiline tooltips which can occur in two ways. You can specify a maximum width for one or all of the tooltips (discussed below) and if the tooltip text you supply is wider than the maximum tooltip width then Windows automatically looks for spaces to break the lines. Also, quite often you will want more control over where lines break so you can include vbCrLf (or vbNewLine) in your text wherever you want a line break. This gets to be a hassle so you may want to use a shortcut we provide (“``”) which gets converted into a vbCrLf for you. This character is the uppercase of the tilde character just to the left of the “1” key on Western keyboards. You can change this constant in the class module to be whatever you want. I suggest finding some key on the keyboard that you rarely use and put 2 of them in the constant ReplvbCrLf which is defined around line 166.

You can deactivate or reactivate any tooltip at any time with the ActivateOrNot procedure.
You can delete a tooltip by using DeleteToolTip.

Variables

There are some variables that are set to default values but you can change them at any time. Once changed, the variable holds that value until you change it again. For example, if you change the text color of the first tooltip you design you can leave the color value alone and all subsequent tooltips will use the same color.

Beware that some of the variables you can set are ignored if your program uses Visual Styles (themes) because Windows will choose for you. So far, I have found that text color, background color and the 4 internal margin settings are affected by this. BTW, if you are using a control that has the capability to use VisualStyles (like Krool’s VBCCRxx controls), it apparently doesn’t matter if you have VisualStyles turned on or off for a given control because Windows takes over. I think this must be that the tooltip is actually a new window (complete with its own handle) and if VisualStyles are no for the program then the new windows have them turned on as well.

TTForeColor As Long – Sets the text color (ignored if using VisualStyles). Default -1& which tells the system to let Windows choose the text color. You can use any RGB color or VB constants such as vbGreen.

TTBackColor As Long – Background color for the tooltip. Default -1& which means let Windows decide. This value is ignored if using VisualStyles.

TTCentered As Boolean- True => center the text; False => left justify. Default is False.

TTBalloon As Boolean- True => use a balloon with a stem that points to your control. False => Use a rectangle for the tooltip. Default is True.

TTWrapTextLength As Long- This is another method of controlling the horizontal size of the tooltip but this one is based on a width in terms of characters in the tooltip rather than a maximum iwdth in pixels. For example, suppose you set a wide max tooltip of half of the screen width but you had a line of text that you wanted to limit to 40 characters. You could do that by setting this variable to 40. You would not have a wide tooltip; Windows will only make the tooltip wide enough to handle the 40-character width. I don’t use this method much so I hae set the default at 0 which means it is not used. BTW, the code for this was modified from some code Elroy on vbForums gave me.

TTTipWidth As Single- This sets the maximum width of the tooltip expressed in terms of a fraction of the width of the screen with the form and controls. It does not set the width of the tooltip, oonly the maximum. For example, if you set this to 1 you are telling the system that your tooltip can be as wide as the screen but if you set a tooltip with the text “Hello World” the tooltip will be very small. ON the other hand, if you don’t specify line breaks in your tooltip text and the length of the tooltip string is such that it is wider than the maximum toolptip size, Windows will do the line breaks for you and the width of the tooltip will be whatever you have set here as the maximum. If you set this to 0 then there is no text wrapping. The default is 0.3, 30% of your screen’s width.

TTDelayTime As Integer- Sets how long (milliseconds) a pointer must be stationary over the control for the tooltip to pop up. The default is -1 which will use Microsoft’s default time.

TTVisibleTime As Integer- Sets how long the tooltip will display if the pointer is stationary. The default is -1 which means Windows handles it (Windows sets this to be 10 times the delay time above).

TTReshowTime As Integer- Sets the amount of time for subsequent tooltips to appear as the pointer moves from one control to another. The default is -1 which lets Windows handle it (Windows sets it to 1/5th the delay time.

TTMarginsTop As Long- If nt using VisualStyles you can override the Windows defaults and set your own margins for top, left, bottom and right in pixels. If Top = -1 Windows defaults are used for all margins.

TTMarginsLeft As Long- See above discussion. The default is -1.

TTMarginsBottom As Long- See above discussion. The default is -1.

TTMarginsRight As Long- See above discussion. The default is -1.

Name:  Hyperlink Tooltip.png
Views: 22
Size:  31.2 KB
Attached Images
   
Attached Files

VB - SnipSnap: Copy/Cut & Paste Image Areas

$
0
0
Earlier versions of this were called "MaskoMania" but a lot has been cleaned up and additional functionality added.

Basically it is a UserControl to be hosted within a container control with a bitmap image. The user can "lasso" a rectangle to be cut or copied, dragged then pasted.

Code:

'Mouse Actions:
'-------------
'
'When Enabled = True the mouse performs the following actions.  When Enabled = False
'the events pass through with no processing.
'
'On the container:
'
'  Left-click to clear the selection.
'
'  Left-drag then release to establish the selection and copy or cut from the
'  container's bitmap.  See the Cutting property.  A cut operation backfills with
'  the MaskColor.  A very small drag acts like a click.
'
'  Shift-left-click makes Masking = False.
'
'  Shift-right-click to choose the color under the mouse as MaskColor and make
'  Masking = True.
'
'On the control:
'
'  Left-drag to move the control.
'
'  Shift-left-click makes Masking = False.
'
'  Right-click pastes the contents of the control into the container bitmap.
'
'  Shift-right-click to choose the color under the mouse as MaskColor and make
'  Masking = True.

Masking is used to designate a transparent color. Minimalist demo:

Name:  sshot.png
Views: 18
Size:  9.3 KB

There is also another demo in the attachment. It covers a wider set of features available, like passing a snippet from one container to another or loading an external file as a snippet.
Attached Images
 
Attached Files

VB6 Color Picker usercontrol with Save Color Picks

$
0
0
Drop this usercontrol in app and start picking colors. It will save 8 sample colors for you.
Attached Files
Viewing all 1478 articles
Browse latest View live


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