So I look at this (Windows build keynote 1:42:56) And I just do not get it - what I can use to create GUI from C++ and/or GUI language that will be capable to call functions from my C++ code? HTML, XAML or what? And where to see code sample of doing markup call code and code create GUI sample with C++ for Windows 8 Metro apps?
Sample code in C++ and other languages is at http://code.msdn.microsoft.com/windowsapps. You can take a look at how it's done.
If you want to call C++ code the easiest way will be to use C++ with Component Extensions. This is just plain C++ that compiles to native code however it has a few extensions (reminiscent of C++/CLI) that let you use the WinRT COM components without worrying quite so much about the COM plumbing.
With C++ and WinRT you can actually use XAML like the managed languages to define your user interface. It's pretty neat, see the documentation here:
Information on C++ component extensions
I haven't looked into it but you may still be able to use P/Invoke or COM interop in the managed languages to call C++ code for a Metro style app however this is unconfirmed. Obviously a desktop app can do all the things it normally would.
You can use C++ code to write metro style applications. You can also write applications in Javascript/HTML/CSS and call APIs that you write in C++ or C#/VB from those JavaScript applications.
Related
guys! I'm currently working on new cross-platform application (iOS, Android, UWP). I have graphical library for UI written in c++, using freeglut for opengGL.
The problem is, I don't know how to use this library in my UWP application. I have read a lot of information about all the wrappers for OpenGL, but they all for WPF or written in C++. I also know about Microsoft ANGLE Project, but it is written in the c++ too, but I need to write the application in C# language.
So, how can I modify my own library using excluding freeglut and import it into my C# application?
By the way, sorry for mistakes in my English.
So you want to consume your legacy C++ assembly in your UWP application?
You can create a Windows Runtime Component(Universal Windows) project, in which you need to include the assembly, and declare as many APIs as you want to expose, all marked with DllImport attribute.
Eventually, this WinRT component will do the Platform Invoke, and works as a "wrapper" layer between your legacy code and UWP application.
It's up to your preference which language you use for the WinRT component, C++ or C#, either way, you need to worry about struct/type mashalling and unmashalling.
After you're done with above, you'll be able to reference the WinRT component in your UWP application, and call the APIs you declared in that assembly.
The same way works for Microsoft Angle project as well.
You might find this post useful.
One last word, you might want to avoid using forbidden APIs, otherwise your UWP app won't pass the Windows Store Certification.
According to https://msdn.microsoft.com/library/windows/desktop/jj714080.aspx there is an option to use DirectX and some native API functions including LoadLibrary and GetProcAddress functions https://msdn.microsoft.com/library/windows/desktop/jj714080.aspx
This should give you ability to use any native dll.
You can try to make RuntimeComponent project and put it there. Also you can try clr oldsyntax option to use native code as it is.
From the answers recieved for the question here: Graphics using Standard C++ only?
Seems to be that C++ itself does not have GUI functionality. So how do other Frameworks like Qt which support GUI in C++ do that? Do they use some other language internally or is there some other standard lobrary/protocol for GUI?
And I am concerned about the C++ language frameworks only.
Thank You.
They call operating system APIs, or APIs in other frameworks, in order to create GUI components.
Eg. on Windows they call the Windows CreateWindow API to create a window.
Where a framework works on multiple platforms, it contains different GUI code for each of those platforms, calling CreateWindow on Windows or whatever the Mac equivalent is on a Mac, for example.
How can i make buttons in c++ and handle them.
I am targeting win32.
Till now i have no idea of how to make graphical programs in c++ . I have come from JAVA and therefore have no idea of handling c++ events and building GUI
It will be of great help if you give the links to tutorials or could name the books to do so.
C++ is merely a language and the framework and operating system services whcih enables you to make use of the services using C++.
Java contains a GUI framework which has implemented across the platform. When you come to a native windows application, you have to rely on mainly two things, Win32 and MFC(a C++ wrapper of Win32 APIs). Win32 provides C based APIs which expose the operating system services.
For your specific questions I can answre like, You can use CreateWindow() Win32 API or CButton::Create() (MFC) to create a button. Also Visual studio provide a really good resource editor where you can manage the controls and make the message handlers.
The APIs are largely classified in to three DLLs
GDI32.dll - provides APIs for drawing
User32.dll - provides APIs to creates buttons windows etc.
Kernel32.dll - provides APIs to use operating system services like file creation, threading, synchronization etc.
As a Java programmer, it would be easy to adopt C# rather than C++. For you C++ might be going back to stone age where you've to hit the stones and make the fire, where in C# you can enjoy the easiness of a matchbox.
I'd suggest you to read following books to learn basic GUI programming under Windows
Windows Via C++ - (Win32)
Programming Windows with MFC - Jeff Prosise
Programming Windows - Charles Petzold
Making UIs is not part of C++ itself : you'll have to use a framework or rely on something else (like MFC in visual c++).
If you want easier way of building a GUI and manage your events, while still keeping your code portable, I suggest having a look at Qt : it's really good quality and delivered with a bunch of well-done examples. (license is LGPL so as long as you link dynamically, you can license your code the way you like).
A very good book to understand win32 api is http://www.charlespetzold.com/pw5/.
I am interested in using Javafx for my visual content for a desktop application and call native,unmanaged C++ functions ( on events from the Javafx views). Is this possible? Can someone explain with an example?
As JavaFX has been designed for maximal compatibility with the Java platform, you can always call Java code from your JavaFX code, and then do some JNI stuff, as in this example question.
I'm looking into creating a GUI program for Windows in C++, I have a good knowledge of C++ in the command line and also in game creation. But I'm not sure where to start with GUI application development.
I have Visual Studio 2010 and have created new projects with a GUI but these templates are complex and leaves me not understanding whats happening and how to modify it.
So I'm asking where do I start? Preferably good websites that you can recommend or tutorials, rather than books being a poor student :)
Having written Windows code since Win2.0, I have to say: start with C#. It's a very easy language to learn after C++, and many of the new features (like built-in event handling) were put there to make writing GUI applications easier.
Then, once you're used to the basic concepts of window management and messaging, then drop down into C++.
I say this for the same reason that assembly is not a good first language. There is an enormous amount of housekeeping code in a Windows application, and in C++ you see it all. Better to use a language that hides much of it until you're grounded.
I'd personally recommend using Qt instead to develop your GUI.
Use a GUI framework/library that hides the dirt from the low-level GUI api. MFC is not a solution - it is only a thin layer above the WinAPI. I recommend using QT or wxWidgets. If you use Qt use the Qt creator/Qt designer to design interfaces. If you use
wxWidgets use wxFormBuilder.