オーナードロータイトルバー(なんてあるのか?)みたいなことをする場合に、使えるかな。いや使えんな…。タイトルバー右横のコントロールボックスあたりの描画は、DrawFrameControl API 関数を調べてね。
Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long, pcRect As RECT, ByVal un As Long) As Long
Public Const DC_ACTIVE = &H1 '背景色はアクティブなキャプションバーの色 Public Const DC_SMALLCAP = &H2 '小さなキャプションを描画 Public Const DC_ICON = &H4 'ウインドウのアイコンを描画 Public Const DC_TEXT = &H8 'タイトルキャプションを描画 Public Const DC_INBUTTON = &H8 '背景色はボタン表面色 以下関数で、GetTitleBarRect() という関数が登場するが、これに関しては「タイトルバーのサイズを取得する」のページを参照。
'--------------------------------------------------------------- ' 関数名:DrawTitleBar ' 機 能:タイトルバーを描画する ' 引 数: (in) hWnd … ウインドウハンドル ' (in) hDC … 描画先のデバイスコンテキストのハンドル ' 返り値: なし '--------------------------------------------------------------- Public Function DrawTitleBar(ByVal hWnd As Long, ByVal hDC As Long) As Long Dim udtRECT As RECT Call GetTitleBarRect(hWnd, udtRECT) With udtRECT .Right = .Right - .Left .Bottom = .Bottom - .Top .Left = 0 .Top = 0 End With 'アクティブ時のタイトルバー Call DrawCaption(hWnd, hDC, udtRECT, DC_ICON Or DC_TEXT Or DC_ACTIVE) '非アクティブ時のタイトルバー 'Call DrawCaption(hWnd, hDC, udtRECT, DC_ICON Or DC_TEXT Or DC_INBUTTON) End Function |