XP Themes "GetThemeColor" always fails ...

  • Thread starter Thread starter yuri
  • Start date Start date
Y

yuri

Hi all
At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control parts
and states entered.
Could somebody help me with advice?
Yuri
 
Hi,
At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control parts
and states entered.

Are you coding in C#? and did you success 'OpenThemeData' ?
Could somebody help me with advice?

Please show me your declearation of 'GetThemeColor'.
 
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B $B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
 
The api looks correct. What are you passing for the iColorID? e.g. For the
border color, you'd use 3801.

yuri said:
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B
$B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
 
Hi Andrew

Thanks for reply. Sure, i use constants from <tmschema.h>.
But nothing works yet. Amazing :)

PS: below is my prosedure:
---------------------------
internal static Color GetThemeColor(ControlPart part, ControlState state,
int iColorID)
{
int result;
int theme ;
// Check to make sure the current system supports themes
if (!SupportsThemes)
throw (new PlatformNotSupportedException("This system does not support the
use of themes."));
// Get the active Windows XP theme for the specified type of control
Themes.ControlClass cp= ControlPartClasses[(int)part];
string s= ControlClassNames[(int)cp];
theme = OpenThemeData(HandleTemp, s); // "WINDOWS"
if (theme == 0)
throw (new NullReferenceException("No active Windows XP Theme could be
detected."));
int ColorRef= new Int32();
result= GetThemeColor(theme, (int) part, (int) state, iColorID, ref
ColorRef);
Color cr= Color.White;
if(ColorRef!=0)
cr=ColorTranslator.FromWin32(ColorRef);

result = CloseThemeData(theme);
if (result != 0)
throw (new InvalidOperationException("The call to CloseThemeData failed with
an error code of " + result.ToString() + "."));
return cr;
}
---------------
Thanks
Yuri

Andrew (Infragistics) said:
The api looks correct. What are you passing for the iColorID? e.g. For the
border color, you'd use 3801.

yuri said:
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B
$B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
 
Hi yuri
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

It's seems correct, but would you try this?

[DllImport("uxtheme.dll")]
private static extern int OpenThemeData (System.IntPtr hwnd,
[In,MarshalAs(UnmanagedType.LPWStr)] string pszClassList);

[DllImport("uxtheme.dll")]
private static extern int GetThemeColor(int hTheme, int Part, int State, int
iColorID, [Out] out int ColorRef);


--
Hiroaki SHIBUKI [MVP]


yuri said:
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B $B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
 
Actually now that I look at it, I think you should remove the CharSet from
the api declaration - that is exported as GetThemeColor and not
GetThemeColorA/GetThemeColorW.

BTW, why do you assume that if the colorref is 0 that it is white -
shouldn't it be black?

yuri said:
Hi Andrew

Thanks for reply. Sure, i use constants from <tmschema.h>.
But nothing works yet. Amazing :)

PS: below is my prosedure:
---------------------------
internal static Color GetThemeColor(ControlPart part, ControlState state,
int iColorID)
{
int result;
int theme ;
// Check to make sure the current system supports themes
if (!SupportsThemes)
throw (new PlatformNotSupportedException("This system does not support the
use of themes."));
// Get the active Windows XP theme for the specified type of control
Themes.ControlClass cp= ControlPartClasses[(int)part];
string s= ControlClassNames[(int)cp];
theme = OpenThemeData(HandleTemp, s); // "WINDOWS"
if (theme == 0)
throw (new NullReferenceException("No active Windows XP Theme could be
detected."));
int ColorRef= new Int32();
result= GetThemeColor(theme, (int) part, (int) state, iColorID, ref
ColorRef);
Color cr= Color.White;
if(ColorRef!=0)
cr=ColorTranslator.FromWin32(ColorRef);

result = CloseThemeData(theme);
if (result != 0)
throw (new InvalidOperationException("The call to CloseThemeData failed with
an error code of " + result.ToString() + "."));
return cr;
}
---------------
Thanks
Yuri

"Andrew (Infragistics)" <[email protected]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ ×
ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:[email protected]...
The api looks correct. What are you passing for the iColorID? e.g. For the
border color, you'd use 3801.

yuri said:
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B
$B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
Hi,

At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control
parts
and states entered.

Are you coding in C#? and did you success 'OpenThemeData' ?

Could somebody help me with advice?

Please show me your declearation of 'GetThemeColor'.

--
Hiroaki SHIBUKI


Hi all
At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control
parts
and states entered.
Could somebody help me with advice?
Yuri
 
Hi Hiroaki

It's solved. The problem was not in procedure.
The real reason that not each color defined has an equal real color stated
in theme metric.
As the result most calls returns error code and I by mistake assumed it as
trouble with procedure. In fact a several colors is stated only for such
complicated object as a windows so if we ask color e.g. EDGESHADOWCOLOR and
a couple of others then it works :-)

Thanks for your assistance so much.
Thanks
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B $B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
Hi yuri
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

It's seems correct, but would you try this?

[DllImport("uxtheme.dll")]
private static extern int OpenThemeData (System.IntPtr hwnd,
[In,MarshalAs(UnmanagedType.LPWStr)] string pszClassList);

[DllImport("uxtheme.dll")]
private static extern int GetThemeColor(int hTheme, int Part, int State, int
iColorID, [Out] out int ColorRef);


--
Hiroaki SHIBUKI [MVP]


yuri said:
Hi Hiroaki

Yes, I'm coding in C#. The 'OpenThemeData' is succeeded and gives me a
correct theme handler that i use nice with any theme-specific functions.
Also GetThemeSysColor is working correctly.
Below is my declaration:

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
private static extern int GetThemeColor(int hTheme,int Part,int State,int
iColorID,ref int ColorRef);

PS: I tried to pass WINDOW as control part with different states and color
with no successful result.
As a result I am receiving always error "element not found".
PS1: If you know any correct template when this call succeeded please post
it here.

Thank you
Yuri

"Hiroaki SHIBUKI [MVP]" <[email protected]>
$B'c'`'`'R'k'Z'](B/$B'c'`'`'R'k'Z']'Q(B $B'S(B $B'_'`'S'`'c'd'q'g(B $B'c']'V'U'e'p'k'V'V(B:
Hi,

At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control parts
and states entered.

Are you coding in C#? and did you success 'OpenThemeData' ?

Could somebody help me with advice?

Please show me your declearation of 'GetThemeColor'.

--
Hiroaki SHIBUKI


Hi all
At coding XP Themes i can't get "GetThemeColor" to work.
It always fails ("not found" err. code) regardless of which control parts
and states entered.
Could somebody help me with advice?
Yuri
 
Back
Top