Page 1 sur 2

Retirer le titre et les bordures à une fenêtre

Publié : jeu. 29/avr./2004 12:34
par Le Soldat Inconnu
Salut,

un petit code qui permet tout d'abord de visualiser le style de la fenêtre et qui montre comment le modifier.

dans cet exemple, je retire le titre et les bordures au bloc-notes de windows.

Code : Tout sélectionner

Procedure ShowStyle(ID)
  Param = GetWindowLong_(ID, #GWL_STYLE)
  
  If Param & #WS_BORDER
    Debug "WS_BORDER"
  EndIf
  If Param & #WS_CAPTION
    Debug "WS_CAPTION"
  EndIf
  If Param & #WS_CHILD
    Debug "WS_CHILD"
  EndIf
  If Param & #WS_CHILDWINDOW
    Debug "WS_CHILDWINDOW"
  EndIf
  If Param & #WS_CLIPCHILDREN
    Debug "WS_CLIPCHILDREN"
  EndIf
  If Param & #WS_CLIPSIBLINGS
    Debug "WS_CLIPSIBLINGS"
  EndIf
  If Param & #WS_DISABLED
    Debug "WS_DISABLED"
  EndIf
  If Param & #WS_DLGFRAME
    Debug "WS_DLGFRAME"
  EndIf
  If Param & #WS_GROUP
    Debug "WS_GROUP"
  EndIf
  If Param & #WS_HSCROLL
    Debug "WS_HSCROLL"
  EndIf
  If Param & #WS_SYSMENU
    Debug "WS_SYSMENU"
  EndIf
  If Param & #WS_MINIMIZEBOX
    Debug "WS_MINIMIZEBOX"
  EndIf
  If Param & #WS_MAXIMIZEBOX
    Debug "WS_MAXIMIZEBOX"
  EndIf
  If Param & #WS_OVERLAPPED
    Debug "WS_OVERLAPPED"
  EndIf
  If Param & #WS_OVERLAPPEDWINDOW
    Debug "WS_OVERLAPPEDWINDOW"
  EndIf
  If Param & #WS_POPUPWINDOW
    Debug "WS_POPUPWINDOW"
  EndIf
  If Param & #WS_SIZEBOX
    Debug "WS_SIZEBOX"
  EndIf
  If Param & #WS_TABSTOP
    Debug "WS_TABSTOP"
  EndIf
  If Param & #WS_TILED
    Debug "WS_TILED"
  EndIf
  If Param & #WS_TILEDWINDOW
    Debug "WS_TILEDWINDOW"
  EndIf
  If Param & #WS_VSCROLL
    Debug "WS_VSCROLL"
  EndIf 
EndProcedure


; on ouvre le bloc note
RunProgram("notepad.exe")

Delay(1000)

; on récupère le handle de la fenêtre du bloc note
NPID = GetForegroundWindow_()

; on affiche le titre de la fenêtre pour vérifier
Titre.s = Space(100)
GetWindowText_(NPID, @Titre.s, 100)
Debug Titre

; on cache la fenêtre
ShowWindow_(NPID, #SW_HIDE)

; on regarde les param de la fenêtre
Debug "La fenêtre a le Style suivant :"
ShowStyle(NPID)

; On retire le redimensionnement de la fenêtre
SetWindowLong_(NPID, #GWL_STYLE, GetWindowLong_(NPID, #GWL_STYLE) & ~ #WS_TILEDWINDOW)

; On redimensionne la fenêtre pour que windows apporte les modifications désirées
#TailleX = 300
#TailleY = 300
MoveWindow_(NPID, 200, 200, #TailleX + 1, #TailleY + 1, 0)
MoveWindow_(NPID, 200, 200, #TailleX, #TailleY, 0)

Debug ""

; on regarde les param de la fenêtre
Debug "Il reste le Style suivant :"
ShowStyle(NPID)


; on affiche la fenêtre
ShowWindow_(NPID, #SW_SHOW)

Publié : jeu. 29/avr./2004 12:45
par Le Soldat Inconnu
le même code mais les consatntes du style de la fenêtre sont décrites (la description est celle de API-Guide en anglais)

Code : Tout sélectionner

Procedure ShowStyle(ID)
  Param = GetWindowLong_(ID, #GWL_STYLE)
  
  ; Cette procedure permet d'afficher le style de la fenêtre avec une description
  ; La description est tirée de API-Guide
  
  If Param & #WS_BORDER
    Debug "WS_BORDER"
    Debug "   Creates a window that has a thin-line border."
  EndIf
  If Param & #WS_CAPTION
    Debug "WS_CAPTION"
    Debug "   Creates a window that has a title bar (includes the WS_BORDER style)."
  EndIf
  If Param & #WS_CHILD
    Debug "WS_CHILD"
    Debug "   Creates a child window. This style cannot be used with the WS_POPUP style"
  EndIf
  If Param & #WS_CHILDWINDOW
    Debug "WS_CHILDWINDOW"
    Debug "Same as the WS_CHILD style."
  EndIf
  If Param & #WS_CLIPCHILDREN
    Debug "WS_CLIPCHILDREN"
    Debug "Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window."
  EndIf
  If Param & #WS_CLIPSIBLINGS
    Debug "WS_CLIPSIBLINGS"
    Debug "   Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window."
  EndIf
  If Param & #WS_DISABLED
    Debug "WS_DISABLED"
    Debug "   Creates a window that is initially disabled. A disabled window cannot receive input from the user."
  EndIf
  If Param & #WS_DLGFRAME
    Debug "WS_DLGFRAME"
    Debug "   Creates a window that has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar."
  EndIf
  If Param & #WS_GROUP
    Debug "WS_GROUP"
    Debug "Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys."
  EndIf
  If Param & #WS_HSCROLL
    Debug "WS_HSCROLL"
    Debug "   Creates a window that has a horizontal scroll bar."
  EndIf
  If Param & #WS_SYSMENU
    Debug "WS_SYSMENU"
    Debug "   Creates a window that has a window-menu on its title bar. The WS_CAPTION style must also be specified."
  EndIf
  If Param & #WS_MINIMIZEBOX
    Debug "WS_MINIMIZEBOX"
    Debug "   Creates a window that has a Minimize button. The WS_SYSMENU style must also be specified."
  EndIf
  If Param & #WS_MAXIMIZEBOX
    Debug "WS_MAXIMIZEBOX"
    Debug "   Creates a window that has a Maximize button. The WS_SYSMENU style must also be specified."
  EndIf
  If Param & #WS_OVERLAPPED
    Debug "WS_OVERLAPPED"
    Debug "   Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style."
  EndIf
  If Param & #WS_OVERLAPPEDWINDOW
    Debug "WS_OVERLAPPEDWINDOW"
    Debug "   Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style."
  EndIf
  If Param & #WS_POPUP
    Debug "WS_POPUP"
    Debug "   Creates a pop-up window. This style cannot be used with the WS_CHILD style."
  EndIf
  If Param & #WS_POPUPWINDOW
    Debug "WS_POPUPWINDOW"
    Debug "   Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible."
  EndIf
  If Param & #WS_SIZEBOX
    Debug "WS_SIZEBOX"
    Debug "   Creates a window that has a sizing border. Same as the WS_THICKFRAME style."
  EndIf
  If Param & #WS_TABSTOP
    Debug "WS_TABSTOP"
    Debug "Specifies a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style."
  EndIf
  If Param & #WS_VSCROLL
    Debug "WS_VSCROLL"
    Debug "   Creates a window that has a vertical scroll bar."
  EndIf 
EndProcedure


; on ouvre le bloc note
RunProgram("notepad.exe")

Delay(1000)

; on récupère le handle de la fenêtre du bloc note
NPID = GetForegroundWindow_()

; on affiche le titre de la fenêtre pour vérifier
Titre.s = Space(100)
GetWindowText_(NPID, @Titre.s, 100)
Debug Titre
Debug ""

; on cache la fenêtre
ShowWindow_(NPID, #SW_HIDE)

; on regarde les param de la fenêtre
Debug "La fenêtre a le Style suivant :"
Debug ""
ShowStyle(NPID)

; On retire le redimensionnement de la fenêtre
SetWindowLong_(NPID, #GWL_STYLE, GetWindowLong_(NPID, #GWL_STYLE) & ~ #WS_TILEDWINDOW)

; On redimensionne la fenêtre pour que windows apporte les modifications désirées
#TailleX = 300
#TailleY = 300
MoveWindow_(NPID, 200, 200, #TailleX + 1, #TailleY + 1, 0)
MoveWindow_(NPID, 200, 200, #TailleX, #TailleY, 0)

Debug ""

; on regarde les param de la fenêtre
Debug "Il reste le Style suivant :"
Debug ""
ShowStyle(NPID)


; on affiche la fenêtre
ShowWindow_(NPID, #SW_SHOW)

Publié : jeu. 29/avr./2004 12:48
par Backup
toi le specialiste des fenetres , tu devrai bosser dans le batiment !! :D

Publié : jeu. 29/avr./2004 13:13
par Anonyme2
Dobro a écrit :toi le specialiste des fenetres , tu devrai bosser dans le batiment !! :D

Vraiment excellent :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:

Publié : jeu. 29/avr./2004 13:49
par Fred
:lol:

Publié : jeu. 29/avr./2004 14:29
par Le Soldat Inconnu
Attention, je vous tiens à carreau ... (je vous laisse réfléchir :wink: ) ... :mrgreen:

Publié : mer. 05/mai/2004 16:53
par Le Soldat Inconnu
Est-ce que quelqu'un peut me dire si ce code marche sur win98 ou Me, j'ai un doute. merci

Publié : sam. 08/mai/2004 13:53
par Le Soldat Inconnu
Non, personne :( bouhouhou, je suis malheureux :0: :jesors:

Publié : sam. 08/mai/2004 13:58
par Dr. Dri
...

Publié : sam. 08/mai/2004 14:00
par julien
Le Soldat Inconnu a écrit :Non, personne :( bouhouhou, je suis malheureux :0: :jesors:

Allez, Régis tu vas être encore + malheureux
:lol: car ton code ne marche pas sous Windows Me

J'ai juste la fenetre du notepad qui est redimensionné.
Je n'ai pas testé sur Windows 98, faut que je le remette, mais je ne pense pas que cela doit marcher

Publié : sam. 08/mai/2004 14:03
par Le Soldat Inconnu
mince de zut.

vous pouvez me faire une copie du texte du debugguer, ça m'aiderai beaucoup, merci :D

Merci Dr.Dri

donc le style n'est pas modifié. bizarre

Publié : sam. 08/mai/2004 14:07
par Le Soldat Inconnu
ça donne quoi en remplacant

Code : Tout sélectionner

SetWindowLong_(NPID, #GWL_STYLE, GetWindowLong_(NPID, #GWL_STYLE) & ~ #WS_TILEDWINDOW)
par

Code : Tout sélectionner

SetWindowLong_(NPID, #GWL_STYLE, 0)

Publié : sam. 08/mai/2004 16:08
par julien
marche pas non plus, et pour le debug j'ai pas installé Pb sur Windows Me

Publié : sam. 08/mai/2004 18:03
par Le Soldat Inconnu
ha , pas installé PB sur Me, tu as 36 PC toi aussi. il suffit de copier le dossier de PB :wink:

Publié : sam. 08/mai/2004 18:54
par Dr. Dri
...