Modal MDI child ... how ?

Is it possible to modify the behaviour of already displayed MDI child
to become modal (it beeps when you click on it). Currently, it I
iterate through all displayed views and set

view->GetParent()->EnableWindow(enable);

user can't tell that other views are disabled, as there is no visual
or audible indication of it.

Btw, some frames might have toolbar attached to them. 

Any help is appreciated,

Jan
0
janitor1 (17)
1/18/2006 10:38:47 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1045 Views

Similar Articles

[PageSpeed] 50

To answer my own question.

To make child mdi appear modal amongst other mdi children do the
following:

in CMainFrame.h add the following 

public:
CWnd * m_pActiveView;

in CMainFrame constructor add the following:

m_pActiveView=NULL;


in CChildFrame add the WM_MDIACTIVATE handler:

void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd,
CWnd* pDeactivateWnd)
{
	if(bActivate && ((CMainFrame*)AfxGetMainWnd())->m_pActiveView
&& ((CMainFrame*)AfxGetMainWnd())->m_pActiveView!=this)
	{
		MessageBeep(-1);

		FLASHWINFO fi;
		fi.cbSize=sizeof(fi);

fi.hwnd=((CMainFrame*)AfxGetMainWnd())->m_pActiveView->m_hWnd;
		fi.dwFlags=FLASHW_ALL;
		fi.uCount=8;
		fi.dwTimeout=50;
		
		::FlashWindowEx(&fi);


((CMDIFrameWnd*)AfxGetMainWnd())->MDIActivate(((CMainFrame*)AfxGetMainWnd())->m_pActiveView);

		return;
	}

	CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd,
pDeactivateWnd);
}

also add PreTranslateMessage hnadler

BOOL CChildFrame::PreTranslateMessage(MSG* pMsg)
{
	if(((CMainFrame*)AfxGetMainWnd())->m_pActiveView &&
((CMainFrame*)AfxGetMainWnd())->m_pActiveView!=this)
	{
		if(pMsg->message==WM_PAINT)
		{
			return
CMDIChildWnd::PreTranslateMessage(pMsg);
		}
		return TRUE;
	}

	return CMDIChildWnd::PreTranslateMessage(pMsg);
}

Now, in your view add the following:

void CeditorView:MakeModal(BOOL modal)
{
	if(modal)

((CMainFrame*)AfxGetMainWnd())->m_pActiveView=GetParent();
	else
		((CMainFrame*)AfxGetMainWnd())->m_pActiveView=NULL;

	return;
}

So, to make the mdi child modal, just call MakeModal(TRUE). When done,
call MakeModal(FALSE).

When in modal mode, all other mdi children that are CChildFrame will
become disabled (as they receive only WM_PAINT message). When you
click on the disabled frame, it beeps and modal window will flash 8
times to give a visual cue. 

Of course, real programmer would have something like 

protected:
CWnd * m_pActiveView;

((CMainFrame*)AfxGetMainWnd())->SetActiveView(active_view)

instead of
((CMainFrame*)AfxGetMainWnd())->m_pActiveView

Oh, well...

Miro (aka Jan Itor)

0
janitor1 (17)
1/20/2006 11:26:07 PM
Glad you got that to work...

Tom

"Jan Itor" <janitor@gb.com> wrote in message 
news:a8r2t1dp2lbonrrviugjg1oh65higm84je@4ax.com...
> To answer my own question.
>
> To make child mdi appear modal amongst other mdi children do the
> following:
>
> in CMainFrame.h add the following
>


0
tserface (3861)
1/20/2006 11:59:43 PM
One more thing:

In CChildFrame override DestroyWindow

BOOL CChildFrame::DestroyWindow()
{
	if(((CMainFrame*)AfxGetMainWnd())->m_pActiveView &&
((CMainFrame*)AfxGetMainWnd())->m_pActiveView==this)
	{
		((CMainFrame*)AfxGetMainWnd())->m_pActiveView=NULL;
	}

	return CMDIChildWnd::DestroyWindow();
}

This is to prevent setting non-existent window as active window,
resulting in default menu in main frame, even though there are other
documents open.

Miro (Jan Itor )

