[Top Page][Edit][Discussion][Edit History][All Pages][Recent Changes][->Japanese]

HSP3標準ライブラリ:uxtheme.as


Windows XP でビジュアルスタイル関数(UxTheme.dll)を使うためのもの


uxtheme.as

; (uxtheme.as)
#ifdef __hsp30__
#ifndef __UXTHEME__
#define global __UXTHEME__
#uselib "UxTheme.dll"
        #func global CloseThemeData "CloseThemeData" int
        #func global DrawThemeBackground "DrawThemeBackground" int, int, int, int, sptr, sptr
        #func global DrawThemeBackgroundEx "DrawThemeBackgroundEx" int, int, int, int, sptr, sptr
        #func global DrawThemeEdge "DrawThemeEdge" int, int, int, int, sptr, int, int, sptr
        #func global DrawThemeIcon "DrawThemeIcon" int, int, int, int, sptr, int, int
        #func global DrawThemeParentBackground "DrawThemeParentBackground" int, int, sptr
        #func global DrawThemeText "DrawThemeText" int, int, int, int, wstr, int, int, int, sptr
        #func global EnableThemeDialogTexture "EnableThemeDialogTexture" int, int
        #func global EnableTheming "EnableTheming" int
        #func global GetCurrentThemeName "GetCurrentThemeName" wptr, int, wptr, int, wptr, int
        #func global GetThemeAppProperties "GetThemeAppProperties"
        #func global GetThemeBackgroundContentRect "GetThemeBackgroundContentRect" int, int, int, int, sptr, sptr
        #func global GetThemeBackgroundExtent "GetThemeBackgroundExtent" int, int, int, int, sptr, sptr
        #func global GetThemeBackgroundRegion "GetThemeBackgroundRegion" int, int, int, int, sptr, sptr
        #func global GetThemeBool "GetThemeBool" int, int, int, int, sptr
        #func global GetThemeColor "GetThemeColor" int, int, int, int, sptr
        #func global GetThemeDocumentationProperty "GetThemeDocumentationProperty" wstr, wstr, wptr, int
        #func global GetThemeEnumValue "GetThemeEnumValue" int, int, int, int, sptr
        #func global GetThemeFilename "GetThemeFilename" int, int, int, int, wptr, int
        #func global GetThemeFont "GetThemeFont" int, int, int, int, int, sptr ; (wptr)
        #func global GetThemeInt "GetThemeInt" int, int, int, int, sptr
        #func global GetThemeIntList "GetThemeIntList" int, int, int, int, sptr
        #func global GetThemeMargins "GetThemeMargins" int, int, int, int, int, sptr, sptr
        #func global GetThemeMetric "GetThemeMetric" int, int, int, int, int, sptr
        #func global GetThemePartSize "GetThemePartSize" int, int, int, int, sptr, int, sptr
        #func global GetThemePosition "GetThemePosition" int, int, int, int, sptr
        #func global GetThemePropertyOrigin "GetThemePropertyOrigin" int, int, int, int, sptr
        #func global GetThemeRect "GetThemeRect" int, int, int, int, sptr
        #func global GetThemeString "GetThemeString" int, int, int, int, wptr, int
        #func global GetThemeSysBool "GetThemeSysBool" int, int
        #func global GetThemeSysColor "GetThemeSysColor" int, int
        #func global GetThemeSysColorBrush "GetThemeSysColorBrush" int, int
        #func global GetThemeSysFont "GetThemeSysFont" int, int, sptr ; (wptr)
        #func global GetThemeSysInt "GetThemeSysInt" int, int, sptr
        #func global GetThemeSysSize "GetThemeSysSize" int, int
        #func global GetThemeSysString "GetThemeSysString" int, int, wptr, int
        #func global GetThemeTextMetrics "GetThemeTextMetrics" int, int, int, int, sptr
        #func global GetWindowTheme "GetWindowTheme" int
        #func global HitTestThemeBackground "HitTestThemeBackground" int, int, int, int, int, sptr, int, int, int, sptr
        #func global IsAppThemed "IsAppThemed"
        #func global IsThemeActive "IsThemeActive"
        #func global IsThemeBackgroundPartiallyTransparent "IsThemeBackgroundPartiallyTransparent" int, int ,int
        #func global IsThemeDialogTextureEnabled "IsThemeDialogTextureEnabled" int
        #func global IsThemePartDefined "IsThemePartDefined" int, int, int
        #func global OpenThemeData "OpenThemeData" int, wstr
        #func global SetThemeAppProperties "SetThemeAppProperties" int
        #func global SetWindowTheme "SetWindowTheme" int, wstr, wstr
        ; 未完?
