Sign in to follow this  

MFC dialogboxes - keeping window focus

Recommended Posts

Hi- I'm trying to use CDialog's to have users register when they use my company's software. The program is an excel add-in, inside a DLL. When the software first tries to access the DLL, the dialogboxes are displayed. However, there is a problem; when one dialogbox gets closed and another is opened, the focus jumps to the next active window then comes back. It produces a nasty flashing effect or sometimes puts the program in the background. I've been working on this two days straight with no luck! Example Let's say I was going to ask for the license key.. void RegDialog::OnEnterkey() { this->ShowWindow(SW_HIDE); AFX_MANAGE_STATE(AfxGetStaticModuleState()); KeyDialog keyDialog(GetParent(), ptr_User); keyDialog.DoModal(); if(VerifyKey()){ EndDialog(1); return; } this->ShowWindow(SW_SHOW); } //------------------------------------------- This code would flash on ShowWindow(SW_HIDE) I've tried using GotoDlgCtrl(...) to change where which window is active, but it didn't work. I've tried making an invisible main CDialog and creating all the others off of that, no luck there either. For now I'm making all my dialogs using the handle, AfxGetMainWnd() so that hopefully it would put control back to the main window. nothing works : ( Has anyone seen anything similar to this or have any ideas?? Anything would be appreciated! Brad

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this