Selasa, 23 Agustus 2011

Membuat Aplikasi Ter-pin/tertempel Dengan Desktop


Kali ini saya akan menjelaskan mengenai cara agar sebuah aplikasi terpin/tertempel dengan desktop.Dimana - Pin terhadap dekstop artinya memindahkan parent sebuah aplikasi yang awal mulanya parent tersebut adalah "ExploreWClass" menjadi "Progman".
so, mungkin anda akan bertanya, apakah tujuannya? Jika anda pernah melihat aplikasi kalender yang tertempel di dekstop, atau agenda dan jam dinding yang ada didekstop dan biasanya aplikasi tersebut ada pada windows 7 dan bagi yang menggunakan style xp dan sejenisnya.Karena terjadinya perbedaan parent, maka aplikasi-aplikasi tersebut seolah-olah menempel dengan desktop. oke lah kalo begitu langsung saja menuu TKP.....
========================================================================

'Simpan kode di bawah pada module 

Option Explicit



'---------------------------------------------------------------------------------------

'

' Module : modPinToDesktop

' DateTime : 28/06/2005 09:14 PM

' Update : 29/06/2005 02:11 PM (Added unpin sub)

' Author : Carlos Alberto S.

' Purpose : Module to easily pin or stick an application to Windows' desktop.

' It will work with "Active Desktop" on or off and with "Show desktop icons"

' on or off too. The WinKey+D or WinKey+M won't minimize the pinned application.

' Tested only in Windows XP.

' Credits : Original code by Jesse Seidel (Dr. Fire). The original code works

' just when Active Desktop is on. Thanks "herd" for the explanation.

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

' Article : http://msdn.microsoft.com/msdnmag/issues/0600/w2kui2/

'

'---------------------------------------------------------------------------------------



Private Declare Function
FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function
FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function
SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long



Public Sub
PinToDesktop(FormToPin As Form)



'"Progman" would be the parent window of the SHELLDLL_DefView class that

' itself would be either hosting the SysListView32 in classic view

' or the Internet Explorer_Server in Active Desktop view.



Dim
progman As Long

progman = FindWindow("Progman", vbNullString)

SetParent FormToPin.hWnd, progman



End Sub



Public Sub
UnPinFromDesktop(FormToUnPin As Form)



Dim
lngExplorer As Long



lngExplorer = FindWindow("ExploreWClass", vbNullString)

SetParent FormToUnPin.hWnd, lngExplorer



End Sub



'Another way to pin or stick to desktop (limitation: if the application is running and the user

' set the desktop to "Show icons" the application will be hidden).



Public Sub
StickToDesktop(FormToStick As Form)



Dim
progman As Long

Dim
shelldlldefview As Long

Dim
tDesktop As Long



progman = FindWindow("progman", vbNullString)

shelldlldefview = FindWindowEx(progman, 0&, "shelldll_defview", vbNullString)

SetParent FormToStick.hWnd, shelldlldefview



End Sub 
 
===========================================================================
Contoh penggunaan:
===========================================================================
'Simpan kode di bawah pada form 

Private Sub Command1_Click()

PinToDesktop Me 'menempelkan aplikasi terhadap desktop

End Sub



Private Sub
Command2_Click()

UnPinFromDesktop Me 'mengeluarkan aplikasi dari desktop

End Sub 
'-=========================================================================
 
 
 
 
Credit by http://khoiriyyah.blogspot.com/search/label/Application 

0 komentar:

Posting Komentar

Silahkan Tinggalkan Komentar Anda Mengenai Artikel/Berita Di Atas Ini...