INOCHI-GAPTEK
Would you like to react to this message? Create an account in a few clicks or log in to continue.

ActiveX untuk Form "Agar Selalu di Atas"

Go down

ActiveX untuk Form "Agar Selalu di Atas" Empty ActiveX untuk Form "Agar Selalu di Atas"

Post by PujanggaBageur Fri Oct 24, 2008 1:19 pm

Buat project pada "ActiveX Control", ubah nama" Project1" menjadi "INOCHISoftware". Ubah nama "UserControl1" menjadi "inochiOnTop". Ubah properti UserControl "InvisibleAtRuntime" dari "False" menjadi "True".

Tambahkan sebuah class module. Ubah nama menjadi "clsForm". Ubah properti classmodule "Instancing" menjadi "1-Private". Ketik kode di bawah ini di class module (clsForm)!
Code:

Option Explicit

Private WithEvents mParentForm As Form

Public Property Set ParentForm(vData As Form)
    Set mParentForm = vData
End Property

Public Property Get ParentForm() As Form
    Set ParentForm = mParentForm
End Property

Ketik kode di bawah ini di UserControl (inochiOnTop):
Code:

Option Explicit

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Private m_OnTop As Boolean

Private m_Form As New clsForm

Private Sub MakeNormal(lngHwnd As Long)
    SetWindowPos lngHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Private Sub MakeTopMost(lngHwnd As Long)
    SetWindowPos lngHwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Property Get OnTop() As Boolean
    OnTop = m_OnTop
End Property

Property Let OnTop(ByVal vNewValue As Boolean)
    m_OnTop = vNewValue
    Set m_Form.ParentForm = Parent
    If m_OnTop = True Then
        MakeTopMost m_Form.ParentForm.hwnd
    Else
        MakeNormal m_Form.ParentForm.hwnd
    End If
End Property

Private Sub UserControl_Initialize()
    m_OnTop = True
End Sub

Compile menjadi "INOCHISoftware.ocx"

Buatlah projek baru, coba terapkan ActiveX buatan Anda tadi!

Contoh penerapan:

Sisipkan kontrol inochiOnTop di Form, kemudian ketik kode di bawah ini:
Code:

Private Sub Command1_Click()
    Static bytGanti As Byte
    If bytGanti = 0 Then
        inochiOnTop1.OnTop = True
        bytGanti = 1
    Else
        inochiOnTop1.OnTop = False
        bytGanti = 0
    End If
End Sub

Contoh bisa diambil di sini:
Code:
http://www.4shared.com/file/68701653/e1304b05/OnTop.html

flower flower flower
PujanggaBageur
PujanggaBageur
Admin
Admin

Jumlah posting : 148
Join date : 07.08.08
Age : 41
Lokasi : Cirebon

https://inochi.indonesianforum.net

Kembali Ke Atas Go down

Kembali Ke Atas

- Similar topics

 
Permissions in this forum:
Anda tidak dapat menjawab topik