Click here to Skip to main content
Licence CPOL
First Posted 24 Jun 2008
Views 27,116
Downloads 1,635
Bookmarked 32 times

A TXPBAR with GDI+ for MFC

By | 24 Jun 2008 | Article
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)

About the Author

skinui

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

Member

http://www.skinui.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmembermanoj kumar choubey0:13 18 Feb '12  
General为什么有中文注释 Pinmemberhpking19:57 8 Oct '09  
Generalperfect PinmemberMartial Spirit23:38 10 Jul '09  
GeneralYou are out of your mind!You must delete it! Pinmembergrergerg21:08 29 Sep '08  
Generaladvertisement and virus! Pinmembergrergerg20:44 29 Sep '08  
RantThanks everyone Pinmemberskinui4:28 25 Jun '08  
GeneralRe: Thanks everyone Pinmembergrergerg21:07 29 Sep '08  
GeneralWell, it's a start anyway Pinmemberenhzflep13:48 24 Jun '08  
GeneralRe: Well, it's a start anyway PinmemberRedFraggle2:02 25 Jun '08  
GeneralRe: Well, it's a start anyway Pinmemberskinui4:38 25 Jun '08  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 24 Jun 2008
Article Copyright 2008 by skinui
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid