- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathactivedesignereventhandlerexample.cpp
41 lines (37 loc) · 1.54 KB
/
activedesignereventhandlerexample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#using <system.dll>
usingnamespaceSystem;
usingnamespaceSystem::ComponentModel;
usingnamespaceSystem::ComponentModel::Design;
namespaceMiscCompModSamples
{
public ref classActiveDesignerEventHandlerExample
{
private:
ActiveDesignerEventHandlerExample()
{
}
//<Snippet1>
public:
voidLinkActiveDesignerEvent( IDesignerEventService^ eventService )
{
// Registers an event handler for the ActiveDesignerChanged event.
eventService->ActiveDesignerChanged += gcnew ActiveDesignerEventHandler( this, &MiscCompModSamples::ActiveDesignerEventHandlerExample::OnActiveDesignerEvent );
}
private:
voidOnActiveDesignerEvent( Object^ /*sender*/, ActiveDesignerEventArgs^ e )
{
// Displays changed designer information on the console.
if ( e->NewDesigner->RootComponent->Site != nullptr )
{
Console::WriteLine( "Name of the component of the new active designer: {0}", e->NewDesigner->RootComponent->Site->Name );
}
Console::WriteLine( "Type of the component of the new active designer: {0}", e->NewDesigner->RootComponentClassName );
if ( e->OldDesigner->RootComponent->Site != nullptr )
{
Console::WriteLine( "Name of the component of the previously active designer: {0}", e->OldDesigner->RootComponent->Site->Name );
}
Console::WriteLine( "Type of the component of the previously active designer: {0}", e->OldDesigner->RootComponentClassName );
}
//</Snippet1>
};
}