Results 1 to 6 of 6

Thread: [2005] Using SetSysColor API

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    [2005] Using SetSysColor API

    I want to change the frame color of all windows on a PC using the SetSysColor API. i implemeted the API as shown below but nothign happens. No errors but no color change either. I'm testing this on an XP machine.


    vb Code:
    1. Public Declare Function SetSysColors Lib "user32" _
    2.                             (ByVal nChanges As Integer, _
    3.                              ByVal lpSysColor As Integer, _
    4.                              ByVal lpColorValues As Integer) As Boolean
    5.  
    6.     Public Declare Function GetSysColor Lib "user32" _
    7.                              (ByVal nIndex As Integer) As Integer
    8.  
    9.     Private Const COLOR_ACTIVECAPTION = 2           'Caption of Active Window
    10.     Private Const COLOR_INACTIVECAPTION = 3         'Caption of Inactive window
    11.     Private Const COLOR_CAPTIONTEXT = 9
    12.  
    13.     Private OriginalActiveColor As Long             ' Holds original active title bar color
    14.     Private OriginalInactiveColor As Long           ' Holds original inactive title bar color
    15.  
    16.  
    17.     Public Sub InitColors()
    18.         OriginalActiveColor = GetSysColor(COLOR_ACTIVECAPTION)
    19.         OriginalInactiveColor = GetSysColor(COLOR_INACTIVECAPTION)
    20.     End Sub
    21.  
    22.     Public Sub ResetColors()    ' Resets the original system colors
    23.         SetSysColors(1, COLOR_ACTIVECAPTION, OriginalActiveColor)
    24.         SetSysColors(1, COLOR_INACTIVECAPTION, OriginalInactiveColor)
    25.     End Sub
    26.  
    27.     Public Sub ChangeColors()
    28.         ' Change active title bar color to black  
    29.         SetSysColors(1, COLOR_ACTIVECAPTION, RGB(0, 0, 0))
    30.         ' Change inactive title bar color to black  
    31.         SetSysColors(1, COLOR_INACTIVECAPTION, RGB(0, 0, 0))
    32.     End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Using SetSysColor API

    Perhaps this will help?

    http://allapi.mentalis.org/apilist/SetSysColors.shtml

    You may need to pass the args ByRef like shown in the code examples at the bottom of the linked page.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Using SetSysColor API

    Also
    http://pinvoke.net is a good resource. They have more .net examples than allapi does.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Using SetSysColor API

    Old habbits die hard. I keep forgetting about pinvoke.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Using SetSysColor API

    Someday... someday lol
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Using SetSysColor API

    You may need to pass the args ByRef like shown in the code examples
    You were right. I missed the fact that I was passing the arguments byVal versus byRef. I still can't get the window frame bar to change color. I had to fall back and simply change the color of the caption text.

    Is there any reason that I can't change the window frame color? If I look in the dispaly properties, the frame color is set to red but all of my frames still appear as blue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width