On Fri, 20 Jan 2006 15:26:07 -0800, Jan Itor <janitor@gb.com> wrote:

>To answer my own question.
>
>To make child mdi appear modal amongst other mdi children do the
>following:
>
>in CMainFrame.h add the following 
>
>public:
>CWnd * m_pActiveView;
>
>in CMainFrame constructor add the following:
>
>m_pActiveView=NULL;
>
>
>in CChildFrame add the WM_MDIACTIVATE handler:
>
>void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd,
>CWnd* pDeactivateWnd)
>{
>	if(bActivate && ((CMainFrame*)AfxGetMainWnd())->m_pActiveView
>&& ((CMainFrame*)AfxGetMainWnd())->m_pActiveView!=this)
>	{
>		MessageBeep(-1);
>
>		FLASHWINFO fi;
>		fi.cbSize=sizeof(fi);
>
>fi.hwnd=((CMainFrame*)AfxGetMainWnd())->m_pActiveView->m_hWnd;
>		fi.dwFlags=FLASHW_ALL;
>		fi.uCount=8;
>		fi.dwTimeout=50;
>		
>		::FlashWindowEx(&fi);
>
>
>((CMDIFrameWnd*)AfxGetMainWnd())->MDIActivate(((CMainFrame*)AfxGetMainWnd())->m_pActiveView);
>
>		return;
>	}
>
>	CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd,
>pDeactivateWnd);
>}
>
>also add PreTranslateMessage hnadler
>
>BOOL CChildFrame::PreTranslateMessage(MSG* pMsg)
>{
>	if(((CMainFrame*)AfxGetMainWnd())->m_pActiveView &&
>((CMainFrame*)AfxGetMainWnd())->m_pActiveView!=this)
>	{
>		if(pMsg->message==WM_PAINT)
>		{
>			return
>CMDIChildWnd::PreTranslateMessage(pMsg);
>		}
>		return TRUE;
>	}
>
>	return CMDIChildWnd::PreTranslateMessage(pMsg);
>}
>
>Now, in your view add the following:
>
>void CeditorView:MakeModal(BOOL modal)
>{
>	if(modal)
>
>((CMainFrame*)AfxGetMainWnd())->m_pActiveView=GetParent();
>	else
>		((CMainFrame*)AfxGetMainWnd())->m_pActiveView=NULL;
>
>	return;
>}
>
>So, to make the mdi child modal, just call MakeModal(TRUE). When done,
>call MakeModal(FALSE).
>
>When in modal mode, all other mdi children that are CChildFrame will
>become disabled (as they receive only WM_PAINT message). When you
>click on the disabled frame, it beeps and modal window will flash 8
>times to give a visual cue. 
>
>Of course, real programmer would have something like 
>
>protected:
>CWnd * m_pActiveView;
>
>((CMainFrame*)AfxGetMainWnd())->SetActiveView(active_view)
>
>instead of
>((CMainFrame*)AfxGetMainWnd())->m_pActiveView
>
>Oh, well...
>
>Miro (aka Jan Itor)

0
janitor1 (17)
1/21/2006 3:47:28 AM
Thanks !

Miro


On Fri, 20 Jan 2006 15:59:43 -0800, "Tom Serface" <tserface@msn.com>
wrote:

>Glad you got that to work...
>
>Tom
>
>"Jan Itor" <janitor@gb.com> wrote in message 
>news:a8r2t1dp2lbonrrviugjg1oh65higm84je@4ax.com...
>> To answer my own question.
>>
>> To make child mdi appear modal amongst other mdi children do the
>> following:
>>
>> in CMainFrame.h add the following
>>
>

0
janitor1 (17)
1/21/2006 3:47:51 AM
Reply:

Similar Artilces:

Question on MDI Apps #2
I am creating an MDI app that will have a variety of dialog boxes that will be displayed from clicking on Menu items. ex. Customers, Vendors, Inventory etc. I want to have the ability to have a single copy of each of these open at the same time. ex. both the customer and inventory dialog box open at the same time in the app. I also want to have them both listed in the Window menu. Should I use a Modeless Dialog Box or should I use a FormView? If you say a FormView, I know how to display a dialog box from a menu click but how do you display a formview based on a menu click? Also if you say...

