In Visual C++ 2017: Where in the property pages does it say what Application Types correspond to the projets? - c++

I am trying to recreate a Visual C++ Solution that had about 30 projects so that the general organization will be cleaner.
The original "solution" was in fact a Visual C++ 6 workspace from the turn of the century, migrated into VS 2017.
Some of the projects will be close to being clones of the old ones.
When I try to create a project, I am asked what Application Type it must be:
Single Document/Multiple document/Dialog based or Multiple top level documents.
I thought I could guess this by looking at the property pages of the existing documents, but I can't seem to find it. Or am I likely to be going in the wrong direction?

As far as I'm concerned, we couldn't guess this by looking at the property pages of the existing documents. I suggest that you could check MainFrm.cpp in the project source file to distinguish the project from a single document / multiple documents / dialog based or multiple top-level documents.
A multiple documents:the document's frame window can hold multiple child windows.
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
A single document:the document's frame window can hold only one document.
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
dialog based: There is no MainFrm.cpp in the source file.
multiple top-level documents:Creates a multiple top-level architecture for your application, where a view class is based on CView.
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
clicks New Frame on the File menu:
For more details, I suggest you could refer to the Application Type, MFC Application Wizard

Related

How to package several icons for different sizes in a VS C++ app?

I'm developing a C++ app in Visual Studio 2022 with a UI (UI library is wxWidgets). I'm trying to figure out how icons work. I gathered from researching that Windows expects a variety of different icons to be packaged with apps for the best UX (see Which icon sizes should my Windows application's icon include?). However I can't seem to find a way to get multiple icons taken into account.
My understanding so far is that all resource related things, including icons, are controlled by Resource.h and <projectName>.rc, both of which are initially provided by the VS template for a C++ App.
I've removed the provided icons (i.e the "normal" and "small" ones) and have instead imported many icons, one for each size, in the Resource View.
But regardless of that, always one icon seem to be used at a time.
Checking the contents of <projectName>.rc, I see the following:
I also expect the following, in Resource.h, to be relevant:
It seems that independently of the icon sizes, IDI_ICON1 is used. If it's 16x16, it's upscaled in context that requires it, if it's 256x256, it's downscaled (poorly, somehow ?) when required i.e in almost all contexts.
How should this be done ? Are there resources available on the matter I may have missed ?
You should embed all your ico files with different resolution into one ico file. The ico file is actually a container and can contain multiple images inside.

How to use google map API with MFC or QT in c++ language?

I have a question how to use google map api in my developing program.
My program is being implemented by c++ language in Visual studio 2017 environment and MFC for graphical interface in usual.
I want to develop program of two versions using google map api.
The first one is to use the google map in my program without internet connection.
The second one is with internet connection.
If anyone know how to do it, please answer to my question.
Qt C++ provides a QWebChannel, which fills the gap between C++ applications and HTML/JavaScript applications.
You need to create a QWebChannel and register a JavaScript helper Object in C++. This object exposes public methods, which are invokable calling from JavaScript in HTML.
QWebEngineView::setUrl() hosts a page, which has Google Maps.
QWebEnginePage::runJavaScript() gives you the power of manipulating the map. C++ call JS, and JS call C++ --- this is truly powerful!
I faced the same need as yours. The solution I have found was to use an embedded browsing component and from that component access Google Maps.
See my article about this implementation.
Basically, here are the instructions for adding such component to your MFC application:
Open Visual C++ and follow these steps:
Choose New from the File menu.
Select MFC AppWizard (exe).
Enter the project name and select a location.
Click OK. When the dialog box for Step 1 appears, select the application type that is appropriate for your application—single document, multiple document, or dialog-based. Select "Dialog-based" for this example.
Click Next.
Select application features and support.
The dialog box for Step 2 asks you to select any features and support your application will need—an About box or automation support, for example. The WebBrowser control is an ActiveX control, so select ActiveX Controls. Click Next to go to the next step.
Select the project style.
The dialog box for Step 3 is used to define your project. You have only one project style option, Standard MFC. But you can indicate whether you want the IDE to generate comments in the source code, and you can specify how you want to use the MFC library. The default selections are appropriate for most applications. Click Next to go to the next step. Name the files and classes. The dialog box for Step 4 displays the names of all the files and classes that Visual C++ created. You can change these to more descriptive names or to names required by your specification. Click Finish.
Add a WebBrowser control.
The actual part that interface with Google Maps is embedded within an HTML code that should be also hosted, so my solution combines the browser's hosting with the interface with Google Maps.
The HTML code is formatted in this example:
HTML_TEXT.Format(L"<!DOCTYPE html><html><meta http-equiv=\"IE X-UA-Compatible\" content=\"IE = edge\"><body><div id =\"googleMap\" style=\"width:%dpx;height:%dpx\"><script>function myMap(){var mapProp = {center:new google.maps.LatLng(%f, %f), zoom : 10};var map = new google.maps.Map(document.getElementById(\"googleMap\"), mapProp);marker = new google.maps.Marker({position: new google.maps.LatLng(%f, %f),map: map});}</script><script src = \"https://maps.googleapis.com/maps/api/js?key=%s&callback=myMap\"></script></div></body></html>", w, h, Latitude, Longitude, Latitude, Longitude, API_KEY);
As you can see, you can generate a map with a marker pointing on a given location using Longitude and Latitude. You also need to obtain an API_KEY from Google.

How to see the list of objects in current file in Visual C++ 2012?

Assume we have the huge Visual Studio solution and there are many files (tabs) opened. Does Visual Studio 2012 (Visual C++ particularly) have any View panel which will show the interactive list of objects from the current file when I switch to the corresponding tab? Or maybe there is an official extension which will help me? The standart Object Browser is not exactly what I want, because I'd like to see the list of all objects from the current file and only them.
Thanks!
Edit: I mean the list of all classes, structures, variables, methods etc., no matter declared or only defined in this file.
Did you try Visual-Assist extension? It might be helpful.
http://www.wholetomato.com/default.asp
Use Object Browser.
The Object Browser lets you select and examine the namespaces, classes, methods, and other programming symbols available for use in your project. You can open the Object Browser from the View menu, by clicking the Object Browser button on the main toolbar, or by typing CTRL+ALT+J. It will work for VS2005, VS2008, VS2010 and VS2012. Check out here for more info.
EDIT: If you want to see a so-called global tree view. I only know this works for WPF projects. You can use the WPF Tree visualizer to explore the visual tree of a WPF object, and to view the WPF dependency properties for the objects that are contained in that tree. For more information about visual trees, see Trees in WPF. For more information about dependency properties, see Dependency Properties Overview. Check out here.

How do you change your app icon in visual studio 2013?

I'm new to visual studios and I just created this very short calculator and I want to put it on mediafire for people to download but I wanted to change the icon..
I've heard that you select your app in solution explorer and Project>Properties
But my properties menu seems different.
It saids calculator property pages.
It doesnt have the tabs like ~Publish~ or ~Applications~ where people said you change your icon.
My properties is like this:
Configuration: Active(Debug)
and some other stuff below it some complicated stuff(to me)
Why doesnt mine have what other people have? I just want to share my first ever app with a custom icon. Help please, will appreciate it.
Create a text file, rename it res.rc, edit it to contain the line:
201 ICON "myicon.ico"
Add that file to your project. The file myicon.ico must exists.
Note: This is a bit hacky, the numerical vaulues should preferably be defined in a header.
You might be confused because Visual Studio supports different languages, and its UI is not consistent across those languages. Since you tagged it C++, the "old" rules apply. An application icon is a so-called resource.
You have to provide an .ico file, and reference it in a .rc file. The resource compiler (RC) compiles it into a .res file, and the linker then adds it to the EXE.
In C++, if you open the form in designer view, the properties window has an icon property that will allow you to browse for the icon of your choice.
Just for reference, i spent two hours trying to change it without any success until i resized the icon, it should be 32x32 and another one for small icon -not sure if its necessary though- with 16x16.
visual studio creates two icons when create the project , one is called small.ico and one is name yourexe.ico, just replace those and make sure to have correct sizes.

Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?

Vista introduced an interface: IFileDialog::SetFilter, which allows me to setup a filter that will be called for every potential filename to see if it should be shown to the user.
Microsoft removed that in Windows 7, and didn't support it in XP.
I am trying to customize the our Open file dialog so that I can control which files are displayed to the end user. These files are marked internally with a product-code - there isn't anything in the filename itself to filter on (hence file extension filters are not useful here -= I need to actually interrogate each one to see if it is within the extra filter parameters that our users specified).
I would guess that Microsoft removed the SetFilter interface because too often it was too slow. I can imagine all sorts of similar ideas to this one which don't scale well for networks and cloud storage and what have you.
However, I need to know if there is an alternative interface that accomplishes the same goal, or if I really am restricted to only looking at the file extension for filtering purposes in my File dialogs?
Follow-up:
After looking further into CDN_INCLUDEITEM, which requires the pre-vista version of OPENFILENAME, I have found that this is the most useless API imaginable. It only filters NON-filesystem objects. In other words, you can't use it to filter files. Or folders. The very things one would filter 99.99% of the time for a file open or save dialog. Unbelievable!
There is a very old article by Paul DiLascia which offers the technique of removing each offending filename from the list view control each time the list view is updated.
However, I know from bitter experience that the list view can update over time. If you're looking at a large folder (many items) or the connection is a bit slow (heavily loaded server and/or large number of files), then the files are added to the dialog piecemeal. So one would have to filter out offending filenames repeatedly.
In fact, our current customized file open dialog uses a timer to look at the view's list of filenames periodically to see if any files of a given pattern exist, in order to enable another control. Otherwise it's possible to check for the existence of these files, find none, but a moment later the view updates to have more filenames, and no events are sent to your dialog to indicate that the view has been changed. In fact, my experience with having to write and maintain code for the common controls file dialogs over the years has been that Microsoft is not very cluefull when it comes to how to write such a thing. Events are incomplete, sent at not-useful times, repeated when not necessary, and whole classes of useful notifications don't exist.
Sadly, I think I might have to give up oh this idea. Unless someone has a thought as to how I might be able to keep up with the view spontaneously changing while the user is trying to interact with it (i.e. it would be awkward to go deleting out entries from the list view and changing the user's visual position, or highlighted files, or scroll position, etc.)
You need to initialise the callbacks for your CFileDialog. Then you need to process CDN_INCLUDEITEM notification code to include or exclude items.
You can also check this great article. The author uses some other approaches in addition to callbacks
As you have already discovered, starting in Windows 7 it is no longer possible to filter out files from being displayed based on content, only file extension. You can, however, validate that the user's selected file(s) are acceptable to you before allowing the dialog to close, and if they are not then display a message box to the user and keep the dialog open. That is the best you will be able to do unless you create your own custom dialog.