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

Get The Current Hebrew Date using Visual Basic 6.0 and mscorlib

$
0
0
Most systems have the Microsoft.NET Framework installed. This Visual Basic 6.0 program shows how to call functions from the mscorlib.dll (mscorlib.tlb) from Visual Basic 6.0 to obtain the current Hebrew date.

Code:

' This is a Visual Basic 6.0 program, that demonstrates how to get the current Hebrew date,
'  using the .NET mscorlib.tlb
' Project -> References -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb
'  on my Windows Vista system
Private Sub Main()
  ' Uses Karl Peterson's MConsole.bas, available from http://vb.mvps.org/samples/Console/
  Dim Hebrew As New mscorlib.HebrewCalendar
 
  TheYear = CStr(Hebrew.GetYear(Date))
 
  ' TODO: Expand for inclusion of all month names
  Select Case Hebrew.GetMonth(Date)
  Case 6
    TheMonth = "Adar"
  Case Else
    TheMonth = CStr(Hebrew.GetMonth(Date))
  End Select
 
  TheDay = CStr(Hebrew.GetDayOfMonth(Date))
 
  ' Uses Karl Peterson's MConsole.bas, available from http://vb.mvps.org/samples/Console/
  Con.Initialize
 
  ' You can use a MsgBox here if you don't use MConsole.bas
  ' MsgBox TheMonth + " " + TheDay + ", " + TheYear
  Con.WriteLine TheMonth + " " + TheDay + ", " + TheYear
End Sub

The code above does not test for leap years, but that can be determined using the IsLeapYear Method.

The HebrewCalendar Class has these and many more properties and methods.

VB6 Simple Property-Grid (ADO-Rs-Binding)

$
0
0
Just a very basic Property-Grid, thought as a base for your own enhancements.

The two User-Controls (ucPropertyGridStripe and ucPropertyGrid) contain in Sum only about 100 lines of Code,
so it's still relatively easy to understand how everything plays together - before you adapt the thing to your
own purposes (e.g. currently only plain-textfields are used, but depending on the Rs-Field-Type, a CheckBox
could be shown for Boolean Rs-Fields, etc.).

Nonetheless, the small thingy already scrolls properly - it already contains an .EnsureVisible method and
it reacts to changes on the outside Rs - and it raises Field-Change-Events appropriately - that's what the
small Demo-Form is trying to show.

Download here:
http://vbRichClient.com/Downloads/Si...opertyGrid.zip

and the usual ScreenShot:



Olaf

VB6 lightweight PNG-Controls (4-State-PngButtons and a moveable Png-Image/Sprite)

$
0
0
The small Demo shows a lightweight Implementation of GDI+ based Png-Handling,
encapsulated in two small and resource-friendly windowless Controls...

It's a variation (with some improvements) from my other CodeBank-post here:
http://www.vbforums.com/showthread.p...ely-per-WIA%29

One is for (Moveable) Images or Sprites -> ucPngPicture.ctl - the other is to handle
"4-State-Png-Image"-based Buttons (Normal, Hovered, Pressed, Disabled) -> ucPngButton.ctl.

Here's a ScreenShot, what the combined 4-State-Button-Pngs look like:


