Wednesday, December 9, 2015

How to register a file in Visual Basic

When develop a software, there must be a supported file requirement, for example: ocx file (*.ocx), dll file (*.dll).
Topic: How to supporting Register File through coding with Visual Basic because many cases that supported files will not run before registered to the (Windows) system.

As an example may be you had experienced about application can't be run or find runtime error after install your software to another computer as long as supporting files are not registered, so how to direct registered supported file through coding? Please follow the below steps.

'Put the following code to the Module Project
Private Declare Function LoadLibraryRegister Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function CreateThreadForRegister Lib "kernel32" Alias "CreateThread" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lParameter As Long, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function GetProcAddressRegister Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As Long, ByVal lpProcName As String) As Long

Private Declare Function FreeLibraryRegister Lib "kernel32" Alias "FreeLibrary" (ByVal hLibModule As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lpExitCode As Long) As Long

Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)

Public Function RegServer(ByVal FileName As String) As Boolean
RegServer = RegSvr32(FileName, False)
End Function


Public Function UnRegServer(ByVal FileName As String) As Boolean
UnRegServer = RegSvr32(FileName, True)
End Function

Private Function RegSvr32(ByVal FileName As String, bUnReg As Boolean) As Boolean

Dim lLib As Long
Dim lProcAddress As Long
Dim lThreadID As Long
Dim lSuccess As Long
Dim lExitCode As Long
Dim lThread As Long
Dim bAns As Boolean
Dim sPurpose As String

sPurpose = IIf(bUnReg, "DllUnregisterServer", _
"DllRegisterServer")

If Dir(FileName) = "" Then Exit Function

lLib = LoadLibraryRegister(FileName)
If lLib = 0 Then Exit Function

lProcAddress = GetProcAddressRegister(lLib, sPurpose)

If lProcAddress = 0 Then
FreeLibraryRegister lLib
Exit Function
Else
lThread = CreateThreadForRegister(ByVal 0&, 0&, ByVal lProcAddress, ByVal 0&, 0&, lThread)
If lThread Then
lSuccess = (WaitForSingleObject(lThread, 10000) = 0)
If Not lSuccess Then
Call GetExitCodeThread(lThread, lExitCode)
Call ExitThread(lExitCode)
bAns = False
Exit Function
Else
bAns = True
End If
CloseHandle lThread
FreeLibraryRegister lLib
End If
End If
RegSvr32 = bAns
End Function

'Implemented example from
Public Function Sub RegisterFile() as Boolean
Dim FileSys1 As String

FileSys1 = "C:\Windows\System32\MSCOMCTL.OCX
If Dir(FileSys1) <> "" Then
RegisterFile = RegServer(FileSys1)
End If
End Function

Blog Platform List

Blog Platform List / Free and Pay for upgrade

Blogger (Google)
HubPages
LiveJournal
Tumblr
TypePad
WordPress

Beautiful Appearance, Less Customize (WYSIWYG blog/website builder)
Weebly
Wix

Tuesday, December 8, 2015

Ms Access Database - vb6

Microsoft Access Database - Microsoft Visual Basic 6

VB6 With Access
http://www.vb6.us/tutorials/vb6-access

Tutorial 4: Accessing databases using the DataEnvironment Controll
http://pages.cpsc.ucalgary.ca/~saul/vb_examples/tutorial4/

visual basic 6.0 to ms access
http://www.dreamincode.net/forums/topic/185023-visual-basic-60-to-ms-access/

LESSON 9 - Working with a database
http://www.profsr.com/vb/vbless09.htm


Compact Ms Access Database

Compact Ms Access Database / Compress Ms Access Database

CompactDatabase Method (JRO)
https://msdn.microsoft.com/en-us/library/bb237197.aspx

Access Database Engine
http://techieyogi.blogspot.co.id/2009/11/installing-access-database-engine-with.html

