Form OnTop pada VB


‘1. buat modul dengan nama mdlOnTop
‘ketik pada modul

‘— begin —

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

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
Public Sub MakeOnTop(Handle As Long, status As Boolean)
If status = True Then
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
Else
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End If
End Sub

‘— end of modul —

‘2. Buat code pada form
‘ketik pada kode form
‘buat 2 buah button

‘— begin —
private sub commandOntop_click()
makeOntop me.hwnd, true
end sub

private sub commandOffTop()
makeontop me.hwnd, false
end sub
‘— end of code —

Semoga bermanfaat

About

Flexter member

Posted in VB 6.0
One comment on “Form OnTop pada VB
  1. […] Referensi : https://kohimaru.wordpress.com/2008/06/05/form-ontop-pada-vb/#more-84 […]

Leave a Reply

Fill in your details below or click an icon to log in:

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: