Solved

Keeping the modeless dialog active in an MDI application

Posted on 2001-07-10
12
469 Views
Last Modified: 2013-11-20
Hi,
  I have created an MDI application(VC++ 6.0). It contains a small dialog which is opened when the application opens. This dialog is a modeless dialog containing a few options (settings) which can be incorporated in the application. It is something like a control bar or a toolbar in a typical MFC application. The problem here is tht when I click outside the modeless dialog to work on the document, the dialog title bar is deactivated(ie: the focus is removed). I want the modeless dialog to remain active along with the active document in my MDI application. Is it possible to hav 2 windows active at the same time? If so then can anybody please provide me with the solution?
Waiting for a reply eagerly
Thanx
Shilpa
0
Comment
Question by:Shilpa
  • 6
  • 5
12 Comments
 
LVL 2

Expert Comment

by:MadYugoslav
Comment Utility
No. This is not possible to have two active window at the same time.
But, You can have blue title bar (or other).
0
 

Expert Comment

by:mohd_shafi
Comment Utility
I agree that in windows there cannot be more than one window active at any given time.
 But one crazy kind of solution is, you have to go to the display properties and in the appearance tab, change the Active and Inactive Title bar color to whatever color you please.
0
 

Author Comment

by:Shilpa
Comment Utility
 But if u say tht it is not possible to hav two windows active at the same time, then how do they hav it for control bars in applications which is active with the active document opened, coz Control bar is also a window. There must be some way to make it active though.
Can anybody out there plz suggest some solution to it??
Thanx
Shilpa
0
 

Expert Comment

by:mohd_shafi
Comment Utility
Yes Shilpa,
 One possible solution to your problem is to use CDialogBar. I have given it in steps.
I have tried this out in an MDI application
1. Create your Dialog Resource using Insert Dialog, So you vil get the dialog id say IDD_SHILPADIALOG
2. In the Dialog Properties, change the style to "child" from "popup". Change the Border to "None"
3. See that the "visible" check box is not selected in "more styles" page
4. Declare a member variable "m_Mydlg" of type CDialogBar in your Mainframe.h file
5. Now in your CMainFrame class at the end of the "OnCreate" function add the following code
   (take enough care that you do not write it after return statement)
   
     if(!m_Mydlg.Create(this, IDD_SHILPADIALOG, CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_SHILPADIALOG))
     {
       TRACE0("You have missed something shilpa\n");  
          // approach me if this happens
          return -1;
     }
     
     m_Mydlg.EnableDocking(NULL);     // comment this if you want docking

     // uncomment next line if you want docking
     //m_Mydlg.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM);

     // 2nd parameter should be the point where dialog is displayed
     FloatControlBar(&m_Mydlg, CPoint(10,10));
     
     return 0;
     }     // end of CMainFrame::OnCreate(...)
6. After this, you can click accept "comment as answer", my e-mail id is mohd_shafi@hotmail.com

7. That's it

SHAFI
0
 

Author Comment

by:Shilpa
Comment Utility
Hi Shafi,
   Initially I started with a dialog bar, but had to drop the idea since dialog bar was not handling some command handlers for some controls, and it was not invalidating . It was then tht I thought of using the modeless dialog box. I had rightly tried out the same thing tht u hav suggested before. But now I wud like to continue with the modeless dialog box. If u can still suggest somethin better I wud be grateful.
Thanx once again
Shilpa
0
 

Expert Comment

by:mohd_shafi
Comment Utility
Hi again,
 I have tried using different controls in the dialog bar and i was successfull too. I even implemented command handlers for some of the controls.
 can u let me know what were the controls which you could not handle properly. I still think dialog bar is the best option
SHAFI
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Shilpa
Comment Utility
Hi Shafi,
   I tried using the button control on the dialog bar. Presently wht I hav implemented on the dialog bar is tht, when the user clicks on the button control, he gets a popup generated close to the button, showing 3 different options. I managed to get all this working, but when it came to handling the events for the menu options of the popup menu, I was totally lost. I donno how to disable and enable the menu options through the dialog bar. I m sooo very confused. Is there a solution to this problem shafi??
If yes then please do lemme know abt the same.
Waiting eagerly for ur reply.
Thanx once again
Shilpa
0
 

Expert Comment

by:mohd_shafi
Comment Utility
Hy Shilpa,
  well shilpa as far as i have understood, you have created the dialog bar and have handled the button control. I hope u have

