I have started working with C++ recently and am not comfortable with Visual Studio Development Environment and also I do not have proper understanding of MFC, Win32, ATL, COM Terminologies.
From example point of view, I had taken a simple C++ program to see how it works with Visual Studio Environment and I was having some issues to get that code up and running.
I would like to request if someone could point me to some online resources/books where I can get more understanding about Visual Studio Development Environment from C++ perspective and get some knowledge about MFC, Win32, ATL, COM Terminologies than it would be really very helpful to me.
Note: I have checked MSDN library and some related Microsoft sites but when I see HOW DO I kind of video tutorials they are more from .Net/C#/ASP.Net perspective but I am looking for some online resource for C++/VC++ perspective.
www.stackoverflow.com of course will have plenty of resources around if you look # the right tags
https://stackoverflow.com/questions/tagged/mfc
https://stackoverflow.com/questions/tagged/com
etc.
The Code Project is also a good resource for windows / C++ programming, here are a couple areas to start looking #:
http://www.codeproject.com/KB/MFC/
http://www.codeproject.com/KB/atl/
http://www.codeproject.com/KB/COM/comintro.aspx (via Andy in comments)
The classic book about Win32 is presumably Petzold's. Petzold's book is I think (I've never read it) mostly about GUI programming; whereas the other classic/recommended Win32 book, which is Richter's, is about 'system' (non-GUI) programming.
For learning COM, perhaps Essential COM? Some reviewers praise it, but some others reviews say things like "not for beginners"; but it's how I learned COM, and I found it thorough, low-level, and detailed. It assumes you know C++ (not COM) already.
IMO you don't need books about MFC if you already know C++ and the Win32 API, in which case the reference libraries are sufficient. Alternatively, some people recommend an MFC book like Prosise's.
I learned using Visual Studio IDE and MFC using the Scribble Tutorial. It was a step-by-step tutorial creating a simple MFC application. Unfortunately the tutorial was written for Visual Studio 6.0, and in the meantime almost all wizards and menus changed, so it's not applicable anymore.
The tutorial can be found in MSDN, here, though:
http://msdn.microsoft.com/en-us/library/aa716528(VS.60).aspx
The scribble sample source for Visual Studio 2008 can be found here:
http://msdn.microsoft.com/en-us/library/f35t8fts.aspx
Don't bother learning ATL, WTL, MFC or COM for now (or at all, really). Just use standard C++ for starters. If you want to write GUI programs, I recommend Qt, it is much easier and fun to use than any of the former APIs.
If you have trouble compiling Qt for Visual C++ you can download the entire Qt SDK and it comes with a C++ IDE called Qt Creator. It uses MinGW as a backend.
Related
I'm developing a segmentation tool (for research purpose, not for commercial use) and I was wondering which graphical user interface should I use as there are many.
I'm looking for a relatively simple interface which allows me to do as follows on the same window:
*Input variables that will be used by the algorithm
*Browse a folder and select images
*Call functions by clicking on a button
*Display an image that will evolve while the algorithm is running
I'm coding in c++ with visual studio 2010 and I'm using additional libraries such as OpenCV, so the GUI library must be compilable and usable on console project on VS2010.
So far I've tried Qt, FLTK, GTK+ but Qt as compatible issues on x64 architectures, FLTK is lacking documentation and I'm not sure it answers to my needs and GTK+ wasn't working.
Thank you very much for any input and help you can give me.
Keep it simple.
If working with C++ on Windows with a "non-express" version of Visual-Studio, just use MFC.
The framework is mature and there are tons of reference, examples and samples on the web (codeproject, codeguru, MSDN, ... )
Have you tried OpenCV's own highgui?
http://opencv.willowgarage.com/documentation/python/highgui__high-level_gui_and_media_i_o.html
"While OpenCV was designed for use in full-scale applications and can
be used within functionally rich UI frameworks (such as Qt, WinForms
or Cocoa) or without any UI at all, sometimes there is a need to try
some functionality quickly and visualize the results. This is what the
HighGUI module has been designed for."
Also see: OpenCV and creating GUIs
I've been spending my "inbetween" time at the office looking into C++. I'm primarily a flash & web developer, also working on a bunch of flash games, but I thought it was time to have a look at some non-web-based languages and see if I could get some real games going.
I've got the hang of how typing works, arrays, outputting using cout, structs, classes and so on and so on.
I seem to have found myself stuck in terms of what I can do next. Outputting to a DOS window obviously isn't that exciting - how do I get started on doing something graphical? A square moving around on the screen, even. Simple is better in this case.
As for the compiler - I've been using devcpp by Bloodshed; is this adequate or am I missing a more common compiler somehow?
Graphics can be done using DirectX in Windows, or OpenGL on every platform. It's a whole different discussion upon which to choose.
In addition to trying to work with graphics, you could try your hand at developing GUIs. I'd give Qt a shot. Be warned though, Qt is being sold by Nokia, but it's overall a very well known and heavily used framework. Or try direct Win32 (not necessarily something I'd suggest unless you're interested). Or try WinForms (requires .NET experience, and steals from the true C++; C++/CLR is NOT the same C++ you are learning--it adds to it). If you do go the .NET route, avoid "Managed C++" examples, as they that was the first iteration of C++/CLR, and they simply redid it and vastly improved it.
Two most common compilers: gcc (Linux, Mac and Windows) and Visual Studio's for development on Windows', I always use Visual Studio (there is a free version called Visual Studio Express that is a solid product) for Windows development simply because I love the IDE.
For a compiler, my school uses g++, an excellent, free C++ compiler that is compatible with many IDEs for unix-based C++ development. If you're running a windows machine, you'll have to download cygwin (which emulates a linux shell) - you'll have to select which executables you want to download with the cygwin shell, figuring out what items you need may take a little time (basically, download useful looking things for the type of development that you want to do; g++/gcc are very important).
http://cygwin.com/install.html
When you have this, you can easily configure netbeans or eclipse (I've had better experience with netbeans) to compile and run your C++ code through cygwin.
Also, my favorite resource for learning C++ has been cplusplus.com - it has detailed tutorials of all of C/C++'s standard functions.
Hope this helps a little!
Have a look at graphics and windowing libraries. For windowing, as you seem to be on Windows, there's builtin stuff. For more general applicability I suggest having a look at Qt or Gtk.
For graphics, the fancy stuff is usually done in either DirectX (basically Windows only) or OpenGL (more portable).
Compilers: GCC is commonly used in the Unix/Linux world and also available on Windows through Cygwin. In the Windows world you'll also find Microsoft's MSVCC as it comes with their development tools. Btw., there are free dev tools from Microsoft as well, see their Visual Studio Express Editions.
Some tips:
Work through one or more good books. I recommend "Accelerated C++" and "Effective C++". These books will teach you real C++ programming.
If you're on Windows then I think you're better off using Visual Studio. The learning curve for C++ is steep enough already. If you simultaneously need to learn how to work with gcc and makefiles then you are likely to become overwhelmed.
Windows specific: for simple graphics I find WinAPI and GDI+ useful. They are relatively easy to learn and they are immediately available.
How can you write a C++ program to open a window like this one...
Is it possible or can apps only be ran from the command line?
I'm using the G++ compiler... Do I need something else like visual studio?
Can I do it just by writing code?
Take a look at Qt which is a cross-platform framework that easily builds GUIs.
Then check out a Qt tutorial, do a google search. Here is one that will get you to "hello world"
Also, you might want to check out Code::Blocks as an IDE. It will use your already installed g++ compiler.
You can use Borland C++, Visual C++ they has GUI or wxWindow or GTK library.
GUI programming requires the use of additional libraries. There is a C++ GUI library supplied by Microsoft for Windows called MFC. There are many other GUI libraries out there.
If you use these GUI libraries, you don't need to run the application from the command line.
Search for WinApi Tutorials like this one
there are alot
or you can also you the Visual Studio MFC application wizard and create a dialog application
Microsoft provides a tuturial for doing that:
http://msdn.microsoft.com/en-us/library/bb384843.aspx
The best and most low-level way of doing this would be by using the Windows API:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows
Microsoft itself provides excellent tutorials and documentation on how to program with their Windows Application Programming Interface, but there are also numerous other tutorials out there that can be found quickly with a google search.
To create a window like the one you ask about in the question, you would be looking for the following link:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program
It might seem daunting at first, but the Windows API is extensive and provides a huge amount of functionality, on top of just creating GUIs. It would probably be worthwhile familiarising yourself with it if you are interested in Windows programming.
You need to use the Windows api from within C++.
I have developed WinAPI applications using MinGW without problems. Now, can I do the same with MFC?
I'm just guessing here but I think you would need to buy a copy of Visual Studio to get a license to use MFC. MFC is not well known for its portable use of C++ either. If you are familiar with MFC, you might find the learning curve for Qt to be reasonable (which I use with MinGW). The MFC/MinGW route sounds very painful :)
You cannot. MFC stand for Microsoft Foundation Classes and Microsoft isn't good at supporting any other products than theirs.
You may try to compile MFC under MinGW if you have the source but the result is uncertain.
I've never worked with COM before, and I've been tasked with writing an application that uses some third party COM objects. If anyone could point me to some good tutorials on how to use them it would be much appreciated. More immediately, it appears that I don't have the Active Template Library installed. I've searched online but can't figure out how to get it.
As Dan pointed out, these are distributed with Visual Studio.
If you don't have Visual Studio, you can get the ATL libraries from one of the Microsoft Visual C++ Redistributable packages:
2005 SP1 (32-bit)
2005 SP1 (64-bit)
2005 (Itanium)
2008 SP1 (32-bit)
2008 SP1 (64-bit)
2008 SP1 (Itanium)
Note: The ones marked 2005 are version 8 (atl80.dll), the ones marked 2008 are version 9 (atl90.dll).
It's part of Microsoft Visual Studio (but not the Express Edition.)
I think you have to own a copy of Visual Studio 2005 or 2008 (not Express) to get ATL. If you have one of those installed, but you don't have ATL then go to "Control Panel:Add/Remove Programs" and do a "Modify" install (with the program CD or DVD in the drive) and make sure the box for ATL is checked.
As for tutorials:
I haven't found a really good one online. There are a few OK pages on using ATL/COM:
The Active Template Library Makes
Building Compact COM Objects a
Joy by Don Box (veteran guru of
COM). This article starts: "I love
COM. COM is good. Like a fine pilsner
or ale, COM never disappoints. In
fact, the more I look at COM, the
more I like it. Unfortunately, I work
in C++, and C++ does not share my
appreciation for the finer things in
life." Despite the Grand Master's
proselytizing, and the fact that it's
12 years old now, it's a pretty good
article...
Mike Dunn's excellent tutorial on
COM on CodeProject.
DevGuy's C++ COM Tips -- kind of a hodgepodge of links and suggestions.
The COM Programmer's Cookbook -- this ancient (1995) article isn't bad, despite its age and the fact that it describes implementing COM objects in C rather than C++ (explicit vtables!)
I'm a little rusty myself w/ COM and ATL, but if I remember right, the classes you're going to want to learn that you'll use the most (especially if you are using someone else's COM objects rather than implementing your own) are CComBSTR, CComPtr, and CComVariant. Also the #import statement in Visual C++ makes using external COM objects much easier, it generates a smart pointer class for you from an external DLL or EXE.
If you're going to be implementing COM objects, I would strongly recommend getting a copy of ATL Internals (there's a newer edition out now covering ATL v8). Yes it does go into some gory detail in sections, but even as an intro book it's fairly well written.
If you've never used COM before, the "classic" books Essential COM and Effective COM are very good and you can probably get them inexpensively from your favorite sources of used books. You're also going to want to be very familiar with the RAII idiom, if you aren't already.
The newsgroup microsoft.public.vc.atl is very good for asking particular questions. (they tend to be more gruff there than on StackOverflow, though)
Beware: There are lots of little gotchas with COM, although ATL does help it become a lot easier & without a lot of bloat. The "simulated dynamic binding" techniques aka CRTP are useful in the C++ world, not just in the context of ATL/COM but especially if you are developing a library of reusable classes that you want to subclass or mixin in situations where only one instance is present at a time (e.g. a class CSpiffyFramework that provides mixin functionality that you want to reuse a lot, and you have a derived class that you want to include that functionality, and it's not part of a virtual object model so you don't really need a vtable).
Good luck!
I installed this: http://www.microsoft.com/en-us/download/details.aspx?id=3138 and got the C++ compiler and all stuff on my buildserver, but no ATLMFC libraries.
The redist packages linked above is just that, redistributables, not the headers and includefiles needed..
After lots of searching, I ended up installing vs2008 on the server, crap.
here is how to use atl with vs express:
you need WDK 7.1.0:
https://www.microsoft.com/en-us/download/details.aspx?id=11800
Download Visual Studio Express Edition
Get VS Express C++ free from Microsoft
Download the freely available Windows Driver Kit (7.1 or later) from Microsoft
Get WDK 7.1.0 free from Microsoft
You can mount the ISO file with Virtual Clone Drive or extract it with 7-zip.
Install the WDK and select the "Build Environments" option
This will install the ATL and MFC header and lib files. ATL is a requirement for FireBreath on windows. Make sure to install this in the default location so that FireBreath can find it
For VS Express 2010
If you are using an older version of FireBreath, this post by scjohn may be useful for you. Note that FireBreath 1.4 beta 1 and later these steps are no longer needed!
http://www.firebreath.org/display/documentation/Building+with+Visual+Studio+Express
[vs2010 express include path]
C:\WinDDK\7600.16385.1\inc\atl71
[vs2010 express lib path]
C:\WinDDK\7600.16385.1\lib\ATL\i386