OC: Additional dialog-related Win API functions


Version: 2018

Type: Features

Category: Programming

Subcategory: Origin C

Jira: ORG-17258


Support added for flashing dialog title bar, etc via the functions FlashWindowEx() and FlashWindow().

For example:

FLASHWINFO st;
st.cbSize = sizeof(st);
st.hwnd = s_pMyDlg->GetSafeHwnd();
st.dwFlags = FLASHW_CAPTION;
st.uCount = 3;
st.dwTimeout = 0;
 
FlashWindowEx(&st);{code}
EVENTS_BEGIN_DERIV(HTMLDlg)
    // Others events.
    OnActivate(OnActivate)
EVENTS_END_DERIV
 
BOOL OnInitDialog()
{
    HTMLDlg::OnInitDialog();
 
    HWND hwnd = GetSafeHwnd();
 
    // Add WS_EX_LAYERED to this window style.
    SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
 
    // Make this window 60% alpha.
    SetLayeredWindowAttributes(hwnd, 0, (255 * 60) / 100, LWA_ALPHA);
 
    return TRUE;
}
 
void OnActivate(UINT nState, HWND hwndOther, BOOL bMinimized)
{
    HWND hwnd = GetSafeHwnd();
 
    if( WA_INACTIVE != nState )
    {
        // Window activated.
         
        // Remove WS_EX_LAYERED from this window style.
        SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
 
        // Ask the window and its children to repaint.
        // Comment out if dialog flickers.
        RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
    }
    else
    {
        // Window de-activated.
 
        // Add WS_EX_LAYERED to this window style.
        SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
 
        // Make this window 60% alpha.
        SetLayeredWindowAttributes(hwnd, 0, (255 * 60) / 100, LWA_ALPHA);
    }
}