• Foruma hoş geldin 👋 Ziyaretçi

    Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Arşiv Userform'a simge durumu ekleme

muratgunay48

Yeni Üye
Katılım
10 Mar 2021
Mesajlar
104
Çözümler
9
Aldığı beğeni
118
Excel V
Office 2016 TR
Arkadaşlar, bazen userform kullanırken excel ile çalışmak gerekiyor. Bu durumda userform'u aşağı almak gerekiyor. Normalde mümkün değil.
Yalnız bunda şöyle bir sıkıntı var 32 bit ve 64 bit bilgisayarlarda farklı kod gerekiyor. Farklı dediysem tek kelime. Örneğin ÖRNEK DOSYA 64 bit için.
Önce kodları yazalım.

Modül içine
Kod:
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Const EVN_TASINMA = &H2 '
Private Const EVN_BOYUTLANMA = &H1 '
Private Const EVN_STIL = (-20) '
Private Const EVN_UST = 0 '
Private Const EVN_AKTIFDEGIL = &H10 '
Private Const EVN_GIZLE = &H80 '
Private Const EVN_GOSTER = &H40 '
Private Const EVN_PENCERE = &H40000 '
Private Const EVN_STILI = (-16) '
Private Const EVN_KUCULTBUTON = &H20000 '
Private Const EVN_BUYUTBUTON = &H10000 '
Private Const EVN_DEGIS = &H20 '
Dim hWnd As Long, WSTILI As Long, SONUC As Long

Function KucultButonuEkle() As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, EVN_STILI, _
GetWindowLong(hWnd, EVN_STILI) Or EVN_KUCULTBUTON)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
EVN_DEGIS Or EVN_TASINMA Or EVN_BOYUTLANMA)
End Function

Function BuyutButonuEkle() As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, EVN_STILI, _
GetWindowLong(hWnd, EVN_STILI) Or EVN_BUYUTBUTON)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
EVN_DEGIS Or EVN_TASINMA Or EVN_BOYUTLANMA)
End Function

Function GorevCubugundaGoster(Formum) As Long
hWnd = FindWindow(vbNullString, Formum.Caption)
WSTILI = GetWindowLong(hWnd, EVN_STIL)
WSTILI = WSTILI Or EVN_PENCERE
SONUC = SetWindowPos(hWnd, EVN_UST, 0, 0, 0, 0, _
EVN_TASINMA Or EVN_BOYUTLANMA Or EVN_AKTIFDEGIL Or EVN_GIZLE)
SONUC = SetWindowLong(hWnd, EVN_STIL, WSTILI)
SONUC = SetWindowPos(hWnd, EVN_UST, 0, 0, 0, 0, _
EVN_TASINMA Or EVN_BOYUTLANMA Or EVN_AKTIFDEGIL Or EVN_GOSTER)
End Function

Kod bölümüne
Kod:
Private Sub UserForm_Activate()
KucultButonuEkle
BuyutButonuEkle
Call GorevCubugundaGoster(Me)
End Sub

Bu 32 bit için. 64 bit'e uyarlamak için Declare kelimelerinin yanına PtrSafe yazmak gerekiyor.

Kolay gelsin.
 

Ekli dosyalar

Merhaba Murat Bey;
Userform'u biraz daha esnetelim. (eklediğim dosyada userformu köşelerinden tutup genişletin daraltın.)
Kullandığım versiyonda (ofis 2003 32 bit) sorunsuz çalışıyor.
Userformu oluştururken boş olmasın dedim ve userformda gif uygulama örneğini ekledim.
Bunu ticari üretimlerinizde firma logosu vs olarak uygulayabilirsiniz.
Not: Kodların bir kısmı alıntıdır.

Küçük bir püf;
Userform açma kodunuzu

CSS:
Sub formaç()
UserForm1.Show 0
End Sub

Şeklinde (sonuna sıfır ekleyerek) düzenlerseniz sayfada işlem yapmanıza izin verir.
 

Ekli dosyalar

Son düzenleme:
Arkadaşlar, bazen userform kullanırken excel ile çalışmak gerekiyor. Bu durumda userform'u aşağı almak gerekiyor. Normalde mümkün değil.
Yalnız bunda şöyle bir sıkıntı var 32 bit ve 64 bit bilgisayarlarda farklı kod gerekiyor. Farklı dediysem tek kelime. Örneğin ÖRNEK DOSYA 64 bit için.
Önce kodları yazalım.

Modül içine
Kod:
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Const EVN_TASINMA = &H2 '
Private Const EVN_BOYUTLANMA = &H1 '
Private Const EVN_STIL = (-20) '
Private Const EVN_UST = 0 '
Private Const EVN_AKTIFDEGIL = &H10 '
Private Const EVN_GIZLE = &H80 '
Private Const EVN_GOSTER = &H40 '
Private Const EVN_PENCERE = &H40000 '
Private Const EVN_STILI = (-16) '
Private Const EVN_KUCULTBUTON = &H20000 '
Private Const EVN_BUYUTBUTON = &H10000 '
Private Const EVN_DEGIS = &H20 '
Dim hWnd As Long, WSTILI As Long, SONUC As Long

Function KucultButonuEkle() As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, EVN_STILI, _
GetWindowLong(hWnd, EVN_STILI) Or EVN_KUCULTBUTON)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
EVN_DEGIS Or EVN_TASINMA Or EVN_BOYUTLANMA)
End Function

Function BuyutButonuEkle() As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, EVN_STILI, _
GetWindowLong(hWnd, EVN_STILI) Or EVN_BUYUTBUTON)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
EVN_DEGIS Or EVN_TASINMA Or EVN_BOYUTLANMA)
End Function

Function GorevCubugundaGoster(Formum) As Long
hWnd = FindWindow(vbNullString, Formum.Caption)
WSTILI = GetWindowLong(hWnd, EVN_STIL)
WSTILI = WSTILI Or EVN_PENCERE
SONUC = SetWindowPos(hWnd, EVN_UST, 0, 0, 0, 0, _
EVN_TASINMA Or EVN_BOYUTLANMA Or EVN_AKTIFDEGIL Or EVN_GIZLE)
SONUC = SetWindowLong(hWnd, EVN_STIL, WSTILI)
SONUC = SetWindowPos(hWnd, EVN_UST, 0, 0, 0, 0, _
EVN_TASINMA Or EVN_BOYUTLANMA Or EVN_AKTIFDEGIL Or EVN_GOSTER)
End Function

Kod bölümüne
Kod:
Private Sub UserForm_Activate()
KucultButonuEkle
BuyutButonuEkle
Call GorevCubugundaGoster(Me)
End Sub

Bu 32 bit için. 64 bit'e uyarlamak için Declare kelimelerinin yanına PtrSafe yazmak gerekiyor.

Kolay gelsin.

Güzel çalışma.

Örnek dosya, Windows10 x64 Pro 20H2 ve Office 2016 x64 Pro ile test edildi.
 
Geri
Üst