Sunday, November 14, 2010

Use XP Icons in VB6 Apps

This code shows how you can use Windows XP style icon (32-bit alpha icons) in your VB 6 application. VB6 only supports icons up to 24-bit true color and this code shows the workaround.



[Download]

Temporarily Disable AutoRun

This code shows how you can temporarily disable autorun using your VB6 application.

[Download]

Drop Shadow on Form

This code shows how to add drop shadow to you VB6 form without using any subclassing. All using Windows APIs. Just 8 Lines of code.

[Download]

Add Build Button to VB6

Ever wished you had a 'Build' button on your VB 6 toolbar just like VC++, now you can add a build button to your VB 6 toolbar, without using any addins.



[Download]

Tuesday, November 9, 2010

Draw System Icons

This code shows how you can Draw System Icons like - Critical, Exclamation, Question, Information and new Shield icon introduced in Windows Vista, 7.



[Download]

Sunday, October 10, 2010

Monday, September 27, 2010

Detect 64-Bit Windows

This code shows how to Detect if you are using 64-Bit Edition of Windows in VB6.

[Download]

Disable DEP

DEP (Data Execution Prevention) is a new feature that was introduced with Windows XP SP2 and above, to prevent running of malicious codes, it marks certain memory locations as non-executable. But sometimes it creates problem with applications that are not doing anything harmful and they crashes. In XP SP3 and above Microsoft introduced new APIs that allow us to disable or enable DEP on our applications. This code shows how you can disable or enable DEP at runtime for your applications.

'API In General Declaration Section
Private Declare Function SetProcessDEPPolicy Lib "Kernel32.dll" (ByVal dwFlags As Long) As Long

'To Disable DEP
SetProcessDEPPolicy(0)

'To Enable DEP
SetProcessDEPPolicy(1)

'Note: Once Enabled Using API you cannot disable it Again
More on MSDN
SetProcessDEPPolicy Function [Visit]

New NX APIs added to Vista SP1, XP SP3 and Server 2008 [Visit]

Sunday, September 26, 2010

Draw Text with Shadow

This code shows how you can draw text with shadow. It uses DrawShadowText function in ComCtl32.dll to draw the text with shadow. Only works on Windows XP+ with manifest file.



[Download]

Saturday, September 25, 2010

Add Bitmap to Menus

This code shows how you can add Bitmap to Menus. It works on all versions of Windows. On Windows 95-XP the bitmap size is limited to 13x13 pixels and on Vista, 7 we can use 16x16 pixel bitmap. i have taken this code from MS KB Article 298144.



[Download]

Sunday, September 19, 2010

Cool Form Closing Effect

Just a snippet I wrote. Put this code in Form Unload event to test.

'---
Dim i As Long
Me.Top = (Screen.Height / 2) - (Me.Height / 2)
Me.Left = (Screen.Width / 2) - (Me.Width / 2)
For i = Me.Left To (Screen.Width / 2) Step 10
Me.Height = Me.Height - 15
Me.Width = Me.Width - 20
Me.Left = Me.Left + 100
DoEvents
Next
Unload Me
'---

Friday, September 17, 2010

SOAP Controls for VB6

SOAP is a protocol for accessing Webservices.

PocketSoap
It is a SOAP client COM component for the Windows family
[Visit Website]

Microsoft SOAP Toolkit 3.0
[Visit Website]

Microsoft SOAP Toolkit 3.0 Redistributable
[Visit Website]

Saturday, September 11, 2010

Thursday, September 9, 2010

Tools: List of useful VB6 Add-Ins

Here is a list of few very useful VB6 Addins which provides many features.

vbAdvance
vbAdvance is a Visual Basic Add-In which gives access to advanced build features and many IDE convenience features. You can create Console Applications, Exports Function from VB6 DLLs, Create Resource-Only DLLs and more.
[Visit Website]

Visual Basic 6.0 Procedure Sort Add-In
[Visit Website]

Smart Indenter v3.5
Smart Indenter is a utility to tidy up VBA code by rebuilding the indentation of each line.
[Visit Website]

Sunday, September 5, 2010

System Folder Locations

  • Windows 95, 98, ME
    • System Folder
      • c:\windows\system\ = 32-Bit System Folder
  • Windows NT4, 2000, XP, Vista, 7
    • 32-Bit Windows
      • System Folder
        c:\windows\system\ = old 16-bit system folder
        c:\windows\system32\ = 32-bit system folder
      • Program Files
        c:\program files\ = Program Files
    • 64-Bit Windows
      • System Folder
        c:\windows\system32\ = 64-bit System Folder
        c:\windows\SysWOW64\ = 32-bit System Folder
      • Program Files
        C:\Program Files\ = 64-Bit program files folder
        C:\Program Files (x86)\ = 32-bit program files folder
