Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Saturday, April 3, 2010

VB6 Code - Fungsi Untuk Merubah Desktop Wallpaper

Di bawah ini merupakan fungsi VB6 untuk merubah desktop wallpaper. Bagaimana implementasinya dalam Visual Basic 6.0?
Option Explicit

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SETDESKWALLPAPER = 20

Public Function ChangeWallPaper(imgFile As String)
Call SystemParametersInfo(SPIF_SETDESKWALLPAPER, 0&, imgFile, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Function
Contoh penggunaan kode di atas
Private Sub Command1_Click()
Call ChangeWallPaper("C:\Windows\Blue.bmp")
End Sub
READ MORE - VB6 Code - Fungsi Untuk Merubah Desktop Wallpaper

VB6 - Menyembunyikan Dan Menampilkan Windows Taskbar

Di bawah ini merupakan contoh standar untuk menyembunyikan dan menampilkan windows taskbar menggunakan Visual Basic 6.
Option Explicit

Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40

Public Sub HideTaskBar()
Dim hWnd1 As Long
hWnd1 = FindWindow("Shell_traywnd", "")
Call SetWindowPos(hWnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
End Sub

Public Sub ShowTaskBar()
Dim hWnd1 As Long
hWnd1 = FindWindow("Shell_traywnd", "")
Call SetWindowPos(hWnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
End Sub
Contoh penggunaan untuk menyembunyikan windows taskbar
Private Sub  Command1_Click()
HideTaskBar
End Sub
Contoh penggunaan untuk menampilkan windows taskbar
Private Sub Command2_Click()
ShowTaskBar
End Sub
Demikian mengenai cara menampilkan dan menyembunyikan windows taskbar menggunakan Visual Basic 6.
READ MORE - VB6 - Menyembunyikan Dan Menampilkan Windows Taskbar

VB6 Code - Menampilkan Kotak Dialog Shutdown

Di bawah ini merupakan fungsi API untuk menampilkan kotak dialog shutdown menggunakan kode VB6. Fungsi yang digunakan adalah SHShutDownDialog yang terdapat pada Shell32.dll.
Option Explicit

Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal sParam As Long) As Long
Contoh penggunaan fungsi API di atas:
Private Sub Command1_Click()
SHShutDownDialog 0
End Sub
READ MORE - VB6 Code - Menampilkan Kotak Dialog Shutdown

VB6 Code - Fungsi Untuk Memeriksa Resolusi Screen

Di bawah ini merupakan fungsi VB6 untuk mengetahui resolusi screen. Bagaimana implementasinya dalam Visual Basic 6.0? bisa kita simak kodenya di bawah ini:
Option Explicit
Public Function ScreenResolution(iWidth, iHeight) As String
iWidth = Screen.Width \ Screen.TwipsPerPixelX
iHeight = Screen.Height \ Screen.TwipsPerPixelY
ScreenResolution = "Screen Resolution:" + vbCrLf + vbCrLf + Str$(iWidth) + " x" + Str$(iHeight)
End Function
Contoh penggunaan fungsi di atas:
Private Sub Command1_Click()
Dim intWidth As Integer
Dim intHeight As Integer
MsgBox ScreenResolution(intWidth, intHeight)
MsgBox intWidth
MsgBox intHeight
End Sub
READ MORE - VB6 Code - Fungsi Untuk Memeriksa Resolusi Screen

VB6 Code - Memindahkan File Ke Recycle Bin

Di bawah ini merupakan procedure VB6 untuk memindahkan/menghapus file ke dalam recycle bin. Bagaimana kodenya dalam Visual Basic 6.0? bisa kita simak di bawah ini:
Option Explicit

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type

Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4

Public Sub SendFileToRecycleBin(FileName As String, Optional Confirm As Boolean = True, Optional Silent As Boolean = False)
Dim FileOp As SHFILEOPSTRUCT

With FileOp
.wFunc = FO_DELETE
.pFrom = FileName
fFlags = FOF_ALLOWUNDO
If Not Confirm Then .fFlags = .fFlags + FOF_NOCONFIRMATION
If Silent Then .fFlags = .fFlags + FOF_SILENT
End With
SHFileOperation FileOp
End Sub
Contoh penggunaan procedure VB6 di atas:
Private Sub Command1_Click()
SendFileToRecycleBin "c:\42.tmp", True, False
End Sub
READ MORE - VB6 Code - Memindahkan File Ke Recycle Bin

VB6 Code - Menghapus Seluruh File Recycle Bin

Di bawah ini merupakan fungsi VB6 untuk menghapus seluruh file yang terdapat pada recycle bin. Bagaimana implementasinya dalam Visual Basic 6.0? bisa Anda simak kodenya di bawah ini
Option Explicit

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4

Public Sub EmptyRecycleBin(frm As Form)
Dim RetVal
RetVal = SHEmptyRecycleBin(frm.hWnd, "", SHERB_NOPROGRESSUI + SHERB_NOCONFIRMATION)
End Sub
Contoh pengunaan procedure VB6 di atas
Private Sub Command1_Click()
EmptyRecycleBin Me
End Sub
READ MORE - VB6 Code - Menghapus Seluruh File Recycle Bin

VB6 Code - Apakah Recycle Bin Kosong?

Di bawah ini merupakan fungsi VB6 untuk memeriksa apakah recycle bin kosong? Bagaimana implementasinya dalam Visual Basic 6.0? bisa Anda simak kodenya dibawah ini:
Option Explicit

Private Type SHQUERYRBINFO
cbSize As Long
i64SizeLo As Long
i64SizeHi As Long
i64NumItemsLo As Long
i64NumItemsHi As Long
End Type

Private Declare Function SHQueryRecycleBin Lib "shell32" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, pSHQueryRBInfo As SHQUERYRBINFO) As Long

Function IsEmptyRecycle() As Boolean
Dim RB As SHQUERYRBINFO
RB.cbSize = Len(RB)
Call SHQueryRecycleBin("C:\", RB)
IsEmptyRecycle = (RB.i64NumItemsLo = 0)
End Function
Contoh penggunaan fungsi VB6 di atas:
Private Sub Command1_Click()
MsgBox IsEmptyRecycle
End Sub
READ MORE - VB6 Code - Apakah Recycle Bin Kosong?

VB6 Code - Menghapus Seluruh File Recent Document

Di bawah ini merupakan procedure VB6 untuk menghapus seluruh yang terdapat pada recent document. Untuk keperluan ini digunakan satu fungsi API yakni SHAddToRecentDocs yang terdapat pada shell32.dll.
Option Explicit

Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As Long, ByVal pv As Any)

Sub EmptyRecentDocument()
SHAddToRecentDocs 0, CLng(0)
End Sub
Contoh penggunaan procedure VB6 di atas:
Private Sub Command1_Click()
EmptyRecentDocument
End Sub
READ MORE - VB6 Code - Menghapus Seluruh File Recent Document

VB6 Code - Menambahkan File Ke Recent Document

Di bawah ini merupakan fungsi VB6 (API) untuk menambahkan file ke recent document. Untuk keperluan ini digunakan satu fungsi API yakni SHAddToRecentDocs yang terdapat pada shell32.dll.
Option Explicit

Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As Long, ByVal pv As String)

