Page 1 sur 1

Bouton dans la barre de titre

Publié : dim. 29/janv./2006 21:31
par Gillou
J'ai fait un code pour mettre un bouton dans la barre de titre, mais impossible de récupérer le résultat lorsqu'il est cliqué, si vous avez une idée :(

Je vous remercie d'avance :D
ProcedureDLL MSG(Text.s) ; Affiche une boîte de dialogue
      MessageRequester ( "Information" , text.s)
EndProcedure

Global WHook
Global FrmH.l
Global CtrlH.l

Declare HookProc(nCode, wParam, lParam)

Procedure Init(FormHwnd.l, ControlHwnd.l)
  FrmH = FormHwnd
  CtrlH = ControlHwnd
  hInstance = GetModuleHandle_ (0)
  lpdwProcessId = GetWindowThreadProcessId_ (FormHwnd, 0)
  WHook = SetWindowsHookEx_ ( #WH_CALLWNDPROC , @HookProc(), hInstance, lpdwProcessId)
    SetWindowLong_ (ControlHwnd, #GWL_EXSTYLE , $80)
    SetParent_ (ControlHwnd, GetParent_ (FormHwnd))
    GetWindowRect_ (FrmH, w.rect)
    SetWindowPos_ (CtrlH, 0, w\right-100, W\Top+4, 23, 23, #SWP_FRAMECHANGED )
EndProcedure

Procedure Terminate(FormHwnd.l, ControlHwnd.l)
    UnhookWindowsHookEx_ (WHook)
    SetParent_ (ControlHwnd, FormHwnd)
EndProcedure

Procedure HookProc(nCode, wParam, lParam)
*Msg.CWPSTRUCT = lparam
      If *Msg\hwnd = FrmH
          If *Msg\Message = #WM_NCPAINT Or *Msg\Message = #WM_MOVE
              GetWindowRect_ (FrmH, win.rect)
              SetWindowPos_ (CtrlH, 0, win\right-100, Win\Top+4, 23, 23, #SWP_FRAMECHANGED )
          Else
          Debug *Msg\Message
          EndIf
      EndIf
EndProcedure


win= OpenWindow ( #PB_Any ,0,0,200,200, #PBWIN0 , "test" )
If win And CreateGadgetList ( WindowID (win))
ButtonGadget (0,0,0,10,10, " _" ) : GadgetToolTip (0, "Place la fenêtre dans la barre système" )
ButtonGadget (1,10,10,30,30, " _" )
Init( WindowID (win), GadgetID (0))
Repeat
Select WaitWindowEvent ()
Case #PB_EventGadget
Select EventGadgetID ()
Case 0
Debug "test"
Case 1
MSG( "test" )
Default
Debug 1
EndSelect
Case #PB_Event_CloseWindow
quit=1
EndSelect
Until quit=1
EndIf

Terminate( WindowID (), GadgetID (0))

Publié : lun. 30/janv./2006 9:28
par Dr. Dri
fais une recherche ca a déjà été posté sur le forum

Dri ;)

Publié : mar. 31/janv./2006 19:19
par Gillou
Je te remercie, mais j'ai regardé et je n'ai trouvé qu'un lien vers la lib de dräc. Elle est pas mal mais dès fois la barre de titre perd le style d'XP et ça me gêne un peu. Le problème c'est surtout qu'avec ça lib on ne peut mettre qu'un seul bouton.

Si tu as des liens :wink: