선언:
C#
[DllImport("uxtheme", CharSet = CharSet.Unicode)]
public static extern Int32 SetWindowTheme(IntPtr hWnd, String subAppName, String subIdList);
VB.NET
<DllImport("uxtheme", CharSet := CharSet.Unicode)> _
Public Shared Function SetWindowTheme(hWnd As IntPtr, subAppName As [String], subIdList As [String]) As Int32
End Function
사용 예제:
C#
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ApiReference {
public partial class MainForm : Form {
[DllImport("uxtheme", CharSet = CharSet.Unicode)]
public static extern Int32 SetWindowTheme(IntPtr hWnd, String subAppName, String subIdList);
public MainForm() {
InitializeComponent();
}
void MainFormLoad(object sender, EventArgs e){
for (Int32 i = 0; i < 100; i++ ) {
ListViewItem item = listView1.Items.Add(i.ToString());
item.SubItems.Add("Text " + i.ToString());
item = listView2.Items.Add(i.ToString());
item.SubItems.Add("Text " + i.ToString());
}
SetWindowTheme(listView1.Handle, "explorer", null);
}
}
}
VB.NET
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Namespace ApiReference
Public Partial Class MainForm
Inherits Form
<DllImport("uxtheme", CharSet := CharSet.Unicode)> _
Public Shared Function SetWindowTheme(hWnd As IntPtr, subAppName As [String], subIdList As [String]) As Int32
End Function
Public Sub New()
InitializeComponent()
End Sub
Private Sub MainFormLoad(sender As Object, e As EventArgs)
For i As Int32 = 0 To 99
Dim item As ListViewItem = listView1.Items.Add(i.ToString())
item.SubItems.Add("Text " & i.ToString())
item = listView2.Items.Add(i.ToString())
item.SubItems.Add("Text " & i.ToString())
Next
SetWindowTheme(listView1.Handle, "explorer", Nothing)
End Sub
End Class
End Namespace
예제 실행 결과:
매개 변수 설명:
hWnd - 테마를 적용할 컨트롤의 핸들을 입력합니다.
subAppName - 애플리케이션의 이름을 입력합니다. 보통 explorer 을 입력합니다.
subIdList - 세미콜론으로 나눠진 CLSID(클래스 식별자)를 입력합니다. 보통 사용하지 않습니다.
API 설명:
지정된 윈도우(=컨트롤)에 테마를 설정합니다.
참고:
SetWindowTheme (MSDN)
비고:
테마가 적용된 윈도우에 SetWindowTheme(핸들, "", "") 을 전달함으로 원래 테마로 되돌릴 수 있습니다.
프로젝트 파일:
'API Reference' 카테고리의 다른 글
31. SetWindowLong (0) | 2014.10.11 |
---|---|
30. GetWindowLong (0) | 2014.10.10 |
28. GetForegroundWindow (0) | 2014.10.09 |
27. AbortSystemShutdown (0) | 2014.10.08 |
26. InitiateSystemShutdown (0) | 2014.10.08 |