Results 1 to 3 of 3

Thread: Making Window Appear to Have Focus

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Hi, how can I redraw my window's title bar? I have a foreign window tied to my navigational window. The foreign window doesn't have a title bar -- so when it has focus, I want to make my window appear to have focus. I'm using subclassing and can detect when the user is in this foreign window, but what I'm using to redraw my window's title bar blue isn't working:
    Code:
    Option Explicit
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
    Private Const COLOR_ACTIVEBORDER = 10
    Private Const WM_NCACTIVATE = &H86
    
    
    If msg = WM_NCACTIVATE Then     'Foreign Window Activation/Deactivation
        If wp = 1 Then      'Has focus
                
            'Get Device Context of My Window Including Non-client Area - This Works
            lhDC = GetWindowDC(Form1.hwnd)
                
            'Set Background Color of Title Bar - This Doesn't Seem to Change Anything
            Call SetBkColor(lhDC, GetSysColor(COLOR_ACTIVEBORDER))
                
            'Release DC to My Window
            Call ReleaseDC(Form1.hwnd, lhDC)
        End If
    End If
    [Edited by WadeD on 05-25-2000 at 01:38 PM]
    Wade

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    You could try to use the FlashWindow api call. It toggles the titlebar from active to non-active and back.

    Public Declare Function FlashWindow Lib "user32" Alias "FlashWindow" (ByVal hwnd As Long, ByVal bInvert As Long) As Long

    The returnvalue is true (nonzero) if the window was active before the call.

    Pass the windows hwnd, and True for bInvert to toggle the windows caption, or False to restore the original state.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Thanks
    Wade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width