Access 2007
http://www.vbforums.com/showthread.php?607895-RESOLVED-How-to-compact-Access-2007-data-base
https://social.msdn.microsoft.com/Forums/en-US/ddf4519f-b69f-4d40-b2f4-fe4987305b0f/compact-access-2007-database?forum=adodotnetdataproviders
http://techieyogi.blogspot.co.id/2009/11/how-to-compact-access-2007-database.html
http://www.vbforums.com/showthread.php?43900-Compact-Access-DB-with-VB6-code

Access 2003
http://www.vbforums.com/showthread.php?661787-RESOLVED-Access-database-compact-repair
https://support.microsoft.com/en-us/kb/230501
http://www.freevbcode.com/ShowCode.asp?ID=1162
http://vbadud.blogspot.com/2007/09/reducing-size-of-microsoft-access.html

All Version
http://stackoverflow.com/questions/156331/wouldnt-ms-access-mdb-file-size-reduce-after-deleting-the-content-of-database

DOS Command Prompt
http://www.vbforums.com/showthread.php?364654-Classic-VB-API-How-Do-I-Run-DOS-Commands-From-VB

Thursday, December 3, 2015

Delphi 7 vs Visual Basic 6 - part 1

Delphi 7 = Visual Basic 6
Component Palette toolbar = Toolbox window
Form Designer window ( Shift + F12 ) = Object / Form Designer window ( Shift + F7 )
Project Manager window ( Ctrl + Alt + F11 ) = Project Explorer window ( Ctrl + R )
Object Tree View window ( Shift + Alt + F11 ) = Object Browser window ( F2 )
Object Inspector window ( F11 ) = Properties window ( F4 )

Code Explorer window ( F12 ) = Code Editor window ( F7 )
Code Explorer ( Ctrl + Shift + E ) = Object list box ( Ctrl + F2 ) and Procedure list box ( Ctrl + F2, then Tab)

Microsoft Configuration - tools list

Group Policy Management Console/Group Policy Object Editor:
gpedit.msc

Control Panel
ex: Network Connections control panel = ncpa.cpl

Registry Editor:
regedit
regedt32

Local Security Policy
secpol.msc

Windows Services
services.msc

Microsoft Configuration:
msconfig

Command Prompt / Batch Script
VBScript
JScript

Power Shell
*.ps1

Photoshop Drawing & Painting 1


B : Brush, Pencil Tool, Color Replacement Tool, Mixer Brush (CS6)
E : Eraser tools
J : Spot Healing Brush, Healing Brush, Patch, Red Eye (CS2)
S : Clone Stamp Tool, Pattern Stamp Tool
X : Switch Foreground/Background Colours
Y : History Brush Tool, Art History Brush Tool.

Hold Down Shift + Brush (Works with nearly every drawing tool) : Draw Straight LinesDraw Straight Lines
- Using Brush (Works with nearly every drawing tool)
- Click on the start spot then hold Shift and click on the finish/last/target spot.

]/[ Increase / Decrease brush size (Brush, Stamp tools)
Shift+]/Shift+[ Increase / Decrease brush hardness (Brush, Stamp tools)

Photoshop Text Shortcut 1

Ctrl (Windows) , Command (Macintosh).
Alt (Windows), Option (Macintosh).

T : Activate Text Tool.
Shift + T : Switch to other text tool (Vertical Type Tool, Horizontal Type Mask, Vertical Type Mask).
CTRL+Enter : will commit text changes after you have finished typing.
Enter (on the numeric keypad) : will commit text changes after you have finished typing.
Single click on layer in Layers Panel : will commit text changes after you have finished typing.
click checkmark in (Tool) Options Bar / (Tool) Preferences Bar : will commit text changes after you have finished typing.
Double Click on the "T" icon of a text layer in the layers panel : will select all text in that layer.

Ctrl + Shift + . : Enlarge text size by 2 points.
Ctrl + Shift + , : Smaller text size by 2 points.
Ctrl + Shift + Alt + . : Enlarge text size by 10 points.
Ctrl + Shift + Alt + , : Smaller text size by 10 points.

Ctrl + Shift + K : Quick way to switch between lowercase and uppercase text.
Ctrl + Shift + H - small caps.

Alt + Left and Right Arrow Keys : extend / reduce distance between word, a line or a whole paragraph (Tracking). If you block between two characters (you change the Kerning) by 20.
Ctrl + Alt + Left and Right Arrow Keys : extend / reduce distance between word, a line or a whole paragraph (Tracking). If you block between two characters (you change the Kerning) by 100.

Alt + Up and Down Arrow Keys : Quickly change the distance between selected lines (leading) 20.
Ctrl + Alt + Up and Down Arrow Keys : Quickly change the distance between selected lines (leading) 100.

Alt + Shift + Up and Down Arrow Keys : Easy way to use one text layer but have different positions for the text (Baseline Shift) 2. Generally use for ordinal number in date, equation, chemical, math.
Ctrl + Alt + Shift + Up and Down Arrow Keys : Easy way to use one text layer but have different positions for the text (Baseline Shift) 10. Generally use for ordinal number in date, equation, chemical, math.

Ctrl +Shift+L : will align the selected paragraph text justify/align left.
Ctrl +Shift+R : will align the selected paragraph text justify/align right.
Ctrl +Shift+C : will align the selected paragraph text justify center.
Ctrl + Shift + J : justify with last line left aligned
Ctrl + Shift + F : justify all lines
Ctrl + Shift + U : underline
Ctrl + Shift + I : italic
Ctrl + Shift + B : bold
Ctrl + Shift + Y : not sure what to call it, but it resets everything except justification



Wednesday, December 2, 2015

Photoshop Layer Shortcut 2

Double Click the lock on Background Layer : Change background layer to layer.
Alt + Double Click the lock on Background Layer : Change background layer to layer with default name.
Alt+Delete/Alt+Backspace (Photoshop CS 2 and earlier) : fill empty layer with foreground color.
Ctrl+Delete/Ctrl+Backspace (Photoshop CS 2 and earlier) : fill empty layer with background color.

Photoshop Layer Shortcut 1

F7 : Show/Hide Palette/Panel Layer

Layer Mask
Shift + Click on Layer Mask : Enable/Disable Layer Mask
Alt + Click on Layer Mask : Toggle Mask Visibility / display mask as a grayscale image
Alt + Shift + Click on Layer Mask : Display mask as Red Quick Mask.
\ (backslash) : Display mask as Red Quick Mask.
Ctrl + Click Mask : Load Mask As Selection
Ctrl + I (when layer mask active) : inverts the color of a layer mask.
Alt + New Layer Mask Icon : it applies the layer mask as black.

Ctrl + G (Photoshop CS and earlier) : To create a clipping mask.
Shift + Ctrl + G (Photoshop CS and earlier) : To release the clipping mask.
Ctrl + Alt + G (Photoshop CS2 and higher) : To create a clipping mask/To release the clipping mask.
Hold Alt + Click between layer : To create a clipping mask/To release the clipping mask. (CS 6 can apply to layer group).

Selection
Ctrl + click directly on the layer's preview thumbnail or layer mask thumbnail in the Layers palette : To select the contents of a layer.
Ctrl + Shift + click directly on the layer's preview thumbnail or layer mask thumbnail in the Layers palette : to add additional layers to the selection.
Ctrl + Alt + click directly on the layer's preview thumbnail or layer mask thumbnail in the Layers palette :  to subtract another layer from the selection.
Ctrl + Alt + Shift + click directly on the layer's preview thumbnail or layer mask thumbnail in the Layers palette : to create the intersection between layers.

Choose Layer
Shift key + click on the bottom layer (or vice versa) : select multiple layers. This will select the top layer, the bottom layer, and all the layers in between.
Shift + Alt + [ : select multiple layers that are all directly below each other.
Shift + Alt + ] : select multiple layers that are all directly above each other.
Ctrl + click on each layer you want to select : To select multiple layers that are not directly above or below each other.
Hold Ctrl + click the object on canvas : Auto select layer.
Hold Ctrl + Shift + click the object on canvas : To select more than one layer.
Alt + Shift + . : select until top layer.
Alt + Shift + , : select until bottom layer.

Traversing / Navigating Layer
Alt + [ : go to down layer.
Alt + ] : go to up layer.
Alt + . : go to top layer.
Alt + , : go to bottom layer.

New Layer
Ctrl + J : New Layer Via Copy
Ctrl + Shift + J : New Layer Via Cut.
Shift + Ctrl + N : to create a new layer
Shift + Ctrl + Alt + N : to create a new layer without new layer dialog
Ctrl + click on the New Layer icon at the bottom of the Layers palette : add the new layer below the currently selected layer.

Group and Merge
Ctrl + G : Group Layers
Ctrl + Shift + G : Ungroup Layers.
Ctrl + Shift + C (with a selection) : copies a merged view of all visible layers onto the clipboard. 
Ctrl + E : Merge Layers / Merges selected layer with the layer directly below it. If multiple layers are selected, only those will be merged.
Crtl + Shift + E : Merge Visible / Merges all visible layers into one. Not recommended practice in typical photo editing because you’ll lose layer information.
Ctrl + Alt + E : Stamp Down / Merges all selected layers into one new layer.
Ctrl + click the disclosure triangle next to a layer Group : to expand or collapse all layer Groups in the document.
Alt + click the disclosure triangle : to expand collapse all groups nested within the current group.
Right click the Group’s disclosure triangle and choose "Close/Open this Group" or "Close/Open all Other Groups".

Ctrl + Alt + A : Select All Layer (except the locked Background layer).
Ctrl + \ : switch from Layer color to mask.
Ctrl + ` : switch from Mask to Layer color.
Ctrl + [ : move to lower layer / backward.
Ctrl + ] : move to upper layer / forward.
Ctrl + Shift + [ : move to the lowest layer
Ctrl + Shift + ] : move to the most top layer
Shift + TAB, hide all panels/palette (Layers, Channels,...)
When on a layer, tap the "/" (slash key) : to toggle the Lock (Transparency, Pixels, Position, or All) option on and off.

Alt + clicking on the Layer Visibility icon : all the other layers are hidden / show.
Shift + +/- :  select the Move Tool (V) first. cycle through all the different layer blend modes.
Alt + Click on ( layer mask / vector mask / layer effect / layer / layer group ) then drag drop to other layer : Copy an existing layer object or replace to other layer object.

Changing The Opacity Of A Layer
  1. make sure you have the Move Tool selected by pressing the letter V.
  2. Type 1 = 10%, 15 = 15%, 25 = 25%, "5" for 50% opacity, "8" for 80% opacity, "3" for 30% opacity, 0 = 100%, and so on.
Changing The Fill Of A Layer
  1. make sure you have the Move Tool selected by pressing the letter V.
  2. Hold Shift and Type 1 = 10%, 15 = 15%, 25 = 25%, "5" for 50% fill, "8" for 80% fill, "3" for 30% fill, 0 = 100%, and so on.
 Rules for Linking Layers
  • Selecting a layer that is linked will show the link icon on all the other layers to which it is linked.
  • To unlink a single layer from a link set, simply select the layer and click the link icon. If there were other linked layers, they remain linked.
  • If none of the layers selected contain linked and you click the link icon, all layers become linked - creating a new link set.
  • If the layers selected contain only linked layers, regardless of whether they're all in the same link sets, clicking the link icon unlinks everything selected.
  • If the layers selected contain at least some linked layers within the selection, plus any number of unlinked layers, clicking the link icon extends the link set to include the unlinked layers in the selection.
  • If the layers selected contains linked layers from two or more link sets plus at least one unlinked layer, everything in the selection gets put into a "new" linked set.
  • Layers can only belong to one link set at a time. 
Delete
Alt + Click trash can icon (when you pick Layer group) : To delete the Group and all of it’s contents while bypassing the dialog.
Ctrl + drag a Group to the trash can icon : to delete a Group without deleting it’s contents.
Ctrl + Alt + Click trash can icon (when you pick Layer group)  :  to delete a Group without deleting it’s contents.
Alt + Click trash can icon (when you pick Layer mask) : to delete layer mask without dialog and apply masking.
Alt + Click trash can icon (when you pick Layer color/Layer preview thumbnail) : to delete layer without dialog.