Jump to content
dekzorro

Papar Form Pada Skrin

Recommended Posts

helo semua... camna aku nak nak setkan form VB aku tuh papar sebelah kanan, kiri, atas, bawah pada skrin.

satu lagi... camna coding untuk setkan form tuh display on top aje?

tq

Share this post


Link to post
Share on other sites

1. pakai ni:

form_name.top = value // 0 utk top
form_name.left = value // 0 utk bhgn kiri sekali

//utk center screen
  Form_name.Left = (Screen.Width - F.Width) / 2
  form_name.Top = (Screen.Height - F.Height) / 2
2. pakai statement vbmodal
 form_name.show vbmodal

sekian terima kasih

Share this post


Link to post
Share on other sites

aRmsTer...aku dah try dah coding yg ko bagi tuh..

utk align top ngan center screen tu ok..jadik.

tapi yang nak set on top tu tak jadi la.

aku guna check box, coding yg aku buat camni:

if checkbox.enable = true then

frmHelo.show vbModal

end if

cara aku tuh salah ke?

Share this post


Link to post
Share on other sites

kebetulan laks.......

tapi guna API.....

Option Explicit

Private 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

Const HWND_TOPMOST = -1

Const SWP_SHOWWINDOW = &H40

Const HWND_NOTOPMOST = -2

Private Sub Check1_Click()

Dim Nil, Tinggi, Lebar, Atas, Kiri As Long

Tinggi = 300

Lebar = 300

Atas = 12

Kiri = 16

If Check1.Value = 1 Then

Nil = SetWindowPos(Me.hwnd, HWND_TOPMOST, Kiri, Atas, Lebar, _

Tinggi, SWP_SHOWWINDOW)

ElseIf Check1.Value = 0 Then

Nil = SetWindowPos(Me.hwnd, HWND_NOTOPMOST, Kiri, Atas, Lebar,_

Tinggi, SWP_SHOWWINDOW)

End If

End Sub

ph34r.gif

Share this post


Link to post
Share on other sites

if checkbox.enable = true then

frmHelo.show vbModal

end if

cara aku tuh salah ke?

salah tu..

contoh aku ada 2 form, Form1(main form) & form2(form utk yg stay on top)

kat Form1 ada 2 component, checkbox Check1 & button Command1

jadik aku buat coding bila klik kat button... kalau Check1 tu di tick-kan, Form2 akan kuar n stay on top

Private Sub Command1_Click()
    If Check1.Value = vbChecked Then
        Form2.Show vbModal
    End If
End Sub

err... ko cuma nak dia jadik modal form kat program tuh je kan? bukan semua windows program kan?

p/s: sori aku lambat reply... aku xperasan ko tanya coding tongue.gif

Share this post


Link to post
Share on other sites

dekzorro aku pun Xreti... aku bukanya ada kelulusan dalam bidang ni ... aku belajo pun guna buku je... kalau apa yang aku tau tu boleh le aku tunjukkan...

Buah cempedak di luar pagar,

Ambil galah tolong jolokkan,

Saya budak baru nak belajar,

Kalau salah tolong betulkan,

biggrin.giftongue.gif

Share this post


Link to post
Share on other sites

camna kalo nak disable kan user dari double klik kat title window, aku taknak dia resize ke size development, aku nak dia fit2 kat user screen on start up

ohmy.gif

Share this post


Link to post
Share on other sites

salah tu..

contoh aku ada 2 form, Form1(main form) & form2(form utk yg stay on top)

kat Form1 ada 2 component, checkbox Check1 & button Command1

jadik aku buat coding bila klik kat button... kalau Check1 tu di tick-kan, Form2 akan kuar n stay on top

Private Sub Command1_Click()
    If Check1.Value = vbChecked Then
        Form2.Show vbModal
    End If
End Sub

err... ko cuma nak dia jadik modal form kat program tuh je kan? bukan semua windows program kan?

p/s: sori aku lambat reply... aku xperasan ko tanya coding tongue.gif

