Uxtheme.dll skinning

  • Thread starter Thread starter Martín Heras
  • Start date Start date
M

Martín Heras

Hello everybody...
I am trying to apply some parts of the WinXP skins in panel controls. I am
using the Uxtheme wrapper which you can download from www.codeproject.com
and it is good.
If I want to do what I explained, I have to pass a string to a function
which makes the drawing. The string refers to the part of the skin.
I have made this very well, but I can't find what string is the correct to
draw the StartButton and the task buttons of the Taskbar.
Please help me with this since I need it too much.

Thank you very much...

Martín Heras
 
The Startbutton and Taskbar do not have names associated with them for use
in themeing. If you want to draw those parts then you must extract the
bitmaps from the current themes resource file. You can use
GetCurrentThemeName to get the ColorName of the current theme and then
append that string with "_TASKBARBACKGROUND_BMP" or "_STARTBUTTON_BMP" for
the appropriate bitmaps. GetCurrentThemeName also returns the name of the
resource file to extract the bitmaps from.
 
Mmmmm... And how can I open an unmanaged resource from a file using VB.NET?

Thank you...

"Mick Doherty"
 
I knew this was coming...
Heres one I prepared earlier:

\\\\
Imports System.Runtime.InteropServices
Imports System.Text

#Region " Dll Imports "

<DllImport("kernel32", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Function LoadLibrary( _
ByVal lpFileName As String) As IntPtr
End Function
<DllImport("kernel32", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Function FreeLibrary( _
ByVal hModule As IntPtr) As Boolean
End Function

<DllImport("UxTheme", CharSet:=CharSet.Unicode, _
CallingConvention:=CallingConvention.Cdecl)> _
Friend Shared Function GetCurrentThemeName _
(ByVal pszThemeFileName As StringBuilder, _
ByVal cchMaxNameChars As Integer, _
ByVal pszColorBuff As StringBuilder, _
ByVal cchMaxColorChars As Integer, _
ByVal pszSizeBuff As StringBuilder, _
ByVal cchMaxSizeChars As Integer) As Integer
End Function

#End Region

Private Function ExtractBitmap(ByVal sFilename As String, _
ByVal sBitmapName As String) As Bitmap
Dim hInst As IntPtr = LoadLibrary(sFilename)
Dim BMP As Bitmap = Bitmap.FromResource(hInst, sBitmapName)
FreeLibrary(hInst)
Return BMP
End Function

Dim TaskBarBmp As Bitmap
Dim StartButtonBmp As Bitmap

Private Sub SetBitmaps()
Dim ThemeName As StringBuilder = New StringBuilder(256)
Dim ColorName As StringBuilder = New StringBuilder(256)
Dim ThemeSize As StringBuilder = New StringBuilder(256)
GetCurrentThemeName(ThemeName, 256, ColorName, 256, ThemeSize, 256)
TaskbarBmp = ExtractBitmap(ThemeName.ToString, _
ColorName.ToString + "_TASKBARBACKGROUND_BMP")
StartButtonBmp = ExtractBitmap(ThemeName.ToString, _
ColorName.ToString + "_STARTBUTTON_BMP")
End Sub
////
 
Back
Top