I have an interesting issue. My app is a DLL add-on for another (monster app). Various checks and preparation files have to be processed first, so I have a 'launcher' app that performs those tasks and then runs the monster.
Now, the monster uses it's own forms framework (for cross-platform purposes). The framework however is not 100% compatible with the GUI whistles and bells delivered by Win7, and so it is necessary to run it with the Win7 'Basic' Theme set.
I need my launcher app to switch the Theme programmatically - does anyone know how to do it?
Apply Win7 Theme programatically
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Apply Win7 Theme programatically
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Apply Win7 Theme programatically
Hi
Code: Select all
Procedure.s GetWindowsDirectory()
Path.s=Space(500)
GetWindowsDirectory_(@Path,500)
ProcedureReturn Path
EndProcedure
Userd$ = GetHomeDirectory()
Wind$ = GetWindowsDirectory()
OpenWindow(0, 0, 0, 100, 100, "OpenGL",#PB_Window_Invisible)
;
;RunProgram("rundll32.exe", Chr(32)+Wind$+"\system32\shell32.dll,Control_RunDLL "+Wind$+"\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"+Chr(34)+Wind$+"\Resources\Themes\architecture.theme"+Chr(34),"",#PB_Program_Wait)
;RunProgram(Userd$+"\AppData\Local\Microsoft\Windows\Themes\RASHAD.theme") ;For User Themes
RunProgram(Wind$+"\Resources\Ease of Access Themes\classic.theme") ;For Basic Themes
;RunProgram(Wind$+"\Resources\Themes\characters.theme") ;For Aero Themes
Repeat
hwnd = FindWindow_("CabinetWClass", "Personalization")
Until hWnd
Delay(500)
SendMessage_(hwnd, #WM_CLOSE, 0, 0)
End
Egypt my love
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Apply Win7 Theme programatically
Hi Rashad
I nearly got there, the killer is the Windows pop-up, solved by you thus:
I really dislike changing the User's theme but there is no choice.
I nearly got there, the killer is the Windows pop-up, solved by you thus:
Code: Select all
Repeat
hwnd = FindWindow_("CabinetWClass", "Personalization")
Until hWnd
Delay(500)
SendMessage_(hwnd, #WM_CLOSE, 0, 0)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Apply Win7 Theme programatically
Good
Adding some flavor
Adding some flavor
Code: Select all
#SPI_GETDESKWALLPAPER = 115
Path.s = Space(500)
GetWindowsDirectory_(@Path,512)
FileName.s = Space(512)
SystemParametersInfo_(#SPI_GETDESKWALLPAPER, Len( FileName ),FileName ,0)
OpenWindow(0, 0, 0, 100, 100, "OpenGL",#PB_Window_Invisible)
;
;RunProgram(GetHomeDirectory() + "\AppData\Local\Microsoft\Windows\Themes\RASHAD.theme") ;For User Themes
RunProgram(Path + "\Resources\Ease of Access Themes\classic.theme") ;For Basic Themes
;RunProgram(Path + "\Resources\Themes\characters.theme") ;For Aero Themes
Repeat
hwnd = FindWindow_("CabinetWClass", "Personalization")
Until hWnd
Delay(500)
SendMessage_(hwnd, #WM_CLOSE, 0, 0)
SystemParametersInfo_(#SPI_SETDESKWALLPAPER, 0, FileName, #SPIF_UPDATEINIFILE | #SPIF_SENDWININICHANGE)
End
Egypt my love
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Apply Win7 Theme programatically

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Apply Win7 Theme programatically
I think you can
http://msdn.microsoft.com/en-us/library/bb773402.aspx
Or
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme
http://msdn.microsoft.com/en-us/library/bb773402.aspx
Or
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme
Code: Select all
Path.s = Space(512)
GetWindowsDirectory_(@Path,512)
Procedure.l QueryValueEx(lhkey.i, szValueName.s)
Define.i cch, lrc, lType, lValue
Shared vValue.s
cch = 255
sValue.s = Space(255)
lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, @sValue, @cch)
If lrc = 0
vValue = Left(sValue, cch - 1)
Else
vValue = "Empty"
EndIf
ProcedureReturn lrc
EndProcedure
lTopLevelKey = #HKEY_CURRENT_USER
sRemMachName.s = ""
sKeyName.s = "SOFTWARE\Microsoft\Windows\CurrentVersion\Themes"
sValueName.s = "CurrentTheme"
lRetVal = RegConnectRegistry_(sRemMachName, lTopLevelKey, @lHKeyhandle)
lRetVal = RegOpenKeyEx_(lHKeyhandle, sKeyName, 0, #KEY_READ, @lhkey)
lRetVal = QueryValueEx(lhkey, sValueName)
RegCloseKey_(lhkey)
If lRetVal = 0
CurrentTheme$ = vValue
Debug CurrentTheme$
;MessageRequester("Theme Name", vValue, #MB_ICONINFORMATION)
Else
msg.s = "An Error occured, Return value = " + Str(lRetVal)
MessageRequester("Error", msg, #MB_ICONERROR)
EndIf
OpenWindow(0, 0, 0, 100, 100, "OpenGL",#PB_Window_Invisible)
RunProgram(GetHomeDirectory() + "\AppData\Local\Microsoft\Windows\Themes\RASHAD.theme") ;For User Themes
;RunProgram(Path + "\Resources\Ease of Access Themes\classic.theme") ;For Basic Themes
;RunProgram(Path + "\Resources\Themes\characters.theme") ;For Aero Themes
Repeat
hwnd = FindWindow_("CabinetWClass", "Personalization")
Until hWnd
Delay(500)
SendMessage_(hwnd, #WM_CLOSE, 0, 0)
End
Egypt my love
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Apply Win7 Theme programatically
Hi Rashad
Thanks for that, I'll have a play with GetCurrentThemeName, which looks to be just the ticket
Thanks for that, I'll have a play with GetCurrentThemeName, which looks to be just the ticket

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.