How to call a function from the App class in the cppwinrt template project from MainPage - c++-winrt

I am working within the Visual Studio template project for a cppWinRT Blank App.
What I would like to do is make a call to a function defined in MainPage from the OnLaunched function inside the App class.
So far my theory is that I need is something along those lines:
MainPage* mainPageImpl = from_abi<BlankApp1::implementation::MainPage>(/*somehow get a pointer to the MainPage instance*/);
mainPageImpl->myFunction();
However I am not sure if this is the correct approach.

Use get_self to convert projection class to implementation class.
MainPage* mainPageImpl = get_self<MainPage>(Window::Current().Content().try_as<Frame>().Content().try_as<BlankApp1::MainPage>());
mainPageImpl->myFunction();

Related

Member of a .NET class is empty in the VB6 object browser

At the moment I´m trying tests on the interoperability of VB6 and .NET using COM.
I have followed this simple example to call a .NET component from COM.
https://msdn.microsoft.com/en-us/library/ms973802.aspx
The DLL is registered and the assembly was "succesfully added to the cache". However when I take a look into the object browser of VB6 I can only see methods of the interface and not of the actual class. COM is set on visible and the correct path for the KeyFile, are both in the AssemblyInfo.vb file. The .NET Class+Interface looks like this:
Public Interface iTemperature
'some properties and functions
End Interface
Public Class NET_Temperature
Implements iTemperature
'some implemented public properties and functions
End Class
When I try to run the following Code:
Set moTempClass = New PhysServer2.NET_Temperature
Set moTemp = moTempClass
I´m getting the well known 429-runtime error, saying that creating an object through an Active-X-component does not work. There is a lot of information on the internet regarding this error with unregistered DLL/TLB, but I´m more concerned about the fact that only the methods and properties of the interface are shown in the object browser and not the implemented methods/properties of the interface - the class. How can I fix this Error and make the methods in my class sort of visible to COM and the object browser?

SilverStripe 3: Can a module extend mysite/code/Page.php?

Good afternoon,
I don't know if what I want to do is possible, so here goes.
I have a module that extends Page_Controller, but I want certain functions to be accessible via the site root.
Eg: getMyDataObjectList();
Currently, they only work if I go through the normal MVC routing structure.
I've found that when I place the function 'getMyDataObjectList' within '/mysite/code/Page.php' it works.The problem is, I don't want to place the code in there. I want it bundled with my Custom Module, but to work the same as though it was in 'mysite/code/Page.php'
[Example Scenario]
site root: http://[somesite].com
By default, the 'Page.ss' template loads.
I would like the theme developer to be able to call my module functions (API) within any template/Layout page, and have the result returned from the site root
Currently, this only works if I move the "API" functions to '/mysite/code/Page.php'
If the code is in my module, then data is only returned when you go to:
http://[somesite].com/[module_controller]
Can this be achieved? If so, how?
Thanks for your assistance.
[Update - Code Solution]
///>MyExtension.php
class MyExtension extends Extension{
public function getMyDataObjectList(){
return 'object list goes here!';
}
}//class
///>[Module] => _config.php
Object::add_extension('Page_Controller', 'MyExtension');
And as always, I do a (/dev/build?flush=1) just in case.
Thanks to: 'simon_w'
Yes, this is relatively straightforward. Simply, create an Extension subclass with your methods in them and then add that to Page_Controller. An Extension subclass is almost exactly the same as a DataExtension, they're just for classes other than DataObjects.

Actionscript3 Clarification on Usage of Classes?