Really confusing and complicated. This is for information purpose only, the location should never be hard coded.

Monday, August 23, 2010

Flash Control Error in VB6

There has been recent news about Adobe Flash Control causing problem in VB6 projects. The last version of flash which didnt had any problem with VB6 was Flash10e.ocx it seems all version after that are having the same problem.

Problem
When we try to save a form containing a flash control, VB6 shows an error message.
---------------------------
System Error &H80004005 (-2147467259). Unspecified error
---------------------------

If we open an old project which already have a flash control, there is no problem in saving or compiling the app as long as we dont open the form containing the flash control.

*Adding Flash Control or Adding any control to a form having a flash control
*Opening a form with flash control and/or changing property of existing control

And then trying to save it produces errors.

Solution
Downgrading to flash10e.ocx seems to fix the problem. Flash10f.ocx, Flash10g.ocx, Flash10h.ocx, Flash10i.ocx (the latest) all having the same problem. i tested all these controls.

Fortunately its not happening at runtime. And if it ever happens in the future then solution would be to use Reg-Free COM Manifest file and include the older version of Flash control with your application.

Step 1: Uninstall flash, we need to use the adobe flash uninstaller, because the flash installer leave a check in the registry and doesnt allow us to install an older version. so 1st uninstall flash using the instruction provided here

Step 2: Getting Old Version. oldapps.com has Flash10d.ocx installer, download version 10.0.42.34 from there OR Adobe provides old version of their player on this page, you need to download the fp10_archive.zip 157 MB zip file and then go to \10r45_2 folder to find flashplayer10r45_2_winax.exe which is the Flash10e setup.

fp10.1_archive.zip
\10_1r53_64 = Flash10h.ocx
\10_1r82_76 = Flash10i.ocx

fp10_archive.zip
\10r32_18 = Flash10c.ocx
\10r42_34 = Flash10d.ocx
\10r45_2 = Flash10e.ocx

Searching in Adobe forum here i found many people having the same problem. If someone see this blog post and have any solution then please suggest. Thanks!

Update: Sep 6, 2011.

These workaround dont require you to downgrade the control and will work on any flash version installed.

Workaround 1: For compiling existing application. If you have a multi-form application then you can safely compile the application If you dont open the form containing the flash control.

Workaround 2: Manual Edit method for adding flash control to new app. Add and code the flash control, then remove the control, then add a picturebox with same name as your flash control, then save and exit VB6 IDE. now open your VB Form in notepad and find the picturebox control replace the picturebox code with the code below, modify the top, left values and also other value you want to change.
ShockwaveFlashObjectsCtl.ShockwaveFlash Flash1
Height = 3615
Left = 360
TabIndex = 1
Top = 960
Width = 4815
_cx = 8493
_cy = 6376
FlashVars = ""
Movie = ""
Src = ""
WMode = "Window"
Play = "-1"
Loop = "-1"
Quality = "High"
SAlign = ""
Menu = "-1"
Base = ""
AllowScriptAccess= ""
Scale = "ShowAll"
DeviceFont = "0"
EmbedMovie = "0"
BGColor = "000000"
SWRemote = ""
MovieData = ""
SeamlessTabbing = "1"
Profile = "0"
ProfileAddress = ""
ProfilePort = "0"
AllowNetworking = "all"
AllowFullScreen = "false"
End
now move to top of the code and just below VERSION 5.00 add the following line.
Object = "{D27CDB6B-AE6D-11CF-96B8-444553540000}#1.0#0"; "Flash10e.ocx"

save the file, start VB6 and compile your project (without opening the form).

Friday, August 20, 2010

Tools: Resource Hacker

Resource Hacker is a freeware utility to view, modify, rename, add, delete and extract resources in 32bit Windows executables and resource files (*.res). It incorporates an internal resource script compiler and decompiler and works on Win95, Win98, WinME, WinNT, Win2000 and WinXP operating systems.

[Homepage]

Tools: Installers

The Package & Deployment Wizard that comes with VB 6.0 for making setup for software is outdated and looks unprofessional. Here is the list of some alternatives.

InnoSetup
Powerful script based installer creator [Homepage]


ISTool
GUI front-end for InnoSetup [Homepage]


Nullsoft Scriptable Install System
Another script based installer from the creators of WinAmp [Homepage]

ClickTeam Install Creator
GUI based installer [Homepage]

Updated P&D Wizard
If you still want to use P&D wizard then JSWare provides an updated version of VB's P&D Wizard [Homepage]

Thursday, August 19, 2010

Tools: Right-click OCX Register

This registry file will add Register/UnRegister context menu to all OCX/DLL files so we can quickly register/unregister them without manually using regsvr32. A real timesaver.

[Download]

Thursday, August 12, 2010

