Kamis, 30 Agustus 2007

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