err... ko cuma nak dia jadik modal form kat program tuh je kan? bukan semua windows program kan?

aku nak jadikan utk semua program lerr... bukak MS Office pung, form tuh tetap ada kat top.

cam tu ler kirenyer...

Share this post


Link to post
Share on other sites

dekzorro aku pun Xreti... aku bukanya ada kelulusan dalam bidang ni ... aku belajo pun guna buku je... kalau apa yang aku tau tu boleh le aku tunjukkan...

Buah cempedak di luar pagar,

Ambil galah tolong jolokkan,

Saya budak baru nak belajar,

Kalau salah tolong betulkan,

biggrin.giftongue.gif

dekzorro aku pun Xreti... aku bukanya ada kelulusan dalam bidang ni ... aku belajo pun guna buku je... kalau apa yang aku tau tu boleh le aku tunjukkan...

aku lagiiiiiii la budak baru belajaq... kat umah aku takde internet..tu yg susah skit nak cari info...

Share this post


Link to post
Share on other sites

dekzorro.....

sebelum tu.. aku nak bagi tau ko.... aku ni sekolah sampai ting 3 je... jadi bab-bab math ni aku bukan reti sangat.... so kalau tak jadik tu ....... paham-paham je leee...

ok..... aku ada buat penambahan cikit kat code tu......

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

Option Explicit

Private 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

Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Const HWND_NOTOPMOST = -2

'------------------------------
' bile klik
'------------------------------


Private Sub Check1_Click()

    Dim Nil, Tinggi, Lebar, Atas, Kiri As Long
    
    Lebar = Me.Width / Screen.TwipsPerPixelX
    Tinggi = Me.Height / Screen.TwipsPerPixelY
    Kiri = ((Screen.Width - Me.Width) / 2) / Screen.TwipsPerPixelX
    Atas = ((Screen.Height - Me.Height) / 2) / Screen.TwipsPerPixelY
        
    If Check1.Value = 1 Then
       Nil = SetWindowPos(Me.hwnd, HWND_TOPMOST, Kiri, Atas, Lebar, Tinggi, SWP_SHOWWINDOW)
    ElseIf Check1.Value = 0 Then
       Nil = SetWindowPos(Me.hwnd, HWND_NOTOPMOST, Kiri, Atas, Lebar, Tinggi, SWP_SHOWWINDOW)
    End If
    
End Sub

'---------------------------
'untuk center form
'---------------------------

Private Sub Form_Load()
    
    Move Screen.Width / 2 - Width / 2, Screen.Height / 2 - Height / 2 
        
End Sub

tongue.gif

Share this post


Link to post
Share on other sites

ok.....

mari kite tengok perubahan ke dua lak dengan function yang sama .....

let go.....

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

Option Explicit
Private 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

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

'------------------------------
'bile klik
'-----------------------------

Private Sub Check1_Click()
    
     If Check1.Value Then
        Call Sentiasa_kat_Atas(Me, True)
    Else
        Call Sentiasa_kat_Atas(Me, False)
    End If
    
End Sub

'--------------------------------
'bile form load ( center form )
'---------------------------------

Private Sub Form_Load()
    
    Move Screen.Width / 2 - Width / 2, Screen.Height / 2 - Height / 2
        
End Sub

'-----------------------
' ? terjadi
'-----------------------

Public Sub Sentiasa_kat_Atas(Form As Form, Kedudukan As Boolean)
    
    If Kedudukan = True Then
        SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    Else
        SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    End If
End Sub

'------------------
'selamat belajooo.....
'------------------

tongue.gifblink.gif

Share this post


Link to post
Share on other sites

aku ni sekolah sampai ting 3 je...

ala...ko ting. 3 pung bole buat coding...aku nih sampai PhD pung tak bole² lagi.

tima kasih bebanyak.

caman lak kalu aku nak disable kan fungsi close program yg ada pd form tuh (mcm huruf X tuh). aku nengok ada form yg boleh disable kan function tuh.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...