handled the button in the CMainFrame class only.
For this you might have dun somethin like this

In Message Map
 ON_BN_CLICKED(ON_BN_CLICKED(IDOK, OnOK)

Then in OnOK
 void CMainFrame::OnOK()
{
     ::AfxMessageBox("Is it OK ");
}

now uar problem iz to get a popup menu handled properly?

am i korect ?

IF( iam korect )
 then let me no, wat code u have written to popup the menu, and where is the exact problem in the code.
 i think i have the solution
ELSE
 plz help me out. let me know how and where u have implemented OnOK, OK
ENDIF

 i think v r deviating from the original problem now, but Kool. i hav also startd typin broken english now, courtesy ..

Awatin reply
SHAFI
0
 

Author Comment

by:Shilpa
Comment Utility
Hi Shafi,
   Thanx first for ur efforts....
I m sorry v r actually deviating from our topic, but I seriously need help on it since I hav started with a dialog bar and given up on modeless dialog(from ur suggestion.
  Initially when I created a button on the dialog bar, I had a problem since the button was always shown disabled on opening of the application. Then I came across this article on Codeguru, which said tht u hav to call this below function in the same class ie: of dialog bar
OnUpdateButton(CCmdUI *pCmdUI)
{
  pCmdUI->Enable();
}
And .....it worked..
Then I incorporated the code to popup a menu when the user clicks on the same button. For tht I dowloaded a CCoolBtn class frm Codeguru itself, which allows u to create a dynamic menu bar. (IF u wud like to go thru the class lemme know ur email id and I will send it across). The code worked and I get the dynamically created menu on clicking the button, at the same time I can even handle the events on clicking on the menu items within the menu. But NOW the only problem is when I click on one menu option, I need to disable the other menu option. And after trying all possible ways I hav miserably failed in my attempts. If u can suggest a solution plz plz plz lemme know at the earliest. Waiting for ur response
Thanx once again
Shilpa
0
 

Expert Comment

by:mohd_shafi
Comment Utility
Hi shilpa,
As i had writtn u in the previos mail, it is not necessary to derive a class from CDialogBar, I had also given the steps as to how the CDialogBar object has to be created in the CMainFrame class in OnCreate() function remember.
 And after that i had given steps to handle the CDialogBar OK button(or for that reason handling any other button is quite simple). For that reson, all that codeguru stuff is not required to enable the buttons on the dialog box
 You have to just create the dialog template resource, add whatever buttons you like into that using resource editor. And while creating the CDialogBar using CDialogBar::Create(...) function just specify the dialog resource ID. Add the macros to the MESSAGE_MAP and function prototypes and defintions ALL IN YOUR CMainFrame class only in order to handle buttons and menus.
 I have created a very simple application(MDI, VC++ 6.0 app) with dialog bar with the button handlers, i can send it  across to u by email(ur email id plz). My email id is "mohd_shafi@hotmail.com"(Bangalore)(INDIA). Meanwhile u can send your work on this e-mail id.

Regards
SHAFI

0
 

Accepted Solution

by:
mohd_shafi earned 100 total points
Comment Utility
Hi shilpa,
As i had writtn u in the previos mail, it is not necessary to derive a class from CDialogBar, I had also given the steps as to how the CDialogBar object has to be created in the CMainFrame class in OnCreate() function remember.
 And after that i had given steps to handle the CDialogBar OK button(or for that reason handling any other button is quite simple). For that reson, all that codeguru stuff is not required to enable the buttons on the dialog box
 You have to just create the dialog template resource, add whatever buttons you like into that using resource editor. And while creating the CDialogBar using CDialogBar::Create(...) function just specify the dialog resource ID. Add the macros to the MESSAGE_MAP and function prototypes and defintions ALL IN YOUR CMainFrame class only( in order to handle buttons and menus).
 I have created a very simple application(MDI, VC++ 6.0 app) with dialog bar with the button handlers, i can send it  across to u by email(ur email id plz). My email id is "mohd_shafi@hotmail.com"(Bangalore)(INDIA). Meanwhile u can send your work on this e-mail id.

Regards
SHAFI

0
 

Author Comment

by:Shilpa
Comment Utility
Thanx a lot Shafi,
   u made my life simple.

Till then Keep the Spirit

Shilpa
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now