Advertisement

Results for "Author: vesa piittinen"

5_2007-2008 #189123
ObjectCollection

This is a Collection replacement, limiting itself to objects. This is mostly a usable "technology demo", showcasing how to create a feature full syntax compatible replacement of a Collection. By speed this class only competes in a few areas, being much slower in adding new items for an example. Maybe someone takes this over and makes a syntax compatible version that is much faster. **** Features: Add, Clear, Clone, Count, Index, IndexByPtr, Item, ItemByIndex, ItemByKey, ItemByPtr, Items, Key, KeyByPtr, Keys, Ptrs, Remove, RemoveByIndex, RemoveByKey, RemoveByPtr, Swap, SwapByIndex, SwapByKey and SwapByPtr. As you can guess by this listing of features, you can do a whole lot more than you can do with the native Collection (which only has Add, Count, Item and Remove). **** Based on SelfEnum class posted yesterday. Credits to Paul Caton and LaVolpe for their work on SelfCallback.

5_2007-2008 #189124
UniCaption - unicode caption for your forms

By a request here, I was fooling around with different ways of changing a form's caption to Unicode. I've seen commercial controls that take over the drawing routine with some heavy subclassing and other similar poor attempts, which have then broken, if not when theme changes, then by when Vista got released. I started off by figuring out a way to create a custom Unicode window and then make an existing form a child of it, but this got pretty messy and I wasn't very happy with the complexity. However, I had a bug during this process that I by mistake used a non-Unicode version of DefWindowProc, which prevented the caption to be Unicode. And it didn't take me long to figure out that by temporarily changing a window's window procedure any window caption can be made Unicode. So here it is: a very short and clean way to have an Unicode caption in your forms! The code can be pasted directly to your form.

5_2007-2008 #189125
UniMsgBox - message box class

This single class file gives you tons of power in handling the messagebox: you can change the texts in the buttons, you can set the window's icon, you can set the icon shown besides the message and all the the text is understood in Unicode so no more question marks. If you're an advanced coder you can use the provided interface to do practically whatever you like to the message box window! **** Again thanks to Paul Caton and LaVolpe for their work on SelfSub, SelfHook and SelfCallback.

5_2007-2008 #189126
UniSock - Winsock control replacement

A new class implementation of Winsock API. By style close to the native Winsock control and other class implementations such as CSocket and CSocketMaster, so you don't need to learn or rewrite much of existing code. The new and cool part about this class is that it is just one class file. Also, it performs better (by speed) and handles errors a bit more cleanly (you aren't forced to close the socket each time an error occurs). Other speciality is transparent Unicode support: when you switch to text mode, you start receiving TextArrival event instead of DataArrival and start getting individual lines. These lines are automatically Unicode if received line is UTF-8 or UTF-16! ANSI lines require you to use StrConv to get an usable string, thus you have the power on what to do with the raw data before any conversion has affected it. **** Support thread and documentation: http://www.vbforums.com/showthread.php?t=534580 **** Special thanks to Paul Caton and LaVolpe for their work on SelfSub, SelfHook and SelfCallback. **** UPDATE 2008-08-12: Now Vista compatible!

5_2007-2008 #189127
UniControls: Unicode aware controls [2008-06-19]

It is hard to get Unicode in VB6. The biggest reason is the nowhere-to-be-found support in any of the native controls. In the past few years people have been mostly forced to commercial solutions or to move to another language. With UniControls I try to change this by providing some of the most essential tools for working with Unicode. **** This is the summer release. What you find here are a few powerful controls, and some that are still in an earlier level of development, yet useful for many tasks. Included: UniCaption, UniCommand, UniDialog, UniLabel, UniList, UniMenu & UniText, with some additional bonus code. **** NOTE: despite these controls using SelfSub, SelfHook and SelfCallback by Paul Caton and LaVolpe, not all of these controls are Stop button safe. This is because of UserControl's limited OLE interface, which has forced to some IOleInActivePlaceObject hacking, for which there currently is no perfectly IDE safe solution. If I didn't use it, I would have to use complex hooking to capture Enter, Escape, Tabulator, arrow keys and other navigation keys. **** Hopefully you enjoy these controls!