modal dialog #2
I need to call a function in a modal dialog but only after its completely built and showed. Can someone advise? Thanks amosgcs By this, do you mean "I want to prime some UI elements before DoModal and it asserts? If so, one solution is to prime some data fields in the dlg then in the dlgs OnInitDialog method transfer them to the controls. so, in calling code: CMyDlg dlg; dlg.m_mytmpvar = "happy chappy"; dlg.DoModal(); and in dlg code, OnInitDialog: .... m_cMyCtrl.SetWindowText(m_mytmpvar); .... Or have I missed the point completely? "amosgcs" <mark@co...

preventing a number from being appended to child frame window
I display a child frame window in my MDI application. It always appends a number to the name of the window. How do I prevent that from happening? The user is only allowed one copy of a window type any how. ex. Customers, Vendors etc. In my string table I have \nMaintain Customer\n. That is the exact name I want for the Child frame. William Gower wrote: > I display a child frame window in my MDI application. It always appends a > number to the name of the window. How do I prevent that from happening? > The user is only allowed one copy of a window type any how. ex. Customers...

Having account inherit child entity of lead upon conversion
Hi All, I am new to this group so forgive me if this is an easy one. I am creating a custom entity on the lead and when we convert the lead to the account, I want the newly created account to inherit that entity and its contents where it was related to that specific lead. Example: Lead: John Smith has the custom entity 'services' related to him. There are 3 records of services related to Johm, i.e. Phone, DSL, Satellite. When I convert John to an account, i want John's account to have the three services in their exact form related to the account. I also need to come up with so...

child support calculator
Does anyone have a Child Support Calculator spread sheet or does everyone trust your local Clerk's Office. I DON"T! Thet still can't find my weekly support paymenst from 1990-1993. Hi If you are in Australia, have a look here www.stepfamily.asn.au/seek/ Child_Support_Agency/Self_Help_Tools If in the USA, try: www.alllaw.com/calculators/Childsupport Failing that try Google search " Child Support Calculator" Regards Michael "BrickYardFan" wrote: > Does anyone have a Child Support Calculator spread sheet or does everyone > trust your local Clerk'...

RPC error when creating a new RUS for child domain
Hi everybody, I hope somebody can help me out with this... I'm trying to setup an exchange2003 server to host recipients on a child domain. I have three boxes setup in my lab here all running Server2003, one is the DC for network.com, one is the DC for child.network.com and the third is a member of network.com running Exchange2003 SP1. The problem is this: when I try and create a Recipient Update Service for child.network.com, I am able to select the child domain and resolve the mail server, but when I select finish, it sits there for a minute, and then gives the following error: ...

User and Records Move to a Child Business Unit
We are unable to move a User from one Business Unit to another Child BU. CRM V3.0 'SQL Server Timeout' error message. User has 56,000 records, incl notes, activities etc Is there another process to follow -- prior to moving Users and assigned contacts to another BU rather than just selecting the option to Change Business Unit? Regards, Mandy Franklin. Hi Mandy, perhaps, you could try to follow the steps outlined in http://support.microsoft.com/kb/918609 to increase SQL Server timeout values? Before doing so I'd backup CRM database and put some SQL monitoring in place t...

Can anyone design a child's punishment/reward chart?
i have grounded my teen for 10 days. I told her she can gain points for doing good things, each point means she has one day less grounded. Has anyone or can anyone design a chart to help me? It's easy to do. If you still need help, let me know. "ruby red" wrote: > i have grounded my teen for 10 days. I told her she can gain points for doing > good things, each point means she has one day less grounded. Has anyone or > can anyone design a chart to help me? ...

Can I remove the System Menu Icon from the MDI menubar
Hi, I am working with a standard MDI window application. I want to remove the System menu and its icon from the top left most corner of the title bar from the MDI child windows. I want to retain the maximize/minmize/close that are displayed on the right side of the title bar. With the help of this, http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1865178&SiteID=1 , I am able to turn off the system menu icon and also retain the maximize/minimize/close on the MDI child windows. The issue is if you maximize the child window, Windows add the System Menu along with a default ...

