Storyboard_Completed event produces Linker Tools Error LNK2019 error - c++-winrt

Hello fellow programmers,
I tried the xaml autocompletation and the code behind event registration for creating the event handler but got the same error. With buttons and co this works perfectly.
I'm using this function:
void STORYBOARD_Completed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::Foundation::IInspectable const& e);
For me this error makes no sense :(
Thanks for the help in advance.

Ok i solved it :)
I had to include
#include <winrt/Windows.UI.Xaml.Media.Animation.h>
first.
This was really helpful:
https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/faq#why-is-the-linker-giving-me-a-lnk2019-unresolved-external-symbol-error

Related

Microsoft AdControl stealing focus - Windows 8 MonoGame

I am currently writing a simple snake clone game for Windows 8 using MonoGame. I am using the XAML - MonoGame template and trying to include advertising support. I have found an issue, pretty sure it's with the AdControl itself, not MonoGame, however it is stealing keyboard focus every time an ad is loaded.
I have tried to reinitialize the MonoGame 'MetroGameWindow' instance to try and get focus back with no luck. Eg,
void GamePage_LostFocus(object sender, RoutedEventArgs e)
{
MetroGameWindow.Instance.Initialize(Window.Current.CoreWindow,this)
// 'this' is 'GamePage' which inherits from 'SwapChainBackgroundPanel'
}
Does any one know any workarounds for this problem? Any help would be appreciated.
This ia a known problem with AdControl. As of now best solution is to set IsEnabled property of AdControl to false. Doing so will prevent AdControl from taking focus on ad reloads while remaining clickable. See following discussion on bing ads forum: http://community.bingads.microsoft.com/ads/en/publisher/f/63/t/73548.aspx

C++ Builder TArray<System.Byte> not compiling

I'm trying to include the idUDPServer component (Indy component) in a C++ Builder XE project and when I try to include the onUDPRead event (manually linking it to the component because of a known bug in C++ Builder XE).
All articles I have read so far solves this problem by manually assign the event function to the component.
In my case I can't compile because it can't recognize the TArray<System.Byte> parameter.
I have tried to include the <System.hpp> but it doesn't help.
Is there anyone that has managed to solve this issue with TArray?
Function declaration:
void __fastcall UDPServerUDPRead(TIdUDPListenerThread *AThread, TArray<System.Byte> AData, TIdSocketHandle *ABinding);
Thanks in advance...
Okay, I solved it.
I remembered that I had successfully upgraded an earlier project using the idUDPServer control without any problem. So why did that code compile and not this new one?
After some research I found that apparently Delphi (I know, it's weird. C++ Builder is written partly in Delphi) solves all types to its base form and there is an issue with the TArray<System.Data> type.
I copied the declaration from the converted project:
void __fastcall UDPServerUDPRead(TIdUDPListenerThread *AThread, TIdBytes AData, TIdSocketHandle *ABinding);
As you can see the TArray<System.Data> is replaced with TIdBytes. It compiles without any warnings or Errors. You still have to assign the event function manually although (in the Create Event).
UDPServer->OnUDPRead = &UDPServerUDPRead;
* EDIT *
Updated code TBytes to TIdBytes as Remy Lebeau - TeamB corrected me.

Why do I get the error "error: unknown type name 'virtual'" when trying to compile this code?

Code:
struct IRenderingEngine {
virtual void Initialize(int width, int height) = 0;
virtual void Render() const = 0;
virtual void UpdateAnimation(float timeStep) = 0;
virtual void OnRotate(DeviceOrientation newOrientation) = 0;
virtual ~IRenderingEngine() {}
};
Learning opengles from a book for 3d iphone programming and it uses this example code but the book is targeted for xcode 3.x
Somehow I feel like its something with xcode 4....
EDIT:
Heres the actual error:
/Users/Dan/Documents/opengles/Hello Arrow/Hello Arrow/IRenderingEngine.hpp:27:2: error: unknown type name 'virtual' [1]
And that legitamtely is all that it takes to fail to compile, absolutely no other files. (Yes I've tried compiling with literally a main.m and this hpp file)
It is recognizing the hpp file as a cpp header file though, if I try to add it to the compiled files it says that "no rule to process file '$(PROJECT_DIR)/Hello Arrow/IRenderingEngine.hpp' of type sourcecode.cpp.h for architecture i386" so I really have no idea what is going on
Note that I compiled with main.m meaning I compiled another Cocoa/Foundation based application
I tried compiling for a c++ application and everything worked out just fine....
Similarly compiling with a main.mm test file worked fine too
heres the actual project, lemme know how insane I really am:
[Removed considering I lost the file]
Please rename the main.m to main.mm. This worked for me.
If you're using Xcode 4, try changing the name of file "AppDelegate.m" to "AppDelegate.mm". It works for me.
Changing the name of file "AppDelegate.m" to "AppDelegate.mm". It's correct!
I moved the #import "IRenderingEngine.hpp" line from the GLView.h file to the GLView.mm - this prevented it from being imported into the main.m and HelloArrowAppDelegate.m files when they were compiled - and restricted the import into the .mm file, that could handle the C++.
I also had to make a couple of other fixes for bugs I'd introduced when typing in the code - so apologies if that wasn't the only thing that needed to be done, but it might help those with similar problems!
if you call C++ files ( even if you only import them ) you need to change the .m file that call's it to .mm
This is just a stupid guess since I've never tried compiling something with the word virtual in a C compiler... but is there any chance that you were trying to compile this C++ code as C code? That's the only reason I can think of that a compiler wouldn't understand the keyword virtual.
The header <stdlib.h> is not the right one to use in a C++ program. When I replaced it with the c++ version of C's stdio library <cstdlib> then your code compiled for me.

Expected function body after function declarator error

I downloaded the class files and demo program here: http://github.com/matej/MBProgressHUD
When I try to compile the program, I get several errors. The first one appears here:
CG_EXTERN void CGPDFContextAddDocumentMetadata(CGContextRef context,
CFDataRef metadata) CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_0);
On the second line the error is "Expected function body after function declarator."
What's wrong with this code? How can it be fixed?
In the project build settings, change the compiler version to the system default.
If you have access to Apple's Dev Forums for the Xcode betas, you can find more info and an alternative solution at https://devforums.apple.com/message/287160#287160.

SuppressMessage in interface

I tried to suppress a particular FxCop warning for a method defined in an interface by adding SuppressMessage attribute to the method. But the warning still appears. I know the SuppressMessage attribute is the right choice.
public interface ICustomerAccess
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1024:UsePropertiesWhereAppropriate",
Justification = "This method involves time-consuming operations", Scope="member")]
IList<ICustomer> GetCustomers();
}
Does anyone have the experience on suppressing FxCop warning in an interface?
Thanks,
H
For the record, the answer is in the question's comments:
#Angelina said: Thank you very much! I
am able to resolve the issue by adding
CODE_ANALYSIS to the project.