Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Active window on top

Posted on 1999-07-23
Medium Priority
Last Modified: 2013-11-20
This shouldn't be too hard, but it's annoying me.
I have an application window that creates another window at startup. (It's a button now, but it could be any control in which I can show a video.) This all works fine, but the child window (tstApp) is always overlapping the app window (main), even if it doesn't have the focus.
How can I make it such that the active window (having the focus) is on top?

HWND h=m_pMainWnd->m_hWnd;
HINSTANCE tstInst=AfxGetInstanceHandle();
HWND tstApp = CreateWindow("BUTTON", "VideoForm", WS_OVERLAPPEDWINDOW, 200, 20, 640, 480, h, 0, tstInst, 0);
ShowWindow(tstApp, SW_SHOW);
Question by:vendrig
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

VCGuru earned 80 total points
ID: 1311155
In your CreateWindow function change the h to 0. it works. If you use
HWND tstApp = CreateWindow("BUTTON", "VideoForm", WS_OVERLAPPEDWINDOW, 200, 20, 640, 480, h, 0, tstInst, 0);
then the created window becomes a child and you can't hide it.
HWND tstApp = CreateWindow("BUTTON", "VideoForm", WS_OVERLAPPEDWINDOW, 200, 20, 640, 480, 0, 0, tstInst, 0);  

I do not see and side effects. There are no memory leaks and the window quits when you quit the application.

Author Comment

ID: 1311156
Thanks, it works.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question