Business Unit- Parent/Child Security
I have three business units, one parent and two children. Within Outlook, when a person who owns an opportunity attempts to send an e-mail to someone in the parent business unit and uses "Regarding" the owned opportunity, an error is generated stating: "You do not have enough privileges to access the Microsoft CRM object or perform the requested operation. For more information, contact your system administrator..." I've adjusted various role security settings, but after syncing and restarting Outlook, I can't seem to find the right setting or combination o...

how do you call a modal dialog from another?
Hi, I'm trying to write a dialog that's going to be asking for information to update a configuration file. The configuration file is going to be used to store a password, so I'd like another modal dialog to be popped up before the other to ask for the password. I started the project invoking the dialog that will be used to update the config info; should I start over? Or is there a way to plug in the new dialog? I tried to just add the following lines to the first's OnInitDialog: // create an instance of the password dialog class CGetPassword dlgGetPassword = new CGetP...

Persistence for MDI child windows?
<alert comment="mdi newbie" /> Is there a generally recognized correct/typical/preferred approach to deal with saving and then restoring the position/state of mdi child windows ... including whether they are minimized, maximized, iconicized, etc.? The only thing I came across was a set of semi-involved classes that only partially worked (only saved one of the child windows): http://www.d-bross.com/papers/PersistFrames.shtml What MFC functions are over-ridden and/or handled? CFrameWnd::InitialUpdateFrame ?? CMDIChildWnd::MDIDestroy ?? Thanks (and Merry Christmas) Tk...

Destroying a modeless/modal dialog
Hi, Let me rephrase my question for a broader audience in my desperate effort to resolve my problem. I have a Modeless dialog, with a button that opens a modal dialog. Now, I want to destroy this Modeless dialog from its parent window (which is another modal dialog, but I dont' think it matters to this problem). from my main application window, I can simply destroy this modeless window by sending it a WM_DESTROY, call DestroyWindow and/or delete the pointer to it created with new (this will destroy the window, right?). What I do not know in my main application window is whether this mo...

Extender addition to modal window
GP9 Is it possible to add an extender window to the "Manufacturer's Item Number Maintenance" window keyed off of the item number and manufacturer? The modal nature does not allow me to change focus. I have extender and modifier available to me as necessary. Thanks Stu ...

Parent and Child in separate UI Threads
Hi, I have an application very similar to the MTMDI sample from MSDN but instead of deriving CBounceWnd from CWnd and drawing a flying ellipse I derived it from CDialog and placed there some controls (CButton and CEdit). So I have a window running in a separate thread with a parent window in a main thread. Now I have multiple problems with such approach: 1) On moving/resizing CBounceWnd is not painted correctly. It has areas which are not repainted. Seems that it's related to CWnd::PreTranslateMessage() calls chain that starts in a secondary thread and fails when tries to get the per...

How to show child form with cannot access a dispose object error
Hi, I have child form attached to a parent form. It is declare in parent form. private frmChild child; I also have an event to show the form and activate it. if (this.child == null) { this.child = new frmChild(); this.child.MdiParent = this; } this.child.Show(); this.child.Activate(); No problem when called for the very first time to show the child form. Problem occurs when the child from is closed and the called again to show. "Cannot access a dispose object" error occurs on .Show() line. I do not want to just hide the child form. Can I completely d...

show/hide child splitter window
hi there i have an app which has, as its main view layout, a series of nested splitters one of these nested splitters i want to be a 'dynamically changing splitter layout' that is, the user selects a different task to perform, and this splitter child window 'changes' to show the different task layout the way i have implemented it so far is each Task manager object creates its own child splitter window into the same pane of the main splitter window thus in mainfrm: CSplitterWnd m_wndMainSplitter; m_wndMainSplitter.CreateStatic(...); in TaskMgr1: CSplitterWnd m_wndChil...

