Click here to Skip to main content
16,017,100 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 169.7K   5.5K   48   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 
It's a nice idea, and the graphics look quite appealing.

BUT

Seriously? OMG | :OMG: Perhaps there's an error with my pc, I only see 2 pages for your article, including the page header and whatnot. There are a few brief blocks that demonstrate how the code should be included, but not an iota of info on challenges faced, methods employed or gotchas to watch for when doing something similar, or even just using this code. These types of information are what turn a good/great piece of code into a functional and educational article. Again, thanks for the code, & the pictures are pretty - a little more content would be nice. (if not demanded by some)

You may like to take a look at: http://www.codeproject.com/KB/system/inject2exe.aspx[^] Now, THAT is what one could call an article - weighing in at around 45 pages....

Add to that, the fact that it doesn't run straight out of the box, nor is there any instructions on which VS redistributable package to grab.

TXBar.exe - Unable to Locate Component
  This application has failed to start because MFC42D.DLL was not found. Re-installing the application may fix the problem.


FAIL!
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.