Click here to Skip to main content
15,885,435 members
Articles / Desktop Programming / MFC
Article

A TXPBAR with GDI+ for MFC

Rate me:
Please Sign up or sign in to vote.
3.57/5 (13 votes)
24 Jun 2008CPOL 168.5K   5.5K   47   10
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO http://www.skinui.com
Canada Canada
http://www.skinui.com

Comments and Discussions

 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey18-Feb-12 0:13
professionalManoj Kumar Choubey18-Feb-12 0:13 
General为什么有中文注释 Pin
hpking8-Oct-09 19:57
hpking8-Oct-09 19:57 
Generalperfect Pin
Martial Spirit10-Jul-09 23:38
Martial Spirit10-Jul-09 23:38 
GeneralYou are out of your mind!You must delete it! Pin
grergerg29-Sep-08 21:08
grergerg29-Sep-08 21:08 
Generaladvertisement and virus! Pin
grergerg29-Sep-08 20:44
grergerg29-Sep-08 20:44 
RantThanks everyone Pin
skinui25-Jun-08 4:28
skinui25-Jun-08 4:28 
GeneralRe: Thanks everyone Pin
grergerg29-Sep-08 21:07
grergerg29-Sep-08 21:07 
GeneralWell, it's a start anyway Pin
enhzflep24-Jun-08 13:48
enhzflep24-Jun-08 13:48 
GeneralRe: Well, it's a start anyway Pin
RedFraggle25-Jun-08 2:02
RedFraggle25-Jun-08 2:02 
GeneralRe: Well, it's a start anyway Pin
skinui25-Jun-08 4:38
skinui25-Jun-08 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.