Comment changé la couleur sur un cadre ?

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Ulix
Messages : 315
Inscription : ven. 04/juin/2004 14:27
Localisation : Frontignan

Comment changé la couleur sur un cadre ?

Message par Ulix »

Je suppose qu'il s'agit d'un bug, :twisted: mais la couleur du titre d'une Frame3DGadget est toujours bleue !

Dans l'aide le screenshot représente un titre d'une Frame3DGadget en noir.

Comment changé la couleur ? J' ai essayais avec SetGadgetColor(....) ! Pas de résultat

J'ai essayais aussi toutes les commandes qui ont un rapport avec la couleur ? Rien

En ai-je oublié une ? :oops:

Parce que sur une fenêtre toutes écrite en noir, du texte bleu, ça fait pas très sérieux, alors comment faire ?
Si quelqu'un a une solution je suis preneur ! :lol:
Merci d'avance !
SpaceMan
Messages : 290
Inscription : mar. 26/oct./2004 19:35
Contact :

Message par SpaceMan »

Ben c'est Normal Ulix !
T'as activé le support du skin XP(désactive et tu verras !)
8O
Avatar de l’utilisateur
Ulix
Messages : 315
Inscription : ven. 04/juin/2004 14:27
Localisation : Frontignan

Message par Ulix »

C'est exact, j'ai bien le support de skin XP activé.

Mais comment forcé l'écriture du texte de ce gadget (Frame3DGadget) en noir.

Une API pourrait-elle le permettre ?

C'est bien dommage que la commande SetGadgetColor(....) ne le s'applique a ce gadget !

Merci d'avance de me faire part de vous suggestions ! :wink:
Avatar de l’utilisateur
Ulix
Messages : 315
Inscription : ven. 04/juin/2004 14:27
Localisation : Frontignan

Message par Ulix »

J'ai bien trouvé le code suivant, mais je m'aime pas trop utilisé des calbacks.

Je préfère une API toute simple !

Code : Tout sélectionner

Global TextBackground=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))
Global TextForeground=#Black;	#Red

