Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: window focus and tab order problem with CDialog (Read 2699 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

window focus and tab order problem with CDialog

I'm having a bit of a difficulty with the creation of my main dialog window (which is done within the context of a DSP component).  Here is what I am doing to create the window :

Code: [Select]
AfxWinInit(core_api::get_my_instance(), NULL, "", SW_HIDE);

mainWindow = new CMainWindow();
mainWindow->Create((UINT)IDD_ODDCAST, mainApp.GetMainWnd());    
//mainWindow->Create((UINT)IDD_ODDCAST, CWnd::FromHandle(core_api::get_main_window()));    
//mainWindow->Create((UINT)IDD_ODDCAST, AfxGetMainWnd());

The window is created, however it always stays in front of the foobar2k window.  Additionally, in all the child dialogs, you are unable to tab between fields.  I'm pretty sure this has something to do with the parent ownership of the Create() call, and so I tried a few other things (they are commented out above).  But all of them seem to behave the same way.  I use this same technique for the winamp version of my plugin (which behaves properly), and in that case, the line with AfxGetMainWnd() is the right invocation.

In the above case, I'm declaring mainApp as :
Code: [Select]
CWinApp mainApp;

and CMainWindow is a CDialog.

Any ideas ?

window focus and tab order problem with CDialog

Reply #1
Quote
I'm having a bit of a difficulty with the creation of my main dialog window (which is done within the context of a DSP component).
Are you sure that your window is created in the main thread? Or in a thread with a message loop?

Quote
Additionally, in all the child dialogs, you are unable to tab between fields.
Use modeless_dialog_manager::add() to register your window as a modeless dialog. Call modeless_dialog_manager::remove() before your window is destroyed.

Quote
I'm pretty sure this has something to do with the parent ownership of the Create() call, and so I tried a few other things (they are commented out above).  But all of them seem to behave the same way.  I use this same technique for the winamp version of my plugin (which behaves properly), and in that case, the line with AfxGetMainWnd() is the right invocation.
What do you mean by properly? It is perfectly normal for a window to stay above its parent. Use the desktop window or null as parent, if you don't want that.

window focus and tab order problem with CDialog

Reply #2
Quote
Quote
Additionally, in all the child dialogs, you are unable to tab between fields.
Use modeless_dialog_manager::add() to register your window as a modeless dialog. Call modeless_dialog_manager::remove() before your window is destroyed.

this is exactly what I was looking for.  Adding this call fixed my tabbing issue, and specifying NULL for the parent on the create fixed my focus issue...thanks a whole lot for this

oddsock