The Button-States-PngResources could also be adjusted to work with 5 States (e.g. when
you want to introduce also a "Focused" State - its just about enhancing the Png-Resource
about the new "State-Area" - and adding a few lines of code, which ensure the correct
Offset within the Controls "Refresh-Drawings"-routine.

To incorporate it into your existing Projects, you will have to include the 4 Files:
  • modPngCache.bas <- only contains a global Definition of PngCache As cPngCacheGDIp
  • cPngCacheGDIp.cls <- the GDI+ Handling (APIs and conversion into a 32Bit VB-StdPicture-DIB)
  • ucPngPicture.ctl <- the Png-Image- or Png-Sprite-Control
  • ucPngButton.ctl <- the (currently) 4-State-Png-Button-Implementation


Here's the Download-Link:
http://vbRichClient.com/Downloads/Pn...AndButtons.zip

The Source-Code within the Form is quite small (BTW, also demonstrating the
usage of VBs Usercontrols built-in HitTest-capabilities):

Code:

Option Explicit

Private Sub Form_Initialize() '<- early loading of all Png-Resources under their Keys (before Main-Form_Load)

  'here we add true Alpha-Channel-Png-Images to the cache (with 4 Button-States per Image)
  PngCache.AddImage "Home", App.Path & "\Res\Home.png"
  PngCache.AddImage "Seven", App.Path & "\Res\Seven.png"

  'now we cache another Alpha-Png, which will be rendered in a moveable Control
  PngCache.AddImage "Tucan", App.Path & "\Res\Tucan.png"
End Sub

Private Sub Form_Load()
  'just VBs normal LoadPicture-Function, providing the Forms BackGround-Img from a *.jpg
  Set Picture = LoadPicture(App.Path & "\Res\Checker.jpg")
End Sub

Private Sub Form_Resize() 'this adjusts the two Btns, which share the "Seven"-Key at the LeftBottom-Form-Edge
  ucPngButton(3).Move 7, ScaleHeight - ucPngButton(3).Height
  ucPngButton(4).Move 54, ScaleHeight - ucPngButton(4).Height
End Sub

Private Sub Form_Paint() '<- now that's iportant here for flickerfree rendering
  'to receive Form_Paint-Events, the Form needs to remain at the default (AutoRedraw = False)
  'then we need to ensure, that each and every Png-Usercontrol we use on this Form, gets refreshed

 
  '...starting with the Z-ordering "Bottom-Up" (the first refr. ucPng-Ctl is "bottom-most", a.s.o.)
  ucPngPicture1.Refresh
 
  Dim i As Long 'after the movable Png-Picture-Ctl above, we follow up with our 4 Png-Buttons below
  For i = 1 To 4: ucPngButton(i).Refresh: Next
End Sub

Private Sub ucPngButton_Click(Index As Integer)
  Caption = "ucPngButton " & Index & " -> " & ucPngButton(Index).Key
End Sub

'just a demonstration of the HitTest-Event (which by default, when not explicitely handled - would
'detect a Hit on the current *rectangular* Ctl-Region) - here we adjust the Hit-Detection with the
'"circle-formula" -> R = Sqr(x^2 + y^2), to the circular region of the round Buttons, so when you move
'the Mouse diagonally across the Button-"edges", it should give a hit only when you cross the circumference

Private Sub ucPngButton_HitTest(Index As Integer, X As Single, Y As Single, HitResult As HitResultConstants)
  Const R = 20 '<- we define a Radius of 20 Pixels for our userdefined HitTest
  Dim cx: cx = ucPngButton(Index).Width / 2
  Dim cy: cy = ucPngButton(Index).Height / 2

  HitResult = IIf(Sqr((X - cx) ^ 2 + (Y - cy) ^ 2) < R, vbHitResultHit, vbHitResultOutside)
End Sub

And the appropriate ScreenShot of the small Demo-App:


Have fun with it...

Olaf

VB6 Restoring NWind.db InMemory from ResourceBytes (without touching the FileSystem)

$
0
0
Sometimes there's the problem, to ship your App with a less than simple store, which contains "structured static Data" (e.g. a small catalogue-DB or a DB which contains the word-archives for your small spellchecker or something like that)...

If possible you will have the additional requirement, to ship it within your Executable (or Dll or OCX) - directly as a Binary-Resource (a "compiled into" ByteArray if you want).

Ok, one could do that e.g. with a JET-DB - (and compress and encrypt the FileContent into Bytes) - but in this case you'd have to "decrypt and unpack" into the Filesystem, to be able to use your DB-Data from the compiled-in ResourceBytes.

That last step (the FileSystem-Placement) is often not wanted - but the comfort of a DB (fast queries, joins, filters etc.) shall also remain possible - OK - with SQLite as the JET-alternative one can fullfill that need, since it allows true InMemory-Databases.

The following Demo contains a small example which is acting on NWind.db-content and performs both directions:
  1. the "packing-process" from a filebased DB -> ending up with compressed and RC4-encrypted ResourceBytes
  2. and the opposite direction (decryption/decompression/InMemory-DB-Creation from a plain ByteArray)

The Sources depend on the vbRichClient5-Project-Reference (Download available here: http://vbRichClient.com):

Here comes a ScreenShot:



And here the Project-Download-Link:
http://vbRichClient.com/Downloads/SQ...omResource.zip


Have fun with it...

Olaf

Need Advice on SOAP

$
0
0
Hello

I am using Visual Basic 6.0, I have downloaded Microsoft SOAP Toolkit 3.0. I do not have experience in using SOAP, I have been asked to interface with AVAYA NOTIFICATION and they have given me some examples. I really don't know where and how to start with. Please check on the below code and please advise me on what I should do to be able to make it work.

Example of the SOAP request (Email message):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://common.service.ans.sca.aps.avaya.com/">
<soapenv:Header/>
<soapenv:Body>
<com:createMessage>
<arg0>
<attachment>http://148.147.181.48:8080/upload/wavefile.wav</attachment>
<body>fire alret for this building</body>
<channelType>EMAIL</channelType>
<expirationTime>1000</expirationTime>
<fromAddress>admin@ans.com</fromAddress>
<fromName>?</fromName>
<locale>en-US</locale>
<partitionName>default</partitionName>
<subject>Email Alert</subject>
</arg0>
</com:createMessage>
</soapenv:Body>
</soapenv:Envelope>

Thanks

VB6 TLSSend

$
0
0
TLSSend is a email sending program designed to demonstrate multiple methods of sending an email via SMTP.
1. Standard SMTP using port 25.
2. Standard SMTP with PLAIN AUTHENTICATION using port 1025 (May vary with ISP).
3. TLS 1.0 encrypted SMTP through smtp.gmail.com using port 465.
4. TLS 1.0 encrypted SMTP through smtp.gmail.com using STARTTLS and port 587.
5. TLS 1.0 encrypted SMTP through smtp.live.com using STARTTLS and port 587.
6. Yahoo does not support external access to SMTP for freebie accounts.

Normally, email settings would be stored in the registry or an initialization file, but since this is a demonstration program, your specific account details will have to be incorporated into the code.

- Change the generic To: & From: addresses in frmTLS.
- Change the "yourISP" Combo Box items in the frmTLS.Form_Load sub to reflect your own ISP.
- Change the generic account settings in the cmdConnect_Click sub to reflect your own account settings.

This program does not contain any third party controls or libraries, and utilizes the RSA/Schannel library (schannel.dll) that is shipped with all modern Windows Operating Systems. Although the Cryptography routines will work on most Operating Systems, cSocket2 will only work on systems that support dual stack (IPv4/IPv6). This more or less restricts it to Windows Vista or better. For more information on the Cryptographic functions, see:
http://www.vbforums.com/showthread.p...-VB6-TLSCrypto

J.A. Coutts
Attached Files

This Thread is for Nightwalker83...

$
0
0
Here is the Attachment of the proper ActiveX Control that you have requested for me to upload for you. I really hope that you enjoy this, ofcourse that there isn't any kind of viruses that have been attached to it, I have just scanned them prior to uploading them. Please note that there was a reason for me to remove the graphics, music, sound and also the video from this project. But then they have been included into the Resource File for safe keeping. I cannot remember if I have left in the video, sound, music and what not. But then I am totally definatly sure that I have kept the Graphics inside it, for you to use inside only that project, you are allowed to do so, with them and the source code in that project, with that project alone. That is my only request for you to do, fo me. Programmer to Programmer, so to speak...
Attached Files

VB6 applied physics, using the chipmunk-engine (simple Demo for Starters)

$
0
0
This simple "Physics-Engine usage for Starters"-Demo depends on the vbRichClient5.dll,
downloadable here: http://vbrichclient.com/#/en/Downloads.htm

So, before you can run it you will have to unpack the 3 Dlls from the above linked vbRC5BaseDlls.zip
into a Folder (e.g. C:\RC5\)... and then only register (in AdminMode) the vbRichClient5.dll per regsvr32.

There's no need to copy the Dlls into the same Folder where you unpack the Zip of our small Demo-Project here:
http://vbRichClient.com/Downloads/ChipmunkCairo.zip
Meaning you can run all further RC5-based Demos directly from within their Unpack-Target-Folders,
without having to bother again with the (only once) to install RC5-BaseLibs.

The chipmunk Physic-Engine is wrapped up behind easy to use VB-Classes - no need to take care about
handle-freeing or other stuff (when you'd be using the "plain-C" chipmunk-API)...

For 2D-game-developers this should be quite interesting, since it allows all kinds of physics based games,
which involve e.g. true Car-Physics, or the whole class of "Rubberband-based games" - or shooting some Objects
around, which will follow true flight-parables with only a given Impulse... or all kind of simpler games where
Ball-bouncing-Physics are involved.

The Collision-Detection is sophisticated (respecting Mass, Elasticity, Friction, Momentum) though still quite performant,
even with a larger amount of moving Objects or irregularly shaped "fixed-bodies" in your scenes.

This last part, the construction of complex shapes is a speciality I've included in the Wrapper, since it allows
the Construction of any shape-form with ease over simple Cairo-Drawing-Calls (Cairo-Paths) - and that includes
even as complex shapes as rendered Text - the Demo here will already demonstrate, that the Ball-Objects take
even such complex-formed fixed shapes as rendered Text(Paths) seriously in their collisions...

One can see that easily witht a good look at the ScreenShot below... (where the Balls ended up finally after
bouncing around) - they "lean on each other" and rest with their bottoms on the TextChars exactly
(the left Ball on the "dot of an i" - and the right Ball is "hanging" between the highest points of "k" and "h"):



The Drawing-Capabilities of Cairo include SubPixel-based Rendering of Png-based Sprites, as well as
normal Vectordrawn-Shapes ... this (antialiased) SubPixelprecision-output is quite important
especially with slower moving Objects - and cairos internally used Double-Precision matches exactly with
the Double-Precision each of the Body-Shape-Objects is internally repositioned by the Physics-Engine
in each (highres) Timer-Step.

I'll post some more Demos about this Engine, for the moment this simpler one may be sufficient as a
Base for your own experiments (with different Shapes or maybe only some Fiddling with the Parameters,
as e.g. the Gravity - or the Elasticity and Friction of the Balls).

Have fun with it.

Olaf

VB6 NewSocket

$
0
0
The original CSocket/SocketMaster emulated the Microsoft Winsock Control. cSocket2 introduced the newer Dual Stack calls that would support IPv6 as well as IPv4 , but remained procedurally the same. All of them supported the sending/receiving of all types of data (byte, string, integer, long, etc). WSA sockets treated everything as byte data and could care less what type of data it was, and it was up to the higher level programs as to how that data was treated. What I found was that all my programs utilizing cSocket2 used string data, which made a lot of the code used to support data types unused and redundant. Even though the conversion of Unicode string data (16 bit) to byte data (8 bit) was inefficient, VB6 contained a plethora of commands that made manipulating string data relatively easy, and inherently took care of garbage collection.

NewSocket sends and receives string data only. There is only a single conversion made to and from byte data.

I was not happy with the way cSocket2 handled errors, so now all errors are returned to the calling program for handling through the Error Event.

Modern Cryptographic techniques are built on top of TCP/IP, so a new Event called "EncrDataArrival" was added along with a flag to allow incoming encrypted data to be treated differently from plain data.

Originally, the LocalPort(PropertyGet) routine would simply return the value of m_lngLocalPort, which was assigned during the Bind process. However, GetAddrInfo automatically assigns the first available socket on a Connect call (Bind not called), and the routine would return zero. It was changed to use GetLocalPort.

J.A. Coutts
Attached Files

VBA Code

$
0
0
Hi!
I've been trying for a few time to make a sub, on VBA, that writes, in a specific column, " " or 1 depending on the date that is inserted. The thing I can't quite do is:
1 - I have a sheet where the different projects of a company are stored (name, starting date, ending date and person responsible) and where new projects can be added from a UserForm
2 - I also have another sheet were costs from the projects are stored (one line with cost 1 from project 1, another with cost 2 also from project 1 and cost 3 from project 2, etc) and where I can also add a new cost with another UserForm (this cost as also a date that is added, to when it happened)
3 - What I need to do is, on the costs' sheet I need to create a sub that in the last column adds me 1 if the date of the cost added is not a date between the starting and ending date of the project that it corresponds.
Can anyone help me on this??
Thank you very much :)

VB6 - WIA "BlendPaint" Demo

$
0
0
In honor of the death of Windows XP (which means there is no excuse for VB6 programmers to ignore these techniques any more) here is an example of some of the simple things you can use the Windows Image Acquisition Library 2.0 for.

WIA can do other things for you as well such as trivially extract JPEG EXIF data including thumbnail images and perform many scanner and still-image camera operations. In particular the loading of PNG or TIFF images and saving images in GIF, JPEG, and TIFF are provided via WIA.

However this sample program only shows a few of the things WIA can help you do with little code.

If you can find the old WIA 2.0 SDK you can deploy the library back as far as WinXP SP1 machines if necessary. However the download was pulled from Microsoft Downloads some time ago.


This demo illustrates a couple of things such as image loading with WIA, extracting a Form or PictureBox image to a WIA ImageFile object for use in operations such as saving to disk, and simple use of WIA's ImageProcess object's "Stamp" filter for compositing with transparency and PNG alpha blending.

It doesn't go into the details for other filters such as Convert, RotateFlip, Crop, Scale, etc. but those are documented elsewhere. Filters can even be applied in a group to perform multiple operations at once.

By using the persistent bitmap of a Form (and a smaller PictureBox) this demo shows how you can intermix WIA Stamp with VB6 drawing operations in "layers." Note that GIF transparency and PNG transparency and alpha channel blending are supported.

Name:  sshot.png
Views: 82
Size:  55.9 KB

Screenshot of the demo. Note that this capture was compressed down
to 8-bit color and the actual results look better.

Here all of the images are loaded from disk files. However you can also use WIA to load images from custom resources, or even from sources such as downloaded data without writing them to disk first.
Attached Images
 
Attached Files

VB6 - WIA "BlendPaint" Demo - comparison with Cairo-Drawing

$
0
0
The Demo here depends on a reference to vbRichClient5 (http://vbrichclient.com/#/en/Downloads.htm)

Just demonstrating what is needed (coding wise) and what the performance-differences
are - compared with preinstalled MS-system-libs.

Below is all the code which is needed, to achieve the same effect as the nice Demo of dilettante
here: http://www.vbforums.com/showthread.p...aint-quot-Demo

Code:

Option Explicit

Private Sub mnuPGBsCairo_Click()
    Cairo.ImageList.AddImage "BGnd", App.Path & "\background.jpg"
    Cairo.ImageList.AddImage "Ball", App.Path & "\glass_ball.png"

    New_c.Timing True
      RenderPerCairo Cairo.CreateSurface(480, 360).CreateContext
    Caption = New_c.Timing
End Sub

Private Sub RenderPerCairo(CC As cCairoContext)
    CC.RenderSurfaceContent "BGnd", 0, 0
    CC.RenderSurfaceContent "Ball", 20, 200, 160, 120, , , True
    CC.RenderSurfaceContent "Ball", 300, 220, 160, 120, , , True
    CC.RenderSurfaceContent "Ball", -60, -80
    Set Picture = CC.Surface.Picture
End Sub

Performance is about factor 10 better (4-5msec for Cairo-Blending vs. 45-55msec for the WIA-approach).

Here the Download as a Zip-Archive (re-using dilettantes resources):
http://vbrichclient.com/Downloads/WIA_and_Cairo.zip

And a Screenshot:


Olaf

[vbRichClient] Interactive Dartboard Demo

$
0
0
Here's something I put together for fun. It's an interactive dartboard that supports mouse-over and click events.

The idea was that it could become a score-recording application but once I got to this point I thought I'd pass it along to somebody who actually plays darts as I, myself, do not!

This project has one external dependency (not included) that can be downloaded from Olaf Schmidts site: www.vbrichclient.com

If nothing else, the code might serve as a useful learning tool for somebody playing around with circles...

The dartboard, btw, was entirely drawn in code via the Cairo wrapper that vbRichClient exposes - it isn't a PNG file I just threw in there!
Attached Images
 
Attached Files

[VB6] Shell Video Thumbnail Images

$
0
0
Summary

Thumbnail images for video files are accessible via Shell32's Automation (i.e. ActiveX) interface.

These can be obtained using a ShellFolderItem object's ExtendedProperty() method. The tough part is that these are returned as PROPVARIANT values and not regular Variants as we know them in VB6. For many ExtendedProperty() return values VB6 can handily coerce the PROPVARIANT to a Variant, even though you can still end up with unsupported subtypes (like unsigned integers of varying lengths).

Here we need to request the property by passing SCID_THUMBNAILSTREAM to ExtendedProperty. In this case it returns a PROPVARIANT with a VT_STREAM content subtype, making it a bit troublesome in that VB6 cannot convert it to a standard Variant.

Luckily that can be done by calling the PropVariantToVariant function, though it handles the situation by converting the VT_STREAM to a Variant's VT_UNKNOWN. Still, the IStream object reference is there and usable.

This particular stream is designed for consumption by GDI+/WindowsCodecs, and isn't a simple PNG or JPEG in a stream. But GdipCreateBitmapFromStream() can read it just fine, and from there you are on your way.


The Code

Most of the code in the sample program relates to a version of my ThumbnailsView UserControl. Without this the program would be a lot smaller, but we don't have many good controls for multi-image display. You almost always end up working with things like nested PictureBox controls and a scrollbar or two and some logic to glue it all together. There is also a funky SimpleProgressBar UserControl for visual feedback.

You can pretty much ignore both of those along with helper modules Picture2BMP.bas, BmpGen.cls, and ScaledLoader.cls that are used by ThumbnailsView.ctl.

Even Form1's code is mostly gingerbread, dealing with picking a folder of video files to fetch thumbnails for. Its ListAttributes() subroutine is the part that enumerates the folder items and retrieves the thumbnails, with the help of GdipLoader.cls to convert the stream into a StdPicture object.

Code:

Private Sub ListAttributes(ByVal FolderPath As String)
    Dim Folder As Shell32.Folder
    Dim ShellFolderItem As Shell32.ShellFolderItem
    Dim GdipLoader As GdipLoader
    Dim ExtProp As Variant

    Set Folder = ShellObject.NameSpace(FolderPath & "\")
    If Folder Is Nothing Then
        Unload Me
    Else
        Set GdipLoader = New GdipLoader
        With SimpleProgressBar1
            .Caption = ""
            .Max = Folder.Items.Count
        End With

        For Each ShellFolderItem In Folder.Items
            If Not (ShellFolderItem.IsFolder Or ShellFolderItem.IsLink) Then
                PropVariantToVariant ShellFolderItem.ExtendedProperty(SCID_THUMBNAILSTREAM), ExtProp
                'Note: vbDataObject value is really VT_UNKNOWN (i.e. 13):
                If VarType(ExtProp) = vbDataObject Then
                    ThumbnailsView1.Add GdipLoader.LoadPictureStream(ExtProp), ShellFolderItem.Name
                End If
            End If
            SimpleProgressBar1.Value = SimpleProgressBar1.Value + 1
        Next
    End If
End Sub


Issues

The first issue is that this isn't speedy. I'm not sure what Shell32 is going through to get thethumbnails even though I had assumed they were retrieved using typical OLE Storages & Streams mechanisms. It almost seems too slow for that though and since it uses video codecs there must be more involved.

The second issue is that depending on the video encoding format and codecs you have installed you might get nice results or a junk image back. I was almost ready to give it up until I realized I had VB6.exe in ffdshow's blacklist on my development PC.

But testing the compiled EXE (and allowing ffdshow use via the Compatibility Manager popup) returned good images from everything I tested but some DIVX formats.

See: ffdshow tryouts or use a search site.

Requirements

As written, the program requires a number of things, including running on Windows XP SP2 or later:

  • GDI+ version 1 - ships in XP and later, deployable back to Win95.
  • PropVariantToVariant() in propsys.dll - requires XP SP2 or later.
  • Microsoft Windows Image Acquisition Library v2.0 - ships in Vista or later, can be added to XP SP1 or later.
  • Edanmo's OLE interfaces and functions typelib (olelib.tlb) - needed for development, not needed at run time. Can be acquired from http://www.mvps.org/emorcillo/en/index.shtml.


By getting rid of ThumbnailsView and using some other multi-image control and associated code you can eliminate WIA 2.0 and Edanmo's olelib.tlb.


The Demo

Running the program you'll see the single Form user interface. It has a status/progress bar, a ThumbnailsView taking up the rest of the Form, and a single menu item "Choose Folder" you use to start the process.

The running progress shows you the current and total folder items being processed. Subfolders and links are skipped, as are files that do not have a ThumbnailStream return value.


Name:  sshot1.jpg
Views: 116
Size:  38.3 KB
Some videos using standard Windows codecs


Name:  sshot3.jpg
Views: 117
Size:  43.6 KB
Some videos that require additional codecs (MP4 mostly).
Work fine when ffdshow is used.


Remaining Issues

In theory all kinds of files ought to return thumbnails this way. However I get nothing useful for music folders, Word document folders, etc. I can only assume that the returned results are in another format this demo rejects (GDI+ Image object?). I'll have to investigate further.
Attached Images
  
Attached Files

visual basic 6 master pack 1 , daily update

$
0
0
i will update this thread if u can post too.:thumb::):p



Move Controls at Runtime


Code:

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2


Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage Command1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub

Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage Command2.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage Text1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub

Private Sub Text2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage Text2.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub


[VB6] Shell Drive Free Space

$
0
0
If you are using Shell objects there are lots of properties you can retrieve describing the filesystem and individual files. However the values returned are often types that VB is not prepared to cope with without some help.

Here we'll look at one of the Volume properties that gives you the capacity and free space for each drive in ssfDrives.


This program fetches the Drives Folder (ssfDrives) and retrieves the PKEY_Computer_DecoratedFreeSpace (as SCID_Computer_DecoratedFreeSpace).

The returned value is a PROPVARIANT, so we first convert it to a Variant for use in VB6.

The PROPVARIANT is empty or a "VT_VECTOR | VT_UI8" value, so if not empty we recast it as "VT_ARRAY | VT_CURRENCY" which is something we can play with in VB6.

Update:

It seems that VB6 can coerce these particular PROPVARIANTs to Variants itself. This saves an API call that isn't available in most pre-Vista Windows installations.

Then we format these values (1.) using normal techniques after scaling by 10000 to convert from our pseudo-Currency values to whole numbers, or (2.) by calling StrFormatByteSize() which produces abbreviated formats in KB, MB, GB, TB units.


You could probably also use PKEY_FreeSpace and PKEY_Capacity in separate calls of the ExtendedProperty() method, but I haven't tested that.


See the program comments: this code won't work before Vista except on XP SP2 or later with Windows Desktop Search (WDS) 3.0 or later installed. Those old systems do not have propsys.dll in them.

Update:

No longer a restriction.

Name:  sshot.jpg
Views: 82
Size:  33.5 KB
Attached Images
 
Attached Files

[VB6] UPrinter - Unicode Printer Class

$
0
0
I looked around and didn't find many working samples of this... actually none at all but lots of questions about non-working code snippets. There may be some out there, and better than this basic one. I just didn't find any.

This version does not deal with top/bottom margins, colors, images, drawing, paper tray or size selection, orientation, etc. It only prints in whole lines (or multiples if you have embedded newlines), long lines should wrap.


I have attached an archive here containing a small demo Project that uses UPrinter.

Utf8Reader is is class for reading UTF-8 encoded text files. It in turn makes use of the Utf8Codec class. For this demo a UTF-8 CSV file is read as a source of sample Unicode text to print.

ParseCSV is here because the sample data is a CSV file and I want to split the data into fields and then print them with Tabs in between.

Each line of text after the first (heading) line is printed twice in this demo. The only purpose of that was to test page boundary overflow detection.


This hasn't been fully tested so it may fail with some printer drivers. As already stated it is an incomplete and minimal example but it should serve as a starting point if you want to implement more functionality.


Name:  sshot.jpg
Views: 128
Size:  51.2 KB


Updates:

New version replaces the earlier attachment here. A few small bug fixes, added properties TopMargin and BottomMargin and method KillDoc.
Attached Images
 
Attached Files

A VB6 Recent Files Lister

$
0
0
Here is a VB6 Recent Files lister. You can remove any entries from the list and the programme also checks that the entries have not been deleted or moved.

It is a simple programme which I hope some will find useful. One comment, do not use it from within the IDE or when VB6 is running. VB6 stores the list at startup and re-writes upon completion.

Enjoy - Steve.
Attached Files

[VB6] Tabulator, Crosstab Class

$
0
0
If you know what cross tabulation is you may have a need for this. If you've never heard of it the chances are this may just be a really confusing bit of code.

Quite often we're dealing with data from a database, and many DBMSs offer a built-in way to do this. For example for Jet/ACE SQL look up the TRANSFORM... PIVOT syntax. Normally this makes use of some aggregation function (SUM(), AVERAGE(), etc.).

This Tabulator class can be used with any data source. This version does not include aggregation support, but instead assumes you have simple unique value to collect for each intersection of Column and Row (i.e. "cell").

It can return rows in ascending order (default) or descending order by RowId value. Columns are always in ascending order by ColName values.


You might add aggregation a number of ways. You could hard-code that into Tabulator.cls or the TabulatorValue.cls (a helper class for value storage).

Or you might modify Tabulator.cls to accept an object reference that offers fixed-named methods such as Accumulate() and Report(). For SUM() aggregation Accumulate() might just add new values to the current sum in a cell, and Report() would jsut return the value without modification. For something like AVERAGE() you might have to add values and increment a count in Accumulate() and then divide in the Report() method.


An illustration may help. This is Project1 in the attached archive. Here we have data like:

Code:

GOLD 01-JAN-2010 70.19
OIL 01-JAN-2010 16.70
SUGAR 01-JAN-2010 44.51
COPPER 01-JAN-2010 2.57
GOLD 02-JAN-2010 68.30
OIL 02-JAN-2010 15.11
SUGAR 02-JAN-2010 49.23
COPPER 02-JAN-2010 5.58
GOLD 03-JAN-2010 70.78
OIL 03-JAN-2010 15.69
SUGAR 03-JAN-2010 48.71
COPPER 03-JAN-2010 9.29
GOLD 04-JAN-2010 69.87
OIL 04-JAN-2010 8.52
SUGAR 04-JAN-2010 43.70

We cross tabulate Price by Date and Commodity and display that (descending) in an MSHFlexGrid control:

Name:  sshot1.gif
Views: 42
Size:  23.9 KB


Project2 is another example, showing how Tabulate can handle complex values which can be arrays or even objects. Here each cell Value is an instance of a two-value class (Price and Volume).

The raw data looks like:

Code:

GOLD 15-APR-2014 74.70 42551
OIL 15-APR-2014 9.69 70748
SUGAR 15-APR-2014 49.28 109303
COPPER 15-APR-2014 12.02 28024
GOLD 01-JAN-2011 67.72 45741
OIL 01-JAN-2011 9.91 72771
SUGAR 01-JAN-2011 40.25 36548
COPPER 01-JAN-2011 6.92 94342
GOLD 02-JAN-2011 72.42 111129
OIL 02-JAN-2011 12.99 29290
SUGAR 02-JAN-2011 41.81 91619
COPPER 02-JAN-2011 2.63 93288
GOLD 03-JAN-2011 70.49 96250
OIL 03-JAN-2011 11.10 76063
SUGAR 03-JAN-2011 48.44 87550
COPPER 03-JAN-2011 11.76 90176
OIL 04-JAN-2011 16.53 107546

We'll tabulate this and report it in another MSHFlexGrid control:

Name:  sshot2.jpg
Views: 33
Size:  88.5 KB


Tabulate works by storing row data as a Collection of row Collection objects, RowId values as a Variant array, and "cell" values as TabulateValue.cls instances, each of which have a Variant property.

Peformance was improved by adding a binary search for doing row insertion. Since there are normally far fewer columns, a linear search is still being used to insert new columns as they are "put" into Tabulator. At this point Tabulator is reasonably fast, and the demo programs spend most of their time populating the grid after tabulation has completed.

It seems to be working properly, but if you find bugs please let everyone know by posting a reply here.

Note:

Bug fixed, reposted attachment.
Attached Images
  
Attached Files

RGB, XYZ, and Lab conversions

$
0
0
This program converts images between RGB, XYZ, and Lab formats. It's quite a large program (due to the 2 huge lookup tables for RGB/Lab conversion), so instead of posting it as an attachment, I've uploaded it to Mediafire, and have posted the download link here.

https://www.mediafire.com/?vdx3uy1z31g21as
Viewing all 1478 articles
Browse latest View live