'Paste kode ini pada Modul
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd
As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd
As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const WS_EX_TOOLWINDOW = &H80&
Public Const GWL_EXSTYLE = (-20)
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
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOSIZE = &H1
'Paste code ini pada form code
Private Sub Form_Load()
Dim xx As Long
xx = GetWindowLong(hwnd, GWL_EXSTYLE)
xx = SetWindowLong(hwnd, GWL_EXSTYLE, _
xx Or WS_EX_TOOLWINDOW)
SetWindowPos hwnd, 0, 0, 0, 0, 0, _
SWP_FRAMECHANGED Or SWP_NOMOVE Or _
SWP_NOZORDER Or SWP_NOSIZE
End Sub
Rabu, 29 Agustus 2007
Mengubah ukuran tampilan form (Sizable toolwindow) menggunakan SetWindowLong API function
Menjalankan form selalu berada paling depan "alwasy on top"
Ada kalanya kita ingin menampilkan form kita selalu berada paling depan, untuk
mempermudah hal tersebut om akan memberikan solusinya
Deklarasi
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)
Code yang digunakan
'Code ini akan menampilkan form selalu didepan
rtn = SetWindowPos(OnTop.hwnd, -2, 0, 0, 0, 0, 3)
'Code ini untuk mengembalikan fungsi diatas
rtn = SetWindowPos(OnTop.hwnd, -1, 0, 0, 0, 0, 3)
Cara Menjalankan : Copy code di bawah pada form code)
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)
Private Sub Form_Load()
this code makes the window stay on top
rtn = SetWindowPos(OnTop.hwnd, -2, 0, 0, 0, 0, 3)
End Sub
Tag: Always on top
Disable the close X in a form's upper right corner
Code berikut ini digunakan untuk mendisable Close X pada form
Cara penggunaan : Copy paste code ini ke form code kemudian jalankan, terlihat
bahwa close X nya sudah disable