Windows Phone: Log to console - c++

Disclaimer: I'm quite new to the MSFT tech world and only started Windows Phone development a month or so ago.
I am unable to figure out how to log information to the Visual Studio Output window from within a C# and C++ (Direct3D) Windows Phone 8 App. Is this possible?
I am building in debug mode, targeting Windows Phone 8, running in the XDE emulator and my development machine is a Windows 8 box with VS2012 Ultimate installed. My App runs fine, my Direct3D scene renders normally, but I can't log anything! This makes tracing code execution difficult and forces me to use breakpoints (which can be overkill in many situations).
I've been searching far and wide and have tried many methods (OutputDebugString being one of them). I can't see anything on MSDN about this - why is this not documented anywhere?

Yep, it's possible to write debug strings from WP8 C++ to the output window in VS2012. I actually have an example of that here.
1) Invoke OutputDebugString from C++.
void Direct3DInterop::MyButtonWasClicked()
{
OutputDebugString(L"Button was clicked!");
}
2) Before running the app make sure to change to the native debugger from the managed debugger in the project's properties.

I believe the methods in System.Diagnostics.Debug (specifically the overloads of WriteLine()) work...although I haven't tried them with C++ apps.

Related

Windows 10: The application was unable to start correctly (0xc000a200)

I am developing my QT application on windows 10 . The development is complete (as for now).
After run the application in debug mode from QT-creator, I am trying to run the executable from the build directory. But it shows me an "Application Error" dialog with the following message:
The application was unable to start correctly (0xc000a200). Click OK
to close the application.
What is the problem and How to fix it ?!
The error codes are given to you in the error message for a reason. They don't mean anything to regular users, but we're programmers and we are the intended audience. Now that Google has been invented, you have absolutely no excuse for not taking the 5 seconds to Google the error code and see what it means.
In this case, 0xc000a200 is an error code that corresponds to STATUS_NOT_APPCONTAINER. The master list of COM error codes is in the Windows SDK headers, specifically ntstatus.h. If one looks this one up, one sees the following description:
This operation is only valid in the context of an app container.
Now, admittedly, once you get to this point, you may discover that you are in well over your head. You may not have any idea what an app container is, and certainly no clue about how to fix it. But at least then you would be able to ask a good question, which will go a long way to getting you a good answer.
But let's see if you can get lucky this time anyway. This error is most commonly encountered when an application that is not inside of an app container tries to load a DLL that is marked as being part of an app container. It is the linker that is responsible for marking a DLL as being or not being part of an app container, controlled by a series of options for whatever linker you're using. On Microsoft's linker, it is /APPCONTAINER:YES and /APPCONTAINER:NO that control this. I'm not sure what toolchain Qt Creator uses, but if it is not Microsoft's, this should at least get you started looking in the right place in that linker's documentation. Make sure that all DLLs used by your application are not being marked as part of an app container.
The option should be off by default for a regular C++ desktop application project, but it's possible that one of the DLLs started out life as part of a Windows Store app. Or it's possible that the switch just got thrown accidentally.
I had the same error, but the approved solution wasn't the cure. What I found is that I had installed the wrong Qt compiler support packages. For me it was Qt 5.9.1 on Windows 10 64 bit to use with Visual Studio 2017. When installing Qt I selected the "msvc2017 64-bit" option. Sound good, right? Wrong: what I wanted was the "UWP x64 (MSVC2017)".

Air Native Extensions: Released Air App w/Windows Native Extension works fine on develpment PC but not on other computers

I'm working on an AIR app that uses a Native Extension for windows that I developed for the same project. The app calls an ANE method called pingFunction and passes it a String containing the IP address where the pingFunction will perform, believe it or not, a ping test.
The application and it's ANE work great on Flash Builder and even after making it a release, they keep working like a charm on the development PC. The problem is that I've tried on two other computers and the application is throwing the following error:
ArgumentError: Error #3500: The extension context does not have a method with the name pingFunction.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at com.mycompanyname.myappname::MyAppName/sendPing()[...
At the beggining I thought I had to do with the fact that I was using a DLL I compiled using the Debug configuration on Visual Studio instead of the Release configuration, because I read that sometimes the a debug-version of a DLL can use external DLLs. So, I changed it and rebuilt the whole library as a release build. Sadly for me, I'm still experiencing the same result.
Also, I tried changing the swf-version of both the AIR app and the ANE to the AIR SDK version I'm using (14.0), and got again the same error.
The development computer is running Windows 8.1 and the others, where the app is not working, Windows 7 and Windows 7 Service Pack 1.
Any ideas about why this is happening? Any questions or comments that might lead me to the right track will be deeply appreciated.
Error#3500 is coming because you don't have the required runtime installed on those machines, which is necessary to execute any c++ code .
On your development machine you have visual studio installed and hence you also have msvcr.
Solution of the problem is:
Install msvcr i.e. Microsoft Visual c++ redistribution - 2012 from here.
you need msvcr anywhere you want to run any VS compiled c++ code.

How to write a IE BHO in Plain C++ which executes my javascript

According to my client's demand, I am aiming to write a Internet Explorer BHO which on button click executes my custom Javascript. I have started with this link which contains an example BHO which is inplemented in C++,
http://www.codeproject.com/Articles/37044/Writing-a-BHO-in-Plain-C
But when I try to run it in Visual C++ 2010 Express, it doesnot build. I have these question regarding IE BHO:-
1) On which platform can I build and make changes to the above example code , in VC++ 2010 or Windows 7 SDK?
2) Any other tutorial you can refer me; which can guide me how to make BHO in C++ ?
3) I intend to make a button while using IE BHO, such that whenever it is clicked, my custom javascript is executed. Can anybody give me a general guidance on how to do this?
I have searched alot about this matter on Internet, but it seems that majority of the people are implementing BHO in C#. I am in need of some good suggestions.
First question: You should not ask a question saying "it does not build" and saying nothing about your build problem. Do you want us to download the project and guess what is Ok and what is not depending on VS and OS versions? Update your question with your build problem.
Second question: Use Google: Building Browser Helper Objects with Visual Studio 2005 It's old now, but nothing has really changed since then. Alas, you must have an ATL capable version of VS, and the Express versions are not. Anyway,I very strongly discourage writing a C++ BHO without the help of ATL. You may get the ATL sources by downloading a recent SDK, but you will not have the wizards. If you have a "full" VS2008, it will do the job perfectly well.
Third question: general guidance is the IHTMLWindow2 execScript method

How to create GUI programs with Code::Blocks

Previously I used Visual Studio for my C++ programmings. But some cost effects I had to change my IDE, so I chose Code::Clocks (12.11). But I can't find a way to develop GUI applications with C::B. Is there any way to develop GUIs with C::B?
Yes, You can develop GUIs with CodeBlocks if you have GTK+ or wxWidget Libraries. You can use one of them at your own choice. CodeBlocks can't use them until you download and install them, So you have to perform some actions to make them usable in CodeBlocks. For GTK+ configuration steps see this and for wxWidget see this.
I create Win32 gui apps all the time with Code::Blocks 20.3 (uses MinGW-W64 project compiler) because I code them using the Win32 api. This is the manual way of doing things, and it works great; the down-side is that you must learn the Win32 api. (its an aspiring challenge, but for an experienced C/C++ programmer and some google skills, its doable)
Many programmers believe that gui apps must be built with a graphical builder (GTK+, wxWidgets, etc) but not true. In fact, in the stock version of the 20.3 Code::Blocks one of the project options is Win32 app. It builds a 'very' minimal cpp file that displays a blank window and starts the message loop... this is a good place to start if you've never seen a gui cpp text file that produces a blank window. You will need to study the Win32 api and learn how to use the message loop, how to add controls (buttons etc) to your project, and how to debug it; its a learning curve, but it is rewarding education. Get the book, "Programming Windows" fifth edition--- make sure its the fifth edition only!
The Microsoft docs are pretty good for learning the Win32 api also, but the book is the best approach. Take a class.
marcus
If you want to start creating GUI programs with 'Code::Blocks' then using a 'Win32' approach looks promising.
I only recently installed 'Code::Blocks 20.03', using the defaults for the install directory, and type of installation( Full ), and was easily able to create a basic 'Win32 GUI project'.
NB: I was using Windows 10, and the basic project doesn't really do anything.
For some Microsoft documentation, see at
https://learn.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows
, please note at the bottom left of this page, a 'Download PDF' link.
You could start at page 18 of the pdf, which is where, 'Module 1. Your First Windows Program', starts, page 20 is illuminating.
For information on 'The Message Loop', mentioned in a previous answer, see page 24.
It might be worth bearing in mind 'Reply #3' to the question at
https://forums.codeblocks.org/index.php?topic=19537.0

Console application in C++ for smart devices (WinCE)?

I am new in developing application for WinCE 5.0. I want to start from "Hello world" program or console application. But I couldn't find anything like that or any other sample applications to start from.
I am using Visual Studio 2005. I created new project >> visual C++ >> Win32 smart device project >> console application >> finish.
The project compiles fine. I was trying simple
printf("Hello world");
But When I ran in smart phone 2003 emulator, it showed no output.
I couldn't find a good tutorial to start from. Please suggest me some good tutorials or sample applications to start from.
Thanks in advance.
What does the log say? That the application has terminated successfully with return code 0x0?
If you did not put anything to stop the application it might be that it runs good and terminates without you noticing it. Try to add a scanf or Sleep(5000) after the printf statement so things will be visible. You can also compile it in debug mode and put a breakpoint after the printf statement and see the results.
In addition, I am not too familiar with Windows Mobile and its incarnations (smart phone 2003 being one of them), but I am not sure how it handles a printf. You can try create an MFC application and use the MessageBox to display your text.
OK. I just tried the two options and there is no CMD windows in Windows Mobile (Smartphone or PocketPC) so the application runs successfully, but prints nothing.
Use the MFC option or deploy your application to a Windows CE 5.0 device emulator image. I have not tried that download myself, but it says that it should save you the hassle of handling Platform Builder. Note that you might be missing some components in the image down the road, but I suppose that for practicing purposes it should suite you just fine.
WinMo/Pocket pC devices have no console, so your output went nowhere. You can always add a console on like PocketConsole.
there is CMD windows in POCKET PC 2003 emulator you can try it using visual basic code