How to Install VB6 on Windows 7, Windows 8, Windows 10

Here are the steps on how to Install Visual Basic 6.0 on Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10. These Steps are valid for Both 32-Bit and 64-Bit versions.

Installing
  1. Use notepad and make a 0-byte file named 'msjava.dll' in C:\Windows\ to avoid the installation of MS Java
  2. Insert the CD or Open the folder containing VS6
  3. Right Click setup.exe > Run As Administrator
  4. Ignore the two Compatibility warnings by clicking 'Run Program' and continue the installation wizard until setup asks you to customize which components to install
  5. Click the 'Custom' button and uncheck components which you dont want to install. (like VC++, FoxPro. Dont uncheck Database Components)
  6. After Completing the installation, setup will prompt you to install MSDN Library, Install it if you wish, but its very helpful.
  7. Skip the installation of BackOffice, InstallShield etc
  8. Click Finish to complete the setup
  9. Now run VB6 for the 1st time. Right-click Visual Basic 6.0 shortcut from startmenu > Run As Administrator. This will setup all the registry entries.
  10. Close VB6 and Install Service Pack 6. Thats All!
  11. Restart Windows
Correctly Using VB6 On Windows 7, 8, 10

1. User Account Control (UAC)
VB6 needs to be run with administrator rights or it will not work correctly. For this, Turn-off UAC from the control panel.

Or

If you prefer not to Turn off UAC then set VB6 to open with Admin Rights.
For this
1. Right click VB6 shortcut > Properties > 'Open File Location'
2. Then right click 'VB6.EXE' > Properties > Compatibility Tab > Check 'Run this program as an administrator' > OK

This will make VB6 open with Admin rights.

2. Aero Theme Problem
If you are using Aero Theme then VB6 IDE will behave oddly when you resize/move controls on form, To fix this problem Check 'Disable Desktop Composition' in the compatibility Tab, like we did above. Alternatively, you can also move controls using keyboard, Shift + Arrow Keys to Resize controls, Ctrl + Arrow Keys to Move controls.

Enjoy!

Update:
1. Windows Vista, 7, 8, 10 does not support WinHelp Help files, so some of the control's context sensitive help will not work. You can download an add-on from Microsoft to display Helpfiles.

2. On Windows 8 / 8.1 some users are reporting error at the end of setup, to fix this problem uncheck 'Data Access' at the start of setup.

More
Click here for Official Support Statement for VB6 on Windows Windows 7, Windows 8.

Btw, Visual Studio .NET 2002, 2003 have serious compatibility problems with Windows Vista and 7, They dont even install or run properly. On the other hand VB6 continues to run perfectly on all windows version since Windows 95. That makes a total of Se7ven different versions of Windows!

Note: i found the msjava.dll tip in the VB Newsgroup.

Keywords: How to Install Installing VB6 Visual Basic 6 Visual Studio 6 64-Bit Error Problem

Friday, August 6, 2010

Old VB Site Archives

Collection of some VB Websites which are now closed, viewable using Internet Archive Wayback Machine.

Visual Basic MCI Command Post [Visit]

activevb.de Archiv-Project [Visit]

Paul's Visual Basic Code Examples [Visit]
Closed Site: http://www.syix.com/wpsjr1/

Thursday, July 15, 2010

MS Closed Newsgroups

Microsoft recently shutdown their newsgroup server, and asked users to move to their online forums for community help. But people can still access newsgroups using a 3rd party news-server or even google groups.

Article: VB Community Transition

How to Access Newsgroups?
* Go to eternal-september.org or aioe.org
* Register an account and change server in your Newsreader.
* and join comp.lang.basic.visual.misc or microsoft.public.vb.general.discussion

Note: You can also use Google Groups but we cannot access it using a newsreader. Detailed Instruction here

ClassicVB Users Regroup at comp.lang.basic.visual.misc

Thursday, July 8, 2010

VB6 Petition to Microsoft

A petition to Microsoft to continue the development of unmanaged (Non .NET) version Visual Basic and Visual Basic for Applications.

http://www.classicvb.org/petition/

Please sign the petition and share the link with your friends.

(14,444 signatures as of now)

Modern Look to your Apps*

How to Give Modern Look to your VB6 Applications

*Topics*

Toolbar:

OfficeMenu:
http://www.teebo.com/OfficeMenu.htm

MDI Tabs:
http://www.teebo.com/tabbed-mdi.htm

Skinning:
http://www.skincrafter.com $199
http://www.codejock.com/products/skinframework/ $149

Tools: ThunderVB

ThunderVB is an add-in for VB6. ThunderVB let's you embed Asm and C instructions directly in you VB source programs. Furthermore ThunVB let's you create a true StdCall Dlls. Moreover ThunVB can extend VB IDE to a basic Asm/C code editor. That means it can do syntax-highlighting of Asm/C keywords and supports intelli-sense for InlineAsm code as well.



