Taille USER inférieur à 99

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Re : Taille USER inférieur à 99

Bonsoir à tous

Avec les API, oui , mais dans quel but ??
Code:
Option Explicit
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SetWindowPos Lib "user32.dll" (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 Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2

Private Sub UserForm_Click()
Dim hwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
lngWidth = 45
lngHeight = 45
hwnd = GetActiveWindow()
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, lngWidth, lngHeight, SWP_NOMOVE
End Sub

PS: Si on teste avec moins de 45, seul la croix rouge apparait.
 
Dernière édition:
Re : Taille USER inférieur à 99

[...SUITE...]

Une version plus aboutie (grâce un emprunt à Leith Roth)
NB: Test OK sur Excel 2013 32 bits.
Ps: Pour fermer, l'userform il suffit de cliquer dessus.
DANS UN MODULE STANDARD
VB:
'Written: August 01, 2009
'Author:  Leith Ross
'Summary: Removes the Titlebar and thick border around a UserForm.
'Returns the Window Handle of the Window that is accepting User input.
 Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long

 Private Declare Function GetWindowLong _
   Lib "user32.dll" _
     Alias "GetWindowLongA" _
       (ByVal hwnd As Long, ByVal nIndex As Long) As Long
               
 Private Declare Function SetWindowLong _
  Lib "user32.dll" _
    Alias "SetWindowLongA" _
      (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Sub RemoveFrame()
Dim Bitmask As Long
Dim hwnd As Long
Dim WindowStyle As Long
Const GWL_STYLE As Long = (-16)
Const WS_DLGFRAME As Long = &H400000
hwnd = GetForegroundWindow
WindowStyle = GetWindowLong(hwnd, GWL_STYLE)
Bitmask = WindowStyle And (Not WS_DLGFRAME)
Call SetWindowLong(hwnd, GWL_STYLE, Bitmask)
End Sub

DANS LE CODE DE L'USERFOM
VB:
Option Explicit
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SetWindowPos Lib "user32.dll" (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 Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2

Private Sub UserForm_Activate()
Dim hwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
RemoveFrame
lngWidth = 25
lngHeight = 25
hwnd = GetActiveWindow()
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, lngWidth, lngHeight, SWP_NOMOVE
End Sub
Private Sub UserForm_Click()
Unload Me
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
7
Affichages
598
Réponses
4
Affichages
285
Retour