Hi I am quite new to actionscript 3 and I would like some clarification on the use of classes. I am trying to use a AS3Commons UI project from http://sibirjak.com. But I am unsure on how to use some of their classes. The way I have it formatted in one of my keyframes is:
import com.AlertBox; // The location of the alertbox class
import com.AlertTutorialStep1; // The location of the example AlertTutorialStep1 class
var alertbox:AlertTutorialStep1 = new com.AlertTutorialStep1; // Creating an instance of the example class in the AlertTutorialStep1 doc
alertbox.AlertTutorialStep1(); // Trying to access the AlertTutorialStep1() function which is in the AlertTutorialStep1 class
But I am unable to access the function AlertTutorialStep1() and unsure why I am getting the error, can someone provide me with some insight? http://sibirjak.com/osflash/blog/tutorial-creating-an-alert-box-with-the-as3commons-popupmanager/
Try and avoid using the timeline if possible. I think that OOP and the Flash timeline can work if you know what you're doing, but stackoverflow is full of questions from beginners struggling with the timeline and classes, and these tend to be difficult to debug. Try to set your project up with a single Main document class which instantiates all the other classes you need for your project.
That said, assuming you have the AlertBox and AlertTutorialStep1 classes, and their dependencies, in the right directories relative to it, I think your code will work if you set the document class of your .fla to the AlertBoxTutorial1 class.
Again assuming the packages are all set up correctly, you could try replacing your existing code with the following:
//import com.AlertBox; // Don't need to import this, AlertTutorialStep1 imports and uses it
import com.AlertTutorialStep1; // The location of the example AlertTutorialStep1 class
var alertbox:AlertTutorialStep1 = new AlertTutorialStep1(); // Don't need to fully qualify the class as it is already imported in the line above
this.addChild(alertbox); // Need to add the instance to the stage
//alertbox.AlertTutorialStep1(); // AlertTutorialStep1() is the constructor of the class and can't be invoked via an instance of it

Flex Interface method createAutomationIDPartWithRequiredProperties error

I'm currently creating a class that extends UIComponent in Flex 3, but when the flash builder try to compile show me some errors
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class components:ArtWorkImage
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.senocular.display:TransformTool
I see that UIComponent implements this interface, but I had never had this error before, I'm assuming UIComponent should made this implementation by default, so it should be something else, I already try to recreate the project or clean it, with no result, can someone please point me how maybe this can be fix, thanks for your help
oh btw I had this project before in flex builder, exported as a FXP and imported in Flash Builder, thanks!
All UI objects use an Automation delegate to handle implementation of the automation interface. Each UIComponent has a specific automation delegate registered with the Automation Framework. These automation delegate implementations are injected into the object by the Automation framework when the object is created according to the class name of the object.
For example:
UIComponent <- UIComponentAutomationImpl
ToolTip <- ToolTipAutomationImpl
DateChooser <- DateChooserAutomationImpl
Normally if you subclass a component you should inherit the Automation Implementation. However depending upon how the instances of the object are being created the automation framework may not be able to resolve the class name to the appropriate super class. In this case you may need to take additional steps to get the automation implementation into your class.
If you want your class to automatically be injected with a particulary automation implementation you should call the static registerDelegateClass method on the mx.automation.Automation class.
import mx.automation.*
Automation.registerDelegateClass(com.foo.bar.ArtWorkImage, mx.automation.delelegates.core.UIComponentAutomationImpl);
Alternatively you could directly implement the IAutomationObject methods in your UIComponent or create your own delegate class and instantiate and "inject" it into your class in its' constructor thereby by passing the Automation framework.
Here are few links that might help you understand the automation framework:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/Automation.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/delegates/core/UIComponentAutomationImpl.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/package-detail.html

Why Can't I Inherit IO.Directory?

Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable!
I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function.
Please advise and I will send you a six pack. OK nevermind I'm not sending you anything but if you come to the bar tonight I will hook you up and then beat you in pool.
From the Meta Data of .NET
namespace System.IO
{
// Summary:
// Exposes static methods for creating, moving, and enumerating through directories
// and subdirectories. This class cannot be inherited.
[ComVisible(true)]
public static class Directory
You cannot inherit from a Static Class.
Are you using C# 3.0 VB.NET 2008 -- then you could add an Extension Method
If you use the DirectoryInfo class, you will have access to a MoveTo function.
EDIT: I'll correct myself... The static Directory class already has a Move method.
I'd guess that Reflector isn't picking up the sealed attribute correctly for VB (or perhaps just not displaying it properly). If you look at the IL, it is sealed:
class public abstract auto ansi sealed beforefieldinit Directory