::::: มาทำ Control ให้สวย XP Visual Styles กันดีกว่า ::::
posted on 12 Sep 2006 09:35 by theera in Free-DownloadAdding XP Visual Styles to Your Visual Basic Application
มาทำ Control ให้สวย XP Visual Styles กันดีกว่า
จากเดิมหน้าตาแบบนี้

แปลงกายให้เป็น แบบนี้ .... สวยขึ้นทันตาเห็น..

โดยวิธีง่ายๆๆ คือ
สร้าง Project มา แล้ว ลาก Control มาตามรูป และ เพิ่ม Module มาหนึ่งตัว เพิ่ม Code ดังนี้
Option Explicit
Public Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Public Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex _
As _tagInitCommonControlsEx) As Boolean _
Public Const ICC_USEREX_CLASSES = &H200
Public Sub Main()
' we need to call InitCommonControls before we
' can use XP visual styles. Here I'm using
' InitCommonControlsEx, which is the extended
' version provided in v4.72 upwards (you need
' v6.00 or higher to get XP styles)
On Error Resume Next
' this will fail if Comctl not available
' - unlikely now though!
Dim iccex As tagInitCommonControlsEx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
' now start the application
On Error GoTo 0
Form1.Show
End Sub
พอเสร็จแล้วให้ทำการ Make EXE เป็น Project1
ขั้นตอนต่อไปคือ การเพิ่มไฟล์ Manifests เป็น เทคโนโลยีของ Microsoft ที่เป็น DLL และให้นำ Code ข้างล่างนี้ ใส่ Notpad และ Save ไว้ที่เดียวกันกับตัวที่เรา EXE ไว้ ซึ่งการ Save นั้นจะต้องให้ได้ตามรูปแบบนี้ ชื่อEXEของคุณ.exe.manifest เช่น คุณ Save EXE เป็น Project1 ก็ให้ Save เป็น Project11.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourAppName"//ต้องเปลี่ยนค่าให้ตรงกับชื่อExe ด้วยนะคับอย่าลืม
type="win32"
/>
<description>VB code converter.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Public Sub Main()