Compact 2013 Ebook

15.5 XWE Exit Code
Created by djones on 6/18/2013 9:37:11 AM

In mainpage.cpp:

1. In the function MainPage::ExitButton_Click
Insert the following code above the last line of code of the function (which is return hr;)

	//Get reference to the Window
	IXRVisualHostPtr pHost;
	UINT ExitCode = 1;
	hr = App::GetVisualHost(&pHost);
	//Close the Window
	if(hr == S_OK)
	{
		pHost->EndDialog(ExitCode);
	}

Listing 15.8: XAML application exit code

2. Rebuild the subproject and test this exit functionality:
When the Exit button is pressed the application should exit.

 


[1] In some C# XAML discussions, it is stated that for app closure on Main Windows closure, you might need the following in the OnStartUp method, otherwise the app won’t fully terminate: this.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;


NEXT: 15.6 Calling a DLL from Native XAML C++

print

Click here to provide feedback and input

  Comments

There is no comment.

Turkish porno izle video site in rokettubeporno izle