Click here to Skip to main content
13,189,324 members (65,290 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 20 Apr 2006

Keep your Window Always On Top

, 20 Apr 2006
Rate this:
Please Sign up or sign in to vote.
Keep your Window Always On Top


This article show you how to keep a window always on top.
A friend asked me about this question,I searched it on the internet and found
some codes but none of them works well,so I think it is necessary to write a
article about to help the beginners.

To keep a window always on top,you should do as flowing:
1.Create a Dialog based project(Similarly,you can create other projects).
2.Add flowing declare in *Dlg.h between "{{AFX_MSG" and "AFX_MSG}}"

afx_msg int OnCreate(LPCREATESTRUCT lpRes);

3.Add flowing function in *Dlg.cpp:

int *Dlg::OnCreate(LPCREATESTRUCT lpRes)
return CDialog::OnCreate(lpRes);

4.Modify Message map codes,add flowing sentence between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP():


After doing above,compile and build you project,you will find that your window will
keep always on top!That's it ,thank you!


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


About the Author

Web Developer
China China
I am a developper from china.I am a Jsp and Java developper some years ago and now I am a C++ developper.In my spare time,I like to develop some small projects and enjoy the results of executing the projects ,also,I like to play
the game of go though I am not a good player!
If I was a rich man,I would travel all over the world!

You may also be interested in...


Comments and Discussions

GeneralNot working..... Pin
Milind Shingade24-Jul-07 23:09
memberMilind Shingade24-Jul-07 23:09 
GeneralRe: Not working..... Pin
cristitomi4-Oct-07 11:24
membercristitomi4-Oct-07 11:24 
GeneralRe: Not working..... Pin
theCPkid17-Aug-09 22:35
membertheCPkid17-Aug-09 22:35 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171016.2 | Last Updated 20 Apr 2006
Article Copyright 2006 by duguyitian
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid