Aplikasi dengan style Xp menggunakan VB6

Biasanya membuat program di VB6 agak membosankan, karena tampilannya tidak terlalu bagus. Tetapi kini dengan menambahkan kode berikut tampilannya menjadi sesuai dengan skin Xp saat dijalankan di Xp.

Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Declare Function InitCommonControlsEx Lib “comctl32.dll” _
(iccex As tagInitCommonControlsEx) As Boolean
Private Const ICC_USEREX_CLASSES = &H200
Public Sub WriteManifest()
On Error Resume Next
Dim F As String
F = App.Path & “\” & App.EXEName & “.exe.manifest”
If Dir(F) = “” Then
Open F For Output As #3
Print #3, “<?xml version=” & Chr(&H22) & “1.0” & _
Chr(&H22) & ” encoding=” & Chr(&H22) & “UTF-8″ & _
Chr(&H22) & ” standalone=” & Chr(&H22) & “yes” & _
Chr(&H22) & ” ?>”
Print #3, “<assembly xmlns=” & Chr(&H22) & _
“urn:schemas-microsoft-com:asm.v1″ & Chr(&H22) & _
” manifestVersion=” & Chr(&H22) & “1.0” & Chr(&H22) & “>”
Print #3, vbTab & “<assemblyIdentity”
Print #3, vbTab & vbTab & “version=” & Chr(&H22) & _
“1.0.0.0” & Chr(&H22)
Print #3, vbTab & vbTab & “processorArchitecture=” & _
Chr(&H22) & “X86” & Chr(&H22)
Print #3, vbTab & vbTab & “name=” & Chr(&H22) & _
App.CompanyName & “.” & App.ProductName & “.” & _
App.EXEName & Chr(&H22)
Print #3, vbTab & vbTab & “type=” & Chr(&H22) & _
“win32″ & Chr(&H22) & ” />”
Print #3, vbTab & “<description>” & App.Comments & _
“</description>”
Print #3, vbTab & “<dependency>”
Print #3, vbTab & “<dependentAssembly>”
Print #3, vbTab & “<assemblyIdentity”
Print #3, vbTab & vbTab & “type=” & Chr(&H22) & _
“win32” & Chr(&H22)
Print #3, vbTab & vbTab & “name=” & Chr(&H22) & _
“Microsoft.Windows.Common-Controls” & Chr(&H22)
Print #3, vbTab & vbTab & “version=” & Chr(&H22) _
& “6.0.0.0” & Chr(&H22)
Print #3, vbTab & vbTab & “processorArchitecture=” & _
Chr(&H22) & “X86” & Chr(&H22)
Print #3, vbTab & vbTab & “publicKeyToken=” & _
Chr(&H22) & “6595b64144ccf1df” & Chr(&H22)
Print #3, vbTab & vbTab & “language=” & Chr(&H22) & _
“*” & Chr(&H22) & ” />”
Print #3, vbTab & “</dependentAssembly>”
Print #3, vbTab & “</dependency>”
Print #3, “</assembly>”
Print #3, “”
Close #3
Shell App.Path & “\” & App.EXEName & “.exe”, vbNormalFocus
DoEvents
End
End If
Dim Ticce As tagInitCommonControlsEx
Ticce.lngSize = LenB(iccex)
Ticce.lngICC = ICC_USEREX_CLASSES
InitCommonControlsEx Ticce
On Error GoTo 0
End Sub

Save code diatas pada file xp.bas. Tambahkan pada project yang ingin menggunakan style Xp. Kemudian tambahkan kode berikut dalam kode form utama.
Private Sub Form_Initialize()
WriteManifest
End Sub

Agar tampilan form yang diedit juga bertema sesuai dengan tampilan saat run time maka simpan kode di bawah ini pada folder instalasi VB6 anda, misal: C:\Program Files\Microsoft Visual Studio\VB98, sebagai file vb6.exe.manifest
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<assembly xmlns=”urn:schemas-microsoft-com:asm.v1″ manifestVersion=”1.0″>
<assemblyIdentity
type=”win32″
name=”Microsoft.Windows.Editeur”
processorArchitecture=”X86″
version=”4.4.0.0″
/>
<description>Microsoft Visual Basic 6.0</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type=”win32″
name=”Microsoft.Windows.Common-Controls”
language=”*”
processorArchitecture=”X86″
version=”6.0.0.0″
publicKeyToken=”6595b64144ccf1df”
/>
</dependentAssembly>
</dependency>
</assembly>

disadur dari : http://wass.wordpress.com/

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: