?
Solved

Dissappearing window in CTabCtrl

Posted on 2003-03-16
3
Medium Priority
?
572 Views
Last Modified: 2013-11-20
I'm creating a MFC dialog based application in VC6.  The dialog only contains one control; a CTabCtrl.  Each page of the tab control is linked to another dialog (with its own CDialog-derived class).  All the page dialogs are created in the main dialog with the tab control as the parent.  Each page dialog is then hidden and only the correct one is shown.  When a tab is changed, the current page is hidden and the new page is shown (usign ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW)).

The above part all works and the pages are shown as expected.  The problem comes when any control on the page dialog has the focus and I press ENTER.  The page then dissapears.  It is not destroyed, since it reappears when I switch tabs and then back to the page where I was.  It is almost as if it is moved to below the tab control, or if some code redraws over my dialog page.  If, for example, a edit control has the focus and I press ENTER, the page dissapears.  If I type some characters, switch tabs and switch tabs again back to the original page, my page is shown again with the text typed in the edit control.

I've tried to set break points to all the message handlers I could think of without any success.  I can not find why the page is hidden.

Any ideas?
0
Comment
Question by:cfm
[X]
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
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1000 total points
ID: 8150123
I guess the same happens when you press Esc. Overwrite OnOK and OnCancel in each dialog:

void CMyDlg::OnCancel()
{
//     CDialog::OnCancel();  // don't call base class implementation
}
void CMyDlg::OnOK()
{
//     CDialog::OnOK();
}
0
 
LVL 3

Expert Comment

by:Nosfedra
ID: 8152816
I guess this solves the problem Alex, but wouldn't be better to override the OnOK and OnCancel methods for the child dialogs instead of overriding the parent dialog's methods?

Afterall, using Enter and Esc to close dialogs is a pretty well established behavior for closing dialog boxes.
What do you think?

If you want to prohibit the CR close the dialog box when in an edit box (and only then), be sure to set the edit box's style to ES_WANTRETURN (either directly on init dialog or from the dialog editor propery pages).

By the way, why not moving to propery pages instead of tab controls if you are using just one big control (the tab ctrl) on your dialog?

Regards,
--Razvan
0
 

Author Comment

by:cfm
ID: 8157133
AlexFM.  That solved it.  I did think of that as a possible problem, but only related to the parent dialog.  Never thought about implementing it for the page dialogs as well.  Anyway, it is working now.  Thanks
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

762 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