#endif
#endif

uxtheme_sample.hsp

#include "user32.as"
#include "gdi32.as"
#include "uxtheme.as"

#define ptr varptr

  OpenThemeData hwnd, "WINDOW": hTheme = stat
  if hTheme=0: dialog "オープン失敗": end

  gsel 0, -1

  bgscr 2, 320, 240, 0, ginfo_dispx/2-160, ginfo_dispy/2-120

  GetSystemMetrics 4 : cyCap = stat
  GetSystemMetrics 30: cxBtn = stat
  GetSystemMetrics 31: cyBtn = stat

  // 各部のサイズ
  rcCap     = 0, 0, ginfo_winx, 3+cyCap
  rcLeft    = 0, 3+cyCap, 3, ginfo_winy-3
  rcRight   = ginfo_winx-3, 3+cyCap, ginfo_winx, ginfo_winy-3
  rcBottom  = 0, ginfo_winy-3, ginfo_winx, ginfo_winy
  rcBody    = 3, 3+cyCap, ginfo_winx-3, ginfo_winy-3
  rcClose   = 3+2, 3+2, 3+cxBtn-2, 3+cyBtn-2
  rcMax     = ginfo_winx-3-cxBtn+2, 3+2, ginfo_winx-5, 3+cyBtn-2
  rcMin     = rcMax.0-cxBtn+2, 3+2, rcMax.0-2, 3+cyBtn-2
  rcTitl    = rcCap.0+3, rcCap.1+3, rcCap.2-3, rcCap.3

  // 各部のリージョン
  GetThemeBackgroundRegion hTheme, hdc, 1, 1, ptr(rcCap), ptr(hrCap)
  GetThemeBackgroundRegion hTheme, hdc, 7, 1, ptr(rcLeft), ptr(hrLeft)
  GetThemeBackgroundRegion hTheme, hdc, 8, 1, ptr(rcRight), ptr(hrRight)
  GetThemeBackgroundRegion hTheme, hdc, 9, 1, ptr(rcBottom), ptr(hrBottom)
  CreateRectRgnIndirect ptr(rcBody): hrBody = stat

  // ウィンドウ全体のリージョン
  CombineRgn hrBody, hrBody, hrCap, 2
  CombineRgn hrBody, hrBody, hrLeft, 2
  CombineRgn hrBody, hrBody, hrRight, 2
  CombineRgn hrBody, hrBody, hrBottom, 2

  SetWindowRgn hwnd, hrBody, 1

  DeleteObject hrCap
  DeleteObject hrLeft
  DeleteObject hrRight
  DeleteObject hrBottom
  DeleteObject hrBody

  // 各部の"描画"
  DrawThemeBackGround hTheme, hdc, 1, 1, ptr(rcCap), 0
  DrawThemeBackGround hTheme, hdc, 7, 1, ptr(rcLeft), 0
  DrawThemeBackGround hTheme, hdc, 8, 1, ptr(rcRight), 0
  DrawThemeBackGround hTheme, hdc, 9, 1, ptr(rcBottom), 0

  DrawThemeBackGround hTheme, hdc, 18, 1, ptr(rcClose), 0
  DrawThemeBackGround hTheme, hdc, 17, 4, ptr(rcMax), 0
  DrawThemeBackGround hTheme, hdc, 15, 4, ptr(rcMin), 0

  DrawText hdc, "これは縁なしウィンドウ( bgscr )にビジュアルフレームを描画したものです。", -1, ptr(rcBody), $00000010

  redraw 1

  onexit *exit
  stop

*exit
  if hTheme: CloseThemeData hTheme
  end

一気に書くのは大変なので少しづつ書いていきます。書いてくれる人がいればちょこっと付け足してもOKです。