Click here to Skip to main content
15,908,581 members
Home / Discussions / C#
   

C#

 
GeneralRe: Newbie: How to find out which menu item has been clicked from a context menu? Pin
Ed.Poore14-Aug-06 1:21
Ed.Poore14-Aug-06 1:21 
QuestionSimple question Pin
JacquesDP14-Aug-06 0:33
JacquesDP14-Aug-06 0:33 
AnswerRe: Simple question Pin
Ed.Poore14-Aug-06 1:12
Ed.Poore14-Aug-06 1:12 
GeneralRe: Simple question Pin
JacquesDP14-Aug-06 1:28
JacquesDP14-Aug-06 1:28 
GeneralRe: Simple question Pin
Ed.Poore14-Aug-06 2:12
Ed.Poore14-Aug-06 2:12 
GeneralRe: Simple question Pin
JacquesDP14-Aug-06 18:30
JacquesDP14-Aug-06 18:30 
Questionxquery problem [modified] Pin
kkadir14-Aug-06 0:20
kkadir14-Aug-06 0:20 
Questionbuilt own modal dialogs Pin
snapper_21214-Aug-06 0:07
snapper_21214-Aug-06 0:07 
Hi.

Im working on a MDI-application in C#.
For this i want to realize modal dialogs, which are only valid for the calling mdi-child.
that means, if i activate/click on another mdi-child, it will be activated, despite of the modal dialog in the other child.

in my current approache i show a modal dialog as a normal form. by handling the activate/deactivate-events i tried to simulate the behaviour of a modal dialog by calling the Activate()-method on the form that should be modal. but that doesn't work.
i tried to call Activate() on the modal form in the Deactivate-handler of itself and in the Activate-handler of the owner. both doesn't work.
is there perhaps any possibility to cancel the deactivation of a form?

here is the relevant code in the main-form:


//method in the MainForm, that is called when an MDI-child wants to show a dialog
public void ShowAsModalForm(MdiForm modal, MdiForm owner)
{
owner.Tag = modal; //save current displayed dialog for the child in a member-variable
modal.Deactivate += new EventHandler(Modal_Deactivate);
owner.Activated += new EventHandler(ModalOwner_Activated);
modal.Show();
}

//the owner of a modal dialog was activated
void ModalOwner_Activated(object sender, EventArgs e)
{
Form owner = sender as Form;
if (owner != null)
{
Form modal = owner.Tag as Form; //getting the current modal-form form the member an activate it
if (modal != null)
modal.Activate();
}
}

//the modal dialog was deactivated
private void Modal_Deactivate(object sender, EventArgs e)
{
Form modal = sender as Form;
if (modal != null) //activate it
modal.Activate();
}


the ModalOwner_Activated-Method seems never called, though registered in Activated-event.
the other possibility is Modal_Deactivate, which is called on deactivation but modal.Activate() has no effect, not thinking about thats the wrong way, because by handling the deactivate-event i can't decide if the modal dialog should be shown or not (because the user clicked on a other mdi-child).

Can anyone help me?

thx
QuestionWindows Service stops after logging-off from current user/login. Pin
imdeepakpathak13-Aug-06 23:50
imdeepakpathak13-Aug-06 23:50 
AnswerRe: Windows Service stops after logging-off from current user/login. Pin
seee sharp14-Aug-06 0:19
seee sharp14-Aug-06 0:19 
QuestionMouse Clicking Pin
Cassiopeiaxy13-Aug-06 22:10
Cassiopeiaxy13-Aug-06 22:10 
AnswerRe: Mouse Clicking Pin
Malcolm Smart13-Aug-06 22:38
Malcolm Smart13-Aug-06 22:38 
QuestionHow to send a file in batch mode ? Pin
sundar15613-Aug-06 21:20
sundar15613-Aug-06 21:20 
AnswerRe: How to send a file in batch mode ? Pin
Malcolm Smart13-Aug-06 22:11
Malcolm Smart13-Aug-06 22:11 
GeneralRe: How to send a file in batch mode ? Pin
sundar15614-Aug-06 0:16
sundar15614-Aug-06 0:16 
QuestionAbout SplitContainer Pin
ytubis13-Aug-06 21:13
ytubis13-Aug-06 21:13 
AnswerRe: About SplitContainer Pin
CooperWu13-Aug-06 21:33
CooperWu13-Aug-06 21:33 
GeneralRe: About SplitContainer Pin
ytubis13-Aug-06 21:37
ytubis13-Aug-06 21:37 
GeneralRe: About SplitContainer Pin
CooperWu13-Aug-06 21:42
CooperWu13-Aug-06 21:42 
QuestionAbout Threading Pin
engsrini13-Aug-06 20:23
engsrini13-Aug-06 20:23 
AnswerRe: About Threading Pin
Guffa13-Aug-06 21:06
Guffa13-Aug-06 21:06 
GeneralRe: About Threading Pin
engsrini13-Aug-06 21:18
engsrini13-Aug-06 21:18 
GeneralRe: About Threading Pin
Dario Solera13-Aug-06 22:27
Dario Solera13-Aug-06 22:27 
AnswerRe: About Threading Pin
CooperWu13-Aug-06 21:41
CooperWu13-Aug-06 21:41 
Questionsort and filter a set of database Pin
skyeddie13-Aug-06 19:50
skyeddie13-Aug-06 19:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.