Jump to content

Window Theme doesn't change


 Share

Recommended Posts

Hi guys,

I need my client window to be independent of the Windows Theme.

(since I use settings in my program that won't work in case of Aero or other themes)

So I decided to convert the needed window, before using it, to Classic theme.

I used _WinAPI_SetWindowTheme()

First of all I didn't well understood what are the arguments: _WinAPI_SetWindowTheme ( $hWnd [, $sName = 0 [, $sList = 0]] ), so reading MSDN and other examples I just used "" and "".

Anyway I realized that window doesn't change always but just sometimes. (this happens on every kind of window I use as target)

here is the code you can test, I used it with AutoIt Help window

#include <WinAPITheme.au3>
$sText = WinGetTitle("AutoIt H")
$hwnd = WinGetHandle($sText)
$answ = _WinAPI_SetWindowTheme($hwnd,"","")
If Not @error Then
    ConsoleWrite("OK - " & $sText & @CRLF & @CRLF)
Else
    ConsoleWrite("KO - " & @extended & @CRLF& @CRLF)
EndIf

 

My  aim is to use the client window with classic theme and independent from DPI resolution (I use 100% but maybe someone could use 125%), so I would like to applly changes before using the window.

Thanks,

Marco

Link to comment
Share on other sites

Hi Marco,

I have a similar problem ...

But first to your problem: could it be that there must be a short pause before applying the settings?

My problem is that I take a snapshot of a portion of a window and when someone uses 125% DPI or even 150% the metrics of the window change and the screenshot is not taken correctly. I could compensate it within the autoit script but of course setting the window strictly to 100% DPI would be a better solution.

Perhaps you can let me know when you'll have found a solution - I am also working on it (although I am not real AutoIt specialist, more a universalist like you).

Good luck!

Norbert

Link to comment
Share on other sites

Hi Norbert,

that was Phase2 problem :)

infact not only i need to solve the theme-problem but also the DPI one.

What I thought to do today is the following:

set in my program settings.ini three more values:

a) Browser

B) Theme

c) DPI

when my customers create their profiles they have no problems since everything it's done in their pc.

when they use my profiles (self built in my product) I will check before running the profile the 3 conditions:

$class_string = "MozillaWindowClass"
$wclass = WinGetClassList($hwnd)
If StringInStr($wclass,$class_string) Then
    ConsoleWrite("Correct Browser" & @CRLF & @CRLF)
Else
    ConsoleWrite("Only Firefox suitable for this profile" & @CRLF & @CRLF)
EndIf

 

If IsArray($aData) Then
    ConsoleWrite("Only Classic Theme suitable for this profile" & @CRLF & @CRLF)
    ConsoleWrite('File:    ' & $aData[0] & @CRLF)
    ConsoleWrite('Color:   ' & $aData[1] & @CRLF)
    ConsoleWrite('Size:    ' & $aData[2] & @CRLF)
    ConsoleWrite('Name:    ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_CANONICALNAME) & @CRLF)
    ConsoleWrite('Display: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_DISPLAYNAME) & @CRLF)
    ConsoleWrite('Tooltip: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_TOOLTIP) & @CRLF)
    ConsoleWrite('Author:  ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_AUTHOR) & @CRLF)
Else
    ConsoleWrite('Classic Theme' & @CRLF)
EndIf

 

Still don't know how to get DPIs? Do you know how to find them?

M.

Link to comment
Share on other sites

Hi again Marko,

in the meantime I found a workaround - not a real solution - for getting the DPI at least indirectly.

Try this from the helpfile folder:  _GDIPlus_ImageGetHorizontalResolution.au3

It gives the dpi from a test with a captured bitmap - means: 96 for 100%, 120 for 125% etc.

Hope it helps, although directly forcing the window to use a fixed resolution would be better.

Norbert

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...