Procedure WinProc(hWnd,Msg,wParam,lParam)
  result = #PB_ProcessPureBasicEvents
  If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0)
    SetBkMode_(wParam,#TRANSPARENT)
    SetTextColor_(wParam,TextForeground)
    result = TextBackGround
  EndIf
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,250,100,"Colored Frame3D",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
SetWindowCallback(@WinProc())

Frame3DGadget(0,10,10,230,80,"This is a Frame3D")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

DeleteObject_(TextForeground)
DeleteObject_(TextBackground) 
Quelqu'un a-t-il une idée ?
SpaceMan
Messages : 290
Inscription : mar. 26/oct./2004 19:35
Contact :

Message par SpaceMan »

une API toute simple c'est pas évident !
j'ai trouvé les codes suivants sur le forum US :

Code : Tout sélectionner

; Title: Frame3DGadgetEx 
; Author: Fluid Byte 
; Date: December 31, 2006 
; Version: PureBasic V4.02 

Structure FRAME3DEX 
   lpPrevFunc.l 
   clrText.l 
   bThemeXP.b 
EndStructure 

Procedure Frame3DExProc(hWnd.l,uMsg.l,wParam.l,lParam.l) 
   Protected hDC.l,ps.PAINTSTRUCT,*frmex.FRAME3DEX,Title.s,fts.SIZE,wrc.RECT,lpBuffer.l,hThemeButton.l 
    
   *frmex = GetWindowLong_(hwnd,#GWL_USERDATA) 
    
    Select uMsg 
       Case #WM_DESTROY 
       *frmex\lpPrevFunc = -1 
        
       ProcedureReturn 0 
        
        Case #WM_PAINT       
      hdc = BeginPaint_(hwnd,ps) 
       
      SelectObject_(hdc,SendMessage_(hwnd,#WM_GETFONT,0,0)) 
       
      Title = GetGadgetText(GetDlgCtrlID_(hwnd))    
      GetTextExtentPoint32_(hdc,Title,Len(Title),fts)    
      GetClientRect_(hWnd,wrc)       
      SetRect_(wrc,wrc\left,wrc\top+fts\cy/2,wrc\right,wrc\bottom) 
       
      If OSVersion() = #PB_OS_Windows_XP And IsThemeActive_() And IsAppThemed_() And *frmex\bThemeXP 
         lpBuffer = AllocateMemory(13) : PokeS(lpBuffer,"Button",-1,1)       
          
         hThemeButton = OpenThemeData_(WindowID(0),lpBuffer)          
         DrawThemeBackground_(hThemeButton,hdc,4,1,wrc,0) 
         CloseThemeData_(hThemeButton) 
          
         FreeMemory(lpBuffer)          
      Else 
         DrawEdge_(hdc,wrc,#EDGE_ETCHED,#BF_RECT) 
      EndIf 
    
      SetBkColor_(hdc,GetSysColor_(#COLOR_3DFACE)) 
      SetTextColor_(hdc,*frmex\clrText) 
      TextOut_(hdc,9,0,Title,Len(Title))    

      EndPaint_(hwnd,ps) 

      ProcedureReturn 0 

      Default 
      If *frmex\lpPrevFunc = -1 : FreeMemory(*frmex) : Else 
         ProcedureReturn CallWindowProc_(*frmex\lpPrevFunc,hWnd,uMsg,wParam,lParam)          
      EndIf 
    EndSelect 
EndProcedure 

Procedure Frame3DGadgetEx(GadgetID.w,X.w,Y.w,Width.w,Height.w,Text.s,Color.l=0)       
   Protected *frmex.FRAME3DEX,HINSTANCE.l 
    
   Frame3DGadget(GadgetID,X,Y,Width,Height,Text)    
    
   *frmex = AllocateMemory(SizeOf(FRAME3DEX)) 
   *frmex\lpPrevFunc = SetWindowLong_(GadgetID(GadgetID),#GWL_WNDPROC,@Frame3DExProc()) 
   *frmex\clrText = Color 

   HINSTANCE = OpenLibrary(#PB_Any,ProgramFilename()) 
   *frmex\bThemeXP = FindResource_(LibraryID(HINSTANCE),1,24) 
   CloseLibrary(HINSTANCE) 
    
   SetWindowLong_(GadgetID(GadgetID),#GWL_USERDATA,*frmex) 
    
   ProcedureReturn GadgetID(GadgetID) 
EndProcedure 

OpenWindow(0,0,0,400,300,"Ownerdraw Frame3D Control",#WS_OVERLAPPEDWINDOW | 1) 

CreateGadgetList(WindowID(0)) 

SetGadgetFont(#PB_Default,LoadFont(0,"Arial",9)) 

Frame3DGadgetEx(101,10,5,200,90,"Frame3DGadgetEx #1",#Red) 
Frame3DGadgetEx(102,10,100,200,90,"Frame3DGadgetEx #2",RGB(40,180,70)) 
Frame3DGadgetEx(103,10,195,200,90,"Frame3DGadgetEx #3",#Blue) 

While WaitWindowEvent() ! 16 : Wend
2ème code

Code : Tout sélectionner

Procedure DisableXPTheme(Gadget.l) 
  Protected DLL.l, Null.w 
  If OSVersion() >= #PB_OS_Windows_XP 
    DLL = OpenLibrary(#PB_Any, "uxtheme.dll") 
    CallFunction(DLL, "SetWindowTheme", GadgetID(Gadget), @Null.w, @Null.w) 
    CloseLibrary(DLL) 
    ProcedureReturn #True 
  EndIf 
EndProcedure 

Global TextBackground=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE)) 
Global TextForeground=#Black 

Procedure WinProc(hWnd,Msg,wParam,lParam) 
  result = #PB_ProcessPureBasicEvents 
  If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0) 
    SetBkMode_(wParam,#TRANSPARENT) 
    SetTextColor_(wParam,TextForeground) 
    result = TextBackGround 
  EndIf 
  ProcedureReturn result 
EndProcedure 

OpenWindow(0,0,0,250,100,"Colored Frame3D",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 
SetWindowCallback(@WinProc()) 

Frame3DGadget(0,10,10,230,80,"This is a Frame3D") 
DisableXPTheme(0) 
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 

DeleteObject_(TextForeground) 
DeleteObject_(TextBackground)
Répondre