Çözüldü Userformu Simge Durumunda Küçültme/Büyültme

Katılım
18 Kasım 2012
Mesajlar
423
Excel Vers. ve Dili
Microsoft Office 365
Altın Üyelik Bitiş Tarihi
04-07-2024
Herkese Merhaba,

Bir makro çalışmam da kullanmış olduğum Userform U simge durumunda küçültmek/büyültmek için aşağıdaki kodları kullanıyorum.

Ancak doğru çalışmıyor. İlgili kodlarda nerede hata yapıyor yada eksik kullanıyor olabilirim.

Bu konuda yardımcı olabilecek birileri var ise çok memnun olurum.

Herkese şimdiden çok teşekkür ederim.

Syg,


Option Explicit
Public Const MinBox = &H10000
Public Const MaxBox = &H20000
Public Const Style = (-16)
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long

Public Sub MaxMinButton(ByVal FormCaption As String)
Dim hWnd As Long
Dim lngStyle As Long

hWnd = FindWindow(vbNullString, FormCaption)
lngStyle = GetWindowLong(hWnd, Style)
lngStyle = lngStyle Or MaxBox
SetWindowLong hWnd, Style, lngStyle
DrawMenuBar hWnd

End Sub

Private Sub UserForm2_Activate()
Module2.MaxMinButton (Me.Caption)
End Sub
 
Katılım
18 Kasım 2012
Mesajlar
423
Excel Vers. ve Dili
Microsoft Office 365
Altın Üyelik Bitiş Tarihi
04-07-2024
Merhaba,

Bu konu ile ilgili yardımcı olabilecek birileri yok mudur?

Syg,
 

Bilgemen

Altın Üye
Katılım
7 Şubat 2021
Mesajlar
54
Excel Vers. ve Dili
2021
Altın Üyelik Bitiş Tarihi
03-01-2026
Denermisiniz bilgisayar yanïmdr değil de eyemedim.
Kod:
```vba

Option Explicit

Public Const GWL_STYLE = -16

Public Const WS_MINIMIZEBOX = &H20000

Public Const WS_MAXIMIZEBOX = &H10000

Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As Long

Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As LongPtr) As Long

Public Sub MaxMinButton(ByVal FormCaption As String)

    Dim hWnd As LongPtr

    Dim lngStyle As Long

    hWnd = FindWindow(vbNullString, FormCaption)

    lngStyle = GetWindowLong(hWnd, GWL_STYLE)

    lngStyle = lngStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX

    SetWindowLong hWnd, GWL_STYLE, lngStyle

    DrawMenuBar hWnd

End Sub

Private Sub UserForm_Activate()

    MaxMinButton Me.Caption

End Sub

```

Bu kodları kullanara
 
Katılım
18 Kasım 2012
Mesajlar
423
Excel Vers. ve Dili
Microsoft Office 365
Altın Üyelik Bitiş Tarihi
04-07-2024
Denermisiniz bilgisayar yanïmdr değil de eyemedim.
Kod:
```vba

Option Explicit

Public Const GWL_STYLE = -16

Public Const WS_MINIMIZEBOX = &H20000

Public Const WS_MAXIMIZEBOX = &H10000

Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As Long

Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As LongPtr) As Long

Public Sub MaxMinButton(ByVal FormCaption As String)

    Dim hWnd As LongPtr

    Dim lngStyle As Long

    hWnd = FindWindow(vbNullString, FormCaption)

    lngStyle = GetWindowLong(hWnd, GWL_STYLE)

    lngStyle = lngStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX

    SetWindowLong hWnd, GWL_STYLE, lngStyle

    DrawMenuBar hWnd

End Sub

Private Sub UserForm_Activate()

    MaxMinButton Me.Caption

End Sub

```

Bu kodları kullanara
Merhaba,

Cevabınız için çok teşekkür ederim.

Kodlar ne yazık ki bende çalışmadı. Ancak kodlarda bazı düzeltmeler yaparak durumu kendim çözdüm.

Tekrardan teşekkürler.

Syg,
 
Katılım
18 Kasım 2012
Mesajlar
423
Excel Vers. ve Dili
Microsoft Office 365
Altın Üyelik Bitiş Tarihi
04-07-2024
Merhaba,

İhtiyacı olanlar için kodların son hali aşağıdaki gibidir.



Kod:
Option Explicit
Public Const MinBox = &H10000
Public Const MaxBox = &H20000
Public Const Style = (-16)
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long

Public Sub MaxMinButton(ByVal FormCaption As String)
Dim hWnd As Long
Dim lngStyle As Long

hWnd = FindWindow(vbNullString, FormCaption)
lngStyle = GetWindowLong(hWnd, Style)

lngStyle = lngStyle Or MinBox
lngStyle = lngStyle Or MaxBox

SetWindowLong hWnd, Style, lngStyle
DrawMenuBar hWnd

End Sub

Kod:
Private Sub UserForm_Activate()

Module2.MaxMinButton (Me.Caption)

End Sub
 
Üst