Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A TXPBAR with GDI+ for MFC

0.00/5 (No votes)
24 Jun 2008 2  
A XP bar with GDI+ for MFC, like the Apple dockbar.

TXBar

Introduction

This is an XP dockbar program like Apple's dockbar. It switches scrolling with a flip animation effect.

Using the code

Step 1. This step inludes loading the library "User32.DLL" for the "UpdateLayeredWindow" function. This is a per-pixel-alpha transparence. Therefore, we have no more jagged edges.

hFuncInst = LoadLibrary("User32.DLL"); 
BOOL bRet=FALSE;
if(hFuncInst){ 
    UpdateLayeredWindow=(MYFUNC)GetProcAddress(hFuncInst, "UpdateLayeredWindow");
}
else
{
    AfxMessageBox("User32.dll ERROR!");
    exit(0);
}

Step 2. Initialize GDI+.

m_Blend.BlendOp=0; //the only BlendOp defined in Windows2000
m_Blend.BlendFlags=0; //nothing else isspecial...
m_Blend.AlphaFormat=1;
m_Blend.SourceConstantAlpha=255;//AC_SRC_ALPHA

Step 3. Now, the DrawTXBar function.

void DrawTXBar()
{
    DWORD dwExStyle=GetWindowLong(m_hWnd,GWL_EXSTYLE);
    if((dwExStyle&0x80000)!=0x80000)
    SetWindowLong(m_hWnd,GWL_EXSTYLE,dwExStyle^0x80000);
    BOOL bRet=FALSE;
    bRet= UpdateLayeredWindow( m_hWnd,hdcScreen,&ptWinPos, 
          &sizeWindow,m_hdcMemory,&ptSrc,0,&m_Blend,2);
    //UpdateLayeredWindow" must By execute 
    //one hypo- one to Update the alpha window's Image.
    ...
}

Points of interest

The API function "UpdateLayeredWindow" must by executed to update the alpha window's image.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here