6_2008-2009 #211546
Duplicate characters

This is quite a rare need, but here is a very fast solution for finding out whether there is a duplicate of any specific character within a string. Some people use InStr or InStrB as a solution for finding out a character duplicate, but the drawback is that InStr gets slow very fast if the first few characters are not duplicate characters. Also, if there are no duplicates then InStr loops the whole string the amount of length of the string, which can mean hundreds of times at worst case scenarios. The project provides two functions: HasDuplicates and HasDuplicatesM, the latter is class wrapped. The first one is a straightforward InStrB version. The second uses bitmasking in a Long array as well as safe array tricks to get Integer array access to the characters of the given string. Both functions return a character position of the first duplicate they find, however the results between the functions are always different, because InStrB version returns the first character while the safe array version returns the duplicate. InStrB version can be changed to work the same way. This code was requested at VBForums, I don't know why, but I made it anyway. The code should have enough comments for people to learn some advanced VB6 memory tricks.

6_2008-2009 #211547
Small tips: validate control array index

I've seen many ways to check whether a certain control index exists in a control array, where all indexes are not filled. For example, you could have a control array of labels with indexes 0, 1 & 3. I guess one of the most common ways to check for this is to use On Error, but I've always found resorting to rising errors a bad habit to do. A much better another alternative is to loop through the control array using For Each and check for the Index property, but even this becomes a bit silly if you know the index you want to check for and loop the entire control array just to check if it is there or not. The solution: VarType() VarType returns the variable type of default property of a control, ie. VarType(MyLabels(1)) returns 8 (vbString), from Caption property. What makes this usable for sniffing for valid index is that VarType returns 9 (vbObject) for invalid indexes! There is no control that returns an object in their default property, making this a perfectly safe method to check if an index exists or not.

6_2008-2009 #211548
Hex string & byte array conversions

These functions convert hex strings from/to byte arrays. A quick introduction to each: HexStringToBytes_A1: one of the most common ways to turn hex string to byte string using "&H" string conversion to a byte value. HexStringToBytes_A2: an optimized version of A1, grabs bigger values in one go and reduces amount of strings created. HexStringToBytes_A1: fills byte array using AscW & MidB$ HexStringToBytes_A2: same as before, but uses the passed string as a buffer instead just for comparison. Slower as creates more strings than A1. HexStringToBytes_C1: uses Windows CryptStringToBinary API. HexStringToBytes_S1: uses a lot of advanced VB6 tricks to achieve the greatest speed. API just can't compete with this one. HexStringToBytes_F1: uses advanced VB6 tricks like last one, but allows for any formatting in the passed hex string (such as spaces, line changes or anything else – simply looks for any valid hex pairs it can find). Shortly put: the C1 and F1 functions can parse "41 00 42 00 43 00", with formatting. The others only accept "410042004300", no formatting. Those hex strings would convert into a byte array: B(0) = 65 B(1) = 0 B(2) = 66 B(3) = 0 B(4) = 67 B(5) = 0 Or "ABC" as a string (Dim S As String: S = B). There are also functions working the other way around, BytesToHexString_C1 & BytesToHexString_F1. C1 is a version using CryptBinaryToString API while F1 is an optimized function that allows for custom output formatting! You can have any kind of formatting: none at all, just spaces between each hex pair, HTML, XML, C notation, JSON... use your imagination. Not only that, the F1 version is way faster than the C1 version with the exact same output! The following tricks are generally used for speed in the S1 and F1 functions: Safe arrays: VB6 stores arrays internally as safe arrays. The function creates "fake" Long and Integer arrays. Integer array for accessing the string data (1 character = 2 bytes = Integer) and a Long array for memory manipulation (PutMem4 & GetMem4 replacement) as well as saving the decoded hex string to the byte array. SysAllocStringByteLen: this API creates a BSTR and it does that very fast, especially if pointer is set to 0, in which case you get any free point from memory. That memory is not touched in any way except for setting up the minimal BSTR structure information (4 bytes string length & 2 bytes null terminator). This memory is not given to a string however! Instead it is given to the resulting Byte array. Why? It saves an unnecessary step of nullifying all the bytes that are reserved, and this always happens if you just ReDim an array. Long is the fastest datatype in VB6 in current processors. This is why a Long array is used to store the new bytes into the Byte array instead of just using it directly. Summa summarum: these functions should give good knowledge for anyone who wants to understand how memory can be handled so that you achieve better performance code in VB6. It isn't pretty though.

6_2008-2009 #211549
Comma-separated values CSV parser

There is a problem with most of the CSV parsers/readers out there: they do not follow RFC4180. Most handle quotes and comma delimiters properly, but can't handle line changes within quotes. Additionally most of the codes are on the slow side, practically dying if you happen to have a CSV file that goes a few megabytes in size. This procedure is somewhat optimized for speed so a few megabytes is a no-issue. Detailed information at http://www.vbforums.com/showthread.php?t=604031

6_2008-2009 #211550
SelfTimer 1.1

This is a self-contained timer class module. This means there is only one class module required, thus no external module file. This has been achieved by adapting SelfCallback code by Paul Caton and LaVolpe, but this time around I've simplified the code as the requirements in this kind of a class are minimal. Thus the code is much shorter and may give a better picture for some people on what is required for SelfCallback. Naturally the timer is IDE safe so you can hit pause and stop without a worry of crashing. **** Update 1.1: the code is now shorter and faster, code adapter from Paul's Universal DLL Caller. Now all code of interest is in Private_Start and Private_Stop.

6_2008-2009 #211551
UniText RC3 & UniList RC1 [2008-06-14]

Unicode textbox and listbox. On these controls I've attempted to mimic the behavior and features of the native controls, but also give much more power by implementing much more of the native features provided by the Windows API. Despite the focus being on implementing Unicode aware versions of the native controls, you can find much more power than just the Unicode. **** These Release Candidates are released outside the main UniControls release for bug testing and comments - thus I'd like to hear of any problems or oddness you may encounter with the controls so that I can fix them before compiling the main UniControls release (thus the next UniControls release is to be considered stable). **** UniControls main release: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=69738&lngWId=1

6_2008-2009 #211611
Minun Progress Bar 1.8

This is the coolest Progress Bar control you have seen out there. Includes many nice features. Can do colorfading, text scrolling, borderstyles, can be set vertical...anything you can think of. Besides that, the code is very efficient and fast. A good example on how an ActiveX / OCX is made and what it needs.

6_2008-2009 #211612
Minun Progress Bar Deluxe 0.9

This is a new cool progress bar control. I've been doing it two days, based partly on my previos progress bar (I submitted it now already as I'm doing my military service and are therefore limited in time). Though this one is different by looks and is also improved by speed. At the moment the control is not complete, there are properties that are not yet finished. Despite this fact, the control does work. I wish you like that control and that it's customizable :) You can change borders' style, all the colors (15 different), direction (right, up, left, down), set text on it, custom done text and so on.

6_2008-2009 #211613
Minun Progress Bar 2

The best progress bar on PSC: it's fast, it looks cool and it's stable. All you need when it comes to showing a progress. Includes: 1) colors and colorfades! 2) use any font, make it appears as you want 3) you can use seven different borderstyles 4) make the bar grow up, down, right or left 5) Blending (changes color opacity or CosSin mode makes weird colors!) 6) Set the caption just like you want it to be 7) ManualRefresh for optimal usage: if you change colors a lot or do other big changes at a time, you might want to refresh the bar only when you wish 8) Min, Max and Value as big or small as you want 9) You can change parent easily with SetParent 10) enough events: make it a command button as well! 11) clear, optimized code: learn how things can be done fast in VB. Also great example on how to make an ActiveX control with VB. If you like it, please vote & rate :)

6_2008-2009 #211614
UniLabel 2.3 - Unicode label

