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?
Printable View
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?
Hmm, to run the theme dialog under XP...
Is that what your looking for?VB Code:
Option Explicit Private Sub Form_Load() Shell "rundll32.exe shell32.dll,Control_RunDLL DESK.cpl,,0" '0 designates the first tab End Sub
If you pass THEMES.CPL it wil also open up the theme dialog if that control panel icon exists under certain OS'.
Not sure, i have a Theme file that i created in the "Display" panel, i need to open that when the application is run.
How about:
?VB Code:
shell "control.exe desk.cpl,,2"
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.
Try this ...
VB Code:
Option Explicit Private Sub Form_Load() Shell "rundll32.exe shell32.dll,Control_RunDLL C:\MyTheme.theme" End Sub
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:
Private Sub runtheme() Dim strThemeFile As String strThemeFile = InputBox("Type in the location of the theme file") Shell ("rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & strThemeFile & Chr(34)) End Sub
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.
Just noticed the edit kregg for the double quotes. :)
Now since that only loads the theme in the dialog box I wonder if there is a way to apply the theme automatically.VB Code:
Option Explicit Private Sub Form_Load() Shell "rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & "C:\MyTheme.theme" & Chr(34) End Sub
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...
...whis is wrong, because he hasnt got the full path to the THEME.theme file.Quote:
Shell "\Theme.theme", vbMinimizedFocus
try n add the full path to your theme.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 ;)
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.Quote:
Originally Posted by RobDog888
I looked at all your posts, RobDog888 works best. So thanks.
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!
And just because I can't let down a gangsta Yoda,Quote:
Originally Posted by RobDog888
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const BM_CLICK = &HF5 Private Sub runtheme() Dim strThemeFile As String strThemeFile = InputBox("Type in the location of the theme file") Shell ("rundll32.exe shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /file:" & Chr(34) & strThemeFile & Chr(34)) Timer1.Enabled = True End Sub Private Sub Form_Load() runtheme Timer1.Interval = 2000 End Sub Private Sub Timer1_Timer() Dim lhWnd As Long lhWnd = FindWindowEx(0&, 0&, "#32770", vbNullString) lhWnd = FindWindowEx(lhWnd, 0&, "Button", "OK") SendMessage lhWnd, BM_CLICK, 0&, 0& End Sub
That oughta do it (see thread about closing the dialog box down)
I knew that was coming. :D 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 ..Quote:
Originally Posted by RobDog888
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 :wave:
Rory