How to highlight a child CWnd in a SDI application ?
In one SDI application, without the Doc-View support. It has several CWnd derived children which is created on SDI default CWnd. When a child is floating, I can not highlight child CWnd's Frame as MDI did. The application Main Frame is dark blue, but the child's frame keeps lightblue (as inactive color) even it has the focus. I tried: pMyWnd->ModifyStyle(0,WS_OVERLAPPEDWINDOW,SWP_DRAWFRAME); HWND hWndLastPop = ::GetLastActivePopup(pMyWnd->m_hWnd); pMyWnd->BringWindowToTop(); pMyWnd->SetForegroundWindow(); pMyWnd->SetFocus(); Any thing I missed ? Thanks, Mike J...

CRM 4.0: Overriding dedup to save a record causes owner change to child records
Hi all, I don't know if this is a feature or what but here's what happens: I have set some Account duplicate detection rules. If I modify an account that triggers a dedup rule, I get the dedup window so I say "Save the Record" to force the saving of the newly-modified record. This has an effect similar to assigning that record to another owner, even if it keeps the same owner. A major side effect of assigning an account, is that all its children (Contacts, Activities...) get assigned to the new owner. In my case, a user may be the owner of the Account but not the owner of...

Worker thread in MDI App can only use 50% of CPU ..
Hello all, I am working on an MDI application using VS .NET 2003. The application contains a worker thread that can, if allowed run for hours and even DAYS. The remainder of the application is a series of dialogs, displays and graph to allow the user to visually examine both the input and output of the worker thread. At this time, when I run the worker thread, the Windows XP task manager reports that I am only using 50% of the CPU for the application. Given the relatively long potential execution times of the worker thread, I wish to upgrade that value to at least 90% and perhaps m...

making modeless dialog modal
How can I make a modeless property page which is the child of a dialog. I want to make that property page modal based on certain condition at runtime. I tried it using SetParent(dialog) in the OnSetActive() method of propertypage. That is making the propertypage a child of the parent dialog, but it is not making it modal with respect to that dialog. Is there any method to make the property page modal after it is created as modeless? Thanks. > I tried it using SetParent(dialog) in the OnSetActive() method of > propertypage. That is making the propertypage a child of the parent > dia...

HELP! how do i access the child elements of an IHTMLElement object?
hi there a bit of a gumby question, but i'm pretty new to COM stuff basically, i have an instance of internet explorer embedded in an MFC dialog (vc++ 6), and i get access to it via the IWebBrowser2 interface i need to find an element of a particular id, and set/get its inner text i can get a ptr to an IHTMLElement that is the body of the the document (DOM), and then i want to iterate thru its children elements, so if i call get_children() on this ptr i get, according to the msdn doco, "a ptr to the IDispatch interface that receives the collection" my question is, how do i i...

Suppressing Report Headers or How to Report/Display Parent/Child/Granchild relationships
Ok, So, what I have done is create a set of tables that hold data about terms and their definitions. Each term (except the root term) have a parent. There are 5 tables: Root, Grandparents, Parents, Children and Grandchildren. The children of grandparents are stored in the Parents table, etc. So, I've created queries to rejoin all of this a table where the root and its metadata are in column 1-3, grandparents in 4-6, parents in 7-9, children in 10-12 and grandchildren in 13-15. The problem is that not every parent has a child. So, in the query results there are empty cells/values, that'...

how can i get child dialog mouse event in messagege loop
if i have child dialog and i want to detect mouse movemnet on it so hw can i design my message loop and where? if i have winproc for both dialog (win32) The child dialog will receive the notification. You could presumably modify the OnMouseMove handler to "forward" the notification to its parent. joe On Thu, 29 Nov 2007 21:31:05 -0800 (PST), ptlchetan@gmail.com wrote: >if i have child dialog and i want to detect mouse movemnet on it so hw >can i design my message loop and where? >if i have winproc for both dialog (win32) Joseph M. Newcomer [MVP] email: newcomer@flou...

Error in Petzold book? (MDI)
I'm using Charles Petzold's "Programming Windows 95" (copyright 1996), and I'm following his guidelines for creating an MDI (multi-doc-interface). I have copied his code from "mdidemo.c" and made a few minor and harmless changes. The problem is that this code always crashes during the CreateWindow() call that makes the "frame window". Has anybody else tried compiling this code?? I only made one small modification to the code. During the CreateWindow(), instead of using NULL as the last parameter, I used a pointer to some data. Like this : WinMa...