Enhanced label with Unicode support. Copy UniLabel.ctl and UniLabel.ctx to your project's path and add the control into the project! Thanks to Paul Caton (SelfSub), Ralph Eastwood (for fixing SelfSub 2.1 bug) and Zhu Jin Yong (for UnicodeStrings.res and sample code to use it). Read special_features.txt for more information! | UPDATE 2.2 - 2007-11-19 - SelfSub fixed to version released by LaVolpe, thus finally fixing the crash issues! | UPDATE 2.3 - 2007-12-05 - BackStyle works now, some additional font properties added to ease font manipulation.

6_2008-2009 #211615
InBArr and InBArrRev - searching strings from a byte array

This code seeks from the end of a byte array trying to find a matching text. Why? Well, handling byte arrays is much faster than handling strings. So, if you needed to parse data real fast and a lot, it would be benefical to do it using a byte array instead of a string. My starting point to this was rather simple: do the search faster than InStr and InStrRev. Beating the latter was easy: InStrRev isn't of the fastest build-in functions in VB. With InStr I had to taste half of a defeat: it just is superb when it can search in BinaryCompare. But, what if we wanted to do TextCompare? Well, there InBArr and InBArrRev beat real badly both InStr and InStrRev! Anyways, I hope somebody finds this submission helpful. I'm sorry I didn't comment the code as well as I could/should have, but I hope it doesn't matter as the code should be rather flawless on what it does :) Comments and votes welcome, as always!

6_2008-2009 #211616
InBArrBM: byte array searching improved by heaps

This code makes it possible to search byte arrays. You can search in ANSI (textfiles) or Unicode mode (native VB strings) and the function supports vbTextCompare. The search keyword is passed as a normal string for ease of use. *** This function is somewhat a proof that you can make fast stuff with native VB6 code: with a proper search algorithm even the super fast InStr can be beaten in binary compare! The function uses Boyer-Moore algorithm as its base of searching when keyword is longer than two characters. The function will perform faster if the keyword doesn't change often, as its prosessing speed is heavily based on intelligent keyword indexing. The function will also easily beat InStr when searching for a long keyword within a very long text. The code doesn't use API or TLB to help; it would be possible to increase the speed even further with the help of API and TLB. I didn't want to confuse with the use of those methods. *** The function code is commented so it should be possible to follow how it works. I've spent some time to figure out this function with this much performance, so I hope to get votes - the code should be very useful to anyone who wants to search stuff FAST :)

6_2008-2009 #211617
InBArr - now supports Unicode!

These functions perform a search like InStr within a byte array. Accessing byte arrays is much faster than accessing strings, but there aren't many tools provided in VB to handle the arrays. So here you have something: InBArr and InBArrRev, which can search byte arrays with a string keyword in both Unicode and ANSI modes. *** NOTE: you probably don't have a file named C:\hotfix.txt, so you have to edit Form_Load so you can try it. *** Votes welcome :)

6_2008-2009 #211618
EruLabel

This is a Label replacement control that gives you some limited CSS features (BorderRadius, Border, Margin, Padding, Opacity) and Unicode support. Rounded corners are limited because they are implemented using Windows API RoundRect which doesn't give the nicest results in every case.For a more complete description visit VBForums thread: http://www.vbforums.com/showthread.php?t=626737

6_2008-2009 #211640
Valid & fast TrimNull

While I think these TrimNull functions are a bit silly business, I guess they're mostly used due to lack of understanding of Windows API return values or of the file that is being processed, here you can find proper implementations of the LTrim & RTrim equivalents for NULL characters. Instead of InStr of any kind the string is processed as Integer array, without making a new copy of the string. This allows full control over the validation process and thus string is properly parsed from any NULLs at the end or beginning of a string. A test program is included for comparison which shows the bugs in other implementations. Also a bit fuzzy logic RTrimZZ is included: it is fast, but it is mostly dedicated to cases where you expect a buffer full of NULL, except for the actual data at the beginning of the string. The functions are long but fast.

Languages
Top Categories
Global Discovery