Public Function AddToRecentDocument(FileName As String)
Call SHAddToRecentDocs(3, FileName)
End Function
Cara menggunakan fungsi VB6 di atas:
Private Sub Command1_Click()
AddToRecentDocument "C:\boot.ini"
End Sub
READ MORE - VB6 Code - Menambahkan File Ke Recent Document

Monday, March 22, 2010

VB6 Code - Mengganti Label Volume Sebuah Drive

Di bawah ini merupakan kode VB6 untuk mengganti label volume sebuah drive . Bagaimanakah implementasinya dalam pengkodean:
Option Explicit

Private Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long

Private Function SetLabel(RootName As String, NewLabel As String)
If RootName = "" Then
Exit Function
End If
Call SetVolumeLabel(RootName, NewLabel)
End Function
Contoh menggunakan fungsi mengganti label volume sebuah drive:
Private Sub Command1_Click()
Call SetLabel("D:\", "Drive D")
End Sub
READ MORE - VB6 Code - Mengganti Label Volume Sebuah Drive

Tuesday, March 16, 2010

Visual Basic 6 - Membuat Related Documents Pada Project

Artikel kali ini membahas mengenai 'Membuat Related Documents pada Project'.

Apa yang dimaksud Related Docoments? Coba lihat screen Shot ini. Nah, sekarang Anda faham apa yang dimaksud Related Documents itu. Selanjutnya:

Langkah-langkah membuat related documents pada project:
  1. Klik menu project
  2. Klik menu AddFile
  3. Beri tanda centang pada Add As Related Document
  4. Masukan file-file yang menurut Anda berhubungan dengan project yang sedang dibuat
  5. Selesai

Semoga membantu bagi yang belum mengetahui mengenai tata cara membuat related documents pada project.
READ MORE - Visual Basic 6 - Membuat Related Documents Pada Project

VB6 Code - Fungsi Untuk Me-Minimize Seluruh Windows

Di bawah ini merupakan fungsi VB6 untuk me-minimize Seluruh Windows. Karena menggunakan metode Early Binding maka, Untuk keperluan ini Anda harus mereferensi objek "Microsoft Shell Controls And Automation" atau "Shell32.dll" yang biasa terletak pada SystemRoot\System32 (c:\Windows\System32\Shell32.dll).

Jika Anda ingin menggunakan metode Late Binding maka gantilah kode berikut:

Dim Sh as new Shell32.Shell

Menjadi:

Dim Sh as Object
Set Sh = CreateObject("Shell.Application")
Option Explicit

Sub MinimizeAll()
Dim sh As New Shell32.Shell
sh.MinimizeAll
Set sh = Nothing
End Sub

'Contoh penggunaan
Private Sub Command1_Click()
Call MinimizeAll
End Sub
READ MORE - VB6 Code - Fungsi Untuk Me-Minimize Seluruh Windows

VB6 Code - Fungsi Tile Vertically Seluruh Windows

Di bawah ini merupakan fungsi VB6 untuk menjadikan Tile Vertically Seluruh Windows. Karena menggunakan metode Early Binding maka, Untuk keperluan ini Anda harus mereferensi objek "Microsoft Shell Controls And Automation" atau "Shell32.dll" yang biasa terletak pada SystemRoot\System32 (c:\Windows\System32\Shell32.dll).

Jika Anda ingin menggunakan metode Late Binding maka gantilah kode berikut:

Dim Sh as new Shell32.Shell

Menjadi:

Dim Sh as Object
Set Sh = CreateObject("Shell.Application")
Option Explicit

Sub TileVertically()
Dim sh As New Shell32.Shell
sh.TileVertically
Set sh = Nothing
End Sub

'Contoh penggunaan
Private Sub Command1_Click()
Call TileVertically
End Sub
READ MORE - VB6 Code - Fungsi Tile Vertically Seluruh Windows

VB6 Code - Fungsi Tile Horizontally Seluruh Windows

Di bawah ini merupakan fungsi VB6 untuk menjadikan Tile Horizontally Seluruh Windows. Karena menggunakan metode Early Binding maka, Untuk keperluan ini Anda harus mereferensi objek "Microsoft Shell Controls And Automation" atau "Shell32.dll" yang biasa terletak pada SystemRoot\System32 (c:\Windows\System32\Shell32.dll).

Jika Anda ingin menggunakan metode Late Binding maka gantilah kode berikut:

Dim Sh as new Shell32.Shell

Menjadi:

Dim Sh as Object
Set Sh = CreateObject("Shell.Application")
Option Explicit

Sub TileHorizontally()
Dim sh As New Shell32.Shell
sh.TileHorizontally
Set sh = Nothing
End Sub

'Contoh penggunaan
Private Sub Command1_Click()
Call TileHorizontally
End Sub
READ MORE - VB6 Code - Fungsi Tile Horizontally Seluruh Windows

VB6 Code - Fungsi Untuk Meng-Cascade Seluruh Windows

Di bawah ini merupakan fungsi VB6 untuk Meng-Cascade Seluruh Windows. Karena menggunakan metode Early Binding maka, Untuk keperluan ini Anda harus mereferensi objek "Microsoft Shell Controls And Automation" atau "Shell32.dll" yang biasa terletak pada SystemRoot\System32 (c:\Windows\System32\Shell32.dll).

Jika Anda ingin menggunakan metode Late Binding maka gantilah kode berikut:
Dim Sh as new Shell32.Shell

Menjadi:

Dim Sh as Object
Set Sh = CreateObject("Shell.Application")
Option Explicit

Sub CascadeWindows()
Dim sh As New Shell32.Shell
sh.CascadeWindows
Set sh = Nothing
End Sub

'Contoh penggunaan
Private Sub Command1_Click()
CascadeWindows
End Sub
READ MORE - VB6 Code - Fungsi Untuk Meng-Cascade Seluruh Windows