Results 1 to 18 of 18

Thread: [RESOLVED] Opening a Theme file

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    43

    Resolved [RESOLVED] Opening a Theme file

    Shell "\Theme.theme", vbMinimizedFocus


    This is what i currently have but this does not work for me, i'm sure that it cant be opened with shell so how can it be opened?

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

    Re: Opening a Theme file

    Hmm, to run the theme dialog under XP...


    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Shell "rundll32.exe shell32.dll,Control_RunDLL DESK.cpl,,0" '0 designates the first tab
    5. End Sub
    Is that what your looking for?
    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
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Opening a Theme file

    If you pass THEMES.CPL it wil also open up the theme dialog if that control panel icon exists under certain OS'.
    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

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    43

    Re: Opening a Theme file

    Not sure, i have a Theme file that i created in the "Display" panel, i need to open that when the application is run.

  5. #5
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Opening a Theme file

    How about:

    VB Code:
    1. shell "control.exe desk.cpl,,2"
    ?

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    43

    Re: Opening a Theme file

    Yes but will it open the file i created? In fact its best if i tell you what i mean, if you go into the Display panel and then to Theme, click save as and save the file, thats the file i want to open. Its a file that contains information about the theme and where icons and skins are kept. Thats what i want to launch.

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

    Re: Opening a Theme file

    Try this ...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Shell "rundll32.exe shell32.dll,Control_RunDLL C:\MyTheme.theme"
    5. End Sub
    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

  8. #8
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Opening a Theme file

    I think I just understood your post

    you want to open theme files.

    rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:"%1"

    Where "%1" is your theme file.

    How to put it into VB:

    VB Code:
    1. Private Sub runtheme()
    2. Dim strThemeFile As String
    3. strThemeFile = InputBox("Type in the location of the theme file")
    4. Shell ("rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & strThemeFile & Chr(34))
    5. End Sub
    Last edited by kregg; Oct 9th, 2006 at 12:51 PM.

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

    Re: Opening a Theme file

    Probably getting closer but doesnt pass the theme file.

    Running XP SP2.

    I did get another error but fixed it by supplying a space between the "/Action: OpenTheme" part.
    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

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

    Re: Opening a Theme file

    Just noticed the edit kregg for the double quotes.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Shell "rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & "C:\MyTheme.theme" & Chr(34)
    5. End Sub
    Now since that only loads the theme in the dialog box I wonder if there is a way to apply the theme automatically.
    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

  11. #11
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Opening a Theme file

    Now i think you've all understood the guy wrongly! or either i have understood him wrongly.!!

    I think he doesnt want to dialogs and control panel stuff..

    He just wants to run the .theme file... and this is what he has...

    Shell "\Theme.theme", vbMinimizedFocus
    ...whis is wrong, because he hasnt got the full path to the THEME.theme file.

    try n add the full path to your theme.theme file.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



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

    Re: Opening a Theme file

    No, you can not directly shell a .theme file with or without the complete path in VB.

    Try it from the Run box too as the run box will only open the theme dialog box
    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

  13. #13
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Opening a Theme file

    Quote Originally Posted by RobDog888
    Now since that only loads the theme in the dialog box I wonder if there is a way to apply the theme automatically.
    How about Hooking onto the window and then onto the OK button and send message to click on it? I have no idea on how to do it, but I'm going to do research.

  14. #14

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    43

    Re: Opening a Theme file

    I looked at all your posts, RobDog888 works best. So thanks.

  15. #15
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Opening a Theme file

    If you're talking about Post 10, then that was another verison of post 8

    Please don't forget to set post as resolved by going to thread tools at the top and press resolve.

    And If someone has helped you, it would be nice if you rate their posts *hint hint meee!

  16. #16
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Opening a Theme file

    Quote Originally Posted by RobDog888
    Now since that only loads the theme in the dialog box I wonder if there is a way to apply the theme automatically.
    And just because I can't let down a gangsta Yoda,

    VB Code:
    1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
    2.     ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    3.    
    4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
    5.     ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    6.    
    7. Private Const BM_CLICK = &HF5
    8.  
    9. Private Sub runtheme()
    10.  
    11.    
    12.     Dim strThemeFile As String
    13.     strThemeFile = InputBox("Type in the location of the theme file")
    14.     Shell ("rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & strThemeFile & Chr(34))
    15.     Timer1.Enabled = True
    16.  
    17. End Sub
    18.  
    19. Private Sub Form_Load()
    20.     runtheme
    21.     Timer1.Interval = 2000
    22. End Sub
    23.  
    24. Private Sub Timer1_Timer()
    25.     Dim lhWnd As Long
    26.  
    27.     lhWnd = FindWindowEx(0&, 0&, "#32770", vbNullString)
    28.     lhWnd = FindWindowEx(lhWnd, 0&, "Button", "OK")
    29.     SendMessage lhWnd, BM_CLICK, 0&, 0&
    30. End Sub

    That oughta do it (see thread about closing the dialog box down)

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

    Re: [RESOLVED] Opening a Theme file

    I knew that was coming. I was meaning by automatically as in not displaying the dialog and applying the button click but rather an API or something that would just apply the theme file without loading it into the dialog. Good code though.
    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

  18. #18
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: [RESOLVED] Opening a Theme file

    Quote Originally Posted by RobDog888
    I knew that was coming. I was meaning by automatically as in not displaying the dialog and applying the button click but rather an API or something that would just apply the theme file without loading it into the dialog. Good code though.
    I had to do this in an app i was just working on, seems the only way I could get it to do so without the user seeing the Display Properties window, was using the code from Kregg (and Bush), and basically set a seperate form (using the desktop background color) to cover the screen ... see attached example for switching between XP Default and Windows Classic Themes ..

    BTW the class name of display properties is the same as Task Manager and some others, so i also had to send the title in the FindWindow, otherwise it wouldnt work when those other windows are open. Also set a 6 second timeout on the timer in case something goes wrong ..

    thanks to those above that provided the essential code

    Rory
    Last edited by rory; Jan 3rd, 2007 at 11:10 PM.

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