http://sourceforge.net/projects/thundervb/

http://www.freewebs.com/hardcorevb/tvb.html

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=62038&lngWId=1

Sunday, July 4, 2010

VB6 Updates

  • VB 6 Runtime Files
    Run-time files are required by all applications created with VB6
    OS:
    Windows 95, 98, ME, NT4, 2000, XP
    [MS Download Page] [Download]
  • VB 6 Service Pack 6
    Latest update to VB6 IDE
    [Download]

VB6 Common Controls Update
This is an update for the VB6 Common Controls: mscomctl.ocx and comctl32.ocx. Install this update after installing Service Pack 6, if you are having issues with Comctl32.ocx Listview control. You dont need to install this if you have already installed the cumulative update above.
Date: Nov-2005
[View KB Article] [Download]

Which Updates To Install?
Install Service Pack 6, and then May-2012 (KB-957924) Update. Thats all. May-2012 update replaces the May-2009 and Oct-2009 Update.

Updates NOT to Install
Never install the Dec-2008 (KB 957924-v1) Cumulative Update, it is very buggy according to Make My Manifest blog.

Further Reading:
http://www.vbforums.com/showthread.php?t=550276

VB6 Alternatives

Here is my comparison of VB6 Alternatives. The exe size mentioned here is of a typical hello world application.


---Paid---
RealBasic [Homepage]
Cost: $99 for one OS, $299 for Pro
Cons:
1. This is a complete package but there are still some problems with the IDE, the IDE lacks good intellisense support, you have to press Tab to mimic the intellisense and there are no tooltips for control properties while coding, instead this information is displayed in the statusbar.
2. Not that good property pages.
3. Large exe size (about of 3.2 MB)
Pros: Cross Platform, COM support

PowerBasic [Homepage]
Cost: $199 for Compiler + $99 for GUI Designer
Cons: Separate Compiler and GUI designer, Expensive
Pros:
Small exe size (about 75KB), No Runtimes, COM support.

KBasic [Homepage]
Cost: Euro 25
Cons: No ActiveX Support, Large Runtime size (about 30 MB)
Pros: Cross Platform, Syntax Compatible with VB6

PureBasic [Homepage]
Cost: Euro 79
Pros: IDE Available for Multiple Platforms
Cons: No COM support, Confusing Project Management

LibertyBasic [Homepage]
Cost: $60

---Free---
JustBasic [Homepage]

FreeBasic [Homepage]
Pros: Free, Multiple IDE/GUI Designer Available

Jabaco [Homepage]
Description Jabaco is a Basic language compiler closely based on VB6 syntax that generates 100% Pure Java bytecode that runs on the Java VM, and includes a GUI builder and IDE.

Tools: Virtual PC 2007

Virtual PC 2007 allows you to run multiple operating systems at the same time. very good tool for testing you app.

[Virtual PC Homepage] [Download]

Saturday, July 3, 2010

Tools: Mouse Wheel Add-In

Here are a list of few VB6 Addins which adds mousewheel scrolling support to the VB6 IDE.

MS Mousewheel Addin - This addin is released by Microsoft, they have also released source code for it. [Download]

FreeWheel - This is another Addin which does the same thing and comes with more features. [Download]

VBScroll - This is another Addin which does the same thing and comes with few extra features like Horizontal Scrolling [Download]

Add-Ins: MZ-Tools

MZ-Tools 3.0 is a freeware add-in for Visual Basic 6.0, Visual Basic 5.0 and the Visual Basic For Applications editor (provided by a 32-bit VBA-enabled application such as those in Office 2000-2010) which adds several productivity features to the IDE.

You can download it from www.mztools.com

Tools: Make My Manifest

Make My Manifest is a tool to generate manifest files for your application so that you can use ActiveX controls without registering them first, aka Reg-Free COM.

[http://mmm4vb6.atom5.com]

Tools: API-Guide

API-Guide is a API database which lists all API example on allapi.net in a easy to use offline tool. API-Guide has over 900 functions, all documented, and explained with an example.

[Download]

Tools: API Viewer

If you work with API, you've probably noticed that the win32api.txt file that comes with Microsoft's API Viewer is totally out of date. This file is based on the Windows95 header files, and with the arrival of Windows 98, Windows 2000, Windows ME and Windows XP, many new functions were created.

ApiViewer is a replacement for Microsoft's API Viewer. The data-file is based on the latest Windows XP header files, so that means you get access to approximately 6500 functions and 55600 constants! Win32api.txt has approximately 1500 functions and 5000 constants.

[Download]

Hello

Would try to update this blog from now. many links are broken like platnet source code and many websites shutdown.