void Main_OnCommand(HWND hwnd, int id, HWND /* hwndCtl */, UINT /* codeNotify */)
{
    switch (id)
    {
    case ID_FILE_EXIT:
        // The user wants to exit, so send our window a close message
        SendMessage(hwnd, WM_CLOSE, 0, 0L);
        break;

    case ID_HELP_ABOUT:
        // Display the "About" dialog
        DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
        break;

    case ID_PROPERTIES:
        ShowOptions(hwnd);
        break;

    case ID_APPBAR_REGISTER:
        AppBar_Register(hwnd);
        break;

    case ID_APPBAR_UNREGISTER:
        AppBar_UnRegister(hwnd);
        break;

    case ID_APPBAR_AUTOHIDE:
        AppBar_SetAutoHide(hwnd, TRUE);
        break;

    case ID_APPBAR_NOAUTOHIDE:
        AppBar_SetAutoHide(hwnd, FALSE);
        break;

    case ID_APPBAR_TOP:
        AppBar_SetSide(hwnd, ABE_TOP);
        break;

    case ID_APPBAR_BOTTOM:
        AppBar_SetSide(hwnd, ABE_BOTTOM);
        break;

    case ID_APPBAR_LEFT:
        AppBar_SetSide(hwnd, ABE_LEFT);
        break;

    case ID_APPBAR_RIGHT:
        AppBar_SetSide(hwnd, ABE_RIGHT);
        break;
    }
}
BOOL CAppBar::AppBar_NoAutoHide()
{
    HWND hwndAutoHide;
    BOOL fSuccess;  

    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = pHandler;
    abd.uEdge = m_pOptions->uSide;
  
    // First let's check to see if we're the appbar attached to the
    // side of the screen
    abd.uEdge = m_pOptions->uSide;
    hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
    if (hwndAutoHide != pHandler)
     {
       //  DebugMsg(TEXT("ERROR: We're not hidden currently\r\n"));
          return (FALSE);
       }
    
       // We can autohide or stop autohide on this edge.  Set the autohide style.
        abd.lParam = FALSE;         

    fSuccess = (BOOL) SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd);
    if (!fSuccess)
    {
    // DebugMsg(TEXT("ERROR: Error trying to set autohidebar.\r\n"));
      //  ErrorHandler();
        return (FALSE);
    }
    else
    {
        // Need to change the appbar to get the screen desktop space
        // back.  Also need to reattach the appbar to that edge of the
        // screen.
        m_pOptions->fAutoHide = FALSE;        
      
        m_pOptions->cxWidth = g_cxWidth;
        m_pOptions->cyHeight = g_cyHeight;

        AppBar_SetSide(m_pOptions->uSide);   
    }

   return (TRUE);
}
BOOL Main_OnCreate(HWND hwnd, LPCREATESTRUCT /* lpCreateStruct */)
{
    // Initialize the common control DLL
    InitCommonControls();

    // Allocate an OPTIONS struct and attach to the appbar
    POPTIONS pOptions = (POPTIONS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPTIONS));
    if (pOptions)
    {
        SetWindowLongPtr(hwnd, 0,(LONG_PTR)pOptions);
    }
    else
    {
        return FALSE;
    }

    pOptions->fAutoHide = FALSE;
    pOptions->fOnTop = FALSE;
    pOptions->uSide = ABE_TOP;
    pOptions->cxWidth = CX_DEFWIDTH;
    pOptions->cyHeight = CY_DEFHEIGHT;

    // Register the appbar and attach it to the top by default
    AppBar_Register(hwnd);
    AppBar_SetSide(hwnd, ABE_TOP);

    // Create the fonts for drawing in the client area
    LOGFONT lf;
    ZeroMemory(&lf,sizeof(LOGFONT));
    lf.lfHeight = 45;
    lf.lfEscapement = 2700;
    lf.lfOrientation = 0;
    StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), L"Arial");
    s_hFontLeft = CreateFontIndirect(&lf);

    lf.lfEscapement = 0;
    s_hFontTop = CreateFontIndirect(&lf);

    return TRUE;
}