Sign in to follow this  
NikiTo

How to create through C++ code a drop-down toolbar like this one?

Recommended Posts

e8a3d66495.png

The example code i put my hands on uses a .rc file and I can't open it. Apart from that, I need to be able to generate the list dynamically with the creation of the window. The number of items will vary, their names and the function executed will vary too regard the commands that user introduces in the console application that creates the window. That's why I want to generate the control/list through code. The window creation part I know how to do it.
Only telling what methods/structures to use would be enough, because I will search for it. When I search through MSDN, there are no screenshots and I am not sure if the drop-list they show the code for would be created inside the window or on top and what style it will be.
(My solution in VS is of the 'Win32 Console Application' type and it's a dll, in case this info helps)

Share this post


Link to post
Share on other sites

This is called a menu - look for examples for creating a menu in a Windows program.

Here might be a useful place to start: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646977(v=vs.85).aspx

This looks like a simple tutorial: http://zetcode.com/gui/winapi/menus/

Also here: http://www.winprog.org/tutorial/menus.html

Share this post


Link to post
Share on other sites

Thank you, @mhagain!

@Alvaro, the main purpose of the program is to work on data. It would perfectly work without a GUI, but I create temporary windows from the console in order to test the program at startup. For example, I plan to use GPUGP and I will visually test the GPU setup at startup. Then, when the console application starts to work on data, windows will be closed forever. It has lot of prompt menus too and those was much easier for me to do them on the console.

Share this post


Link to post
Share on other sites

Write a GUI front-end application that starts the data processing application. Use command-line arguments (or a temporary data file), to pass GUI information to the data processing application.

As the front-end isn't time-critical at all you can write it in any language rather than being forced to write it in C++.

Share this post


Link to post
Share on other sites

I know nearly nothing about VS but, why did you make it a "Console Application" if you want a GUI?

 

In addition to OP's response, a lot of people (I am not one of them) use the console for debugging and then switch the type later.

Share this post


Link to post
Share on other sites

@Khatharr, yep, it's comfortable to print something when the window fails to create, when window passes certain messages or print all messages the message pump processes.

Edited by NikiTo

Share this post


Link to post
Share on other sites

It just provides an automatic shortcut key so you can do alt-f (in this case) to open the menu.

Great! Thank you! But what if first letter of various menus repeats itself. User will create those menus dynamically, so there could be the same first letters repeated.

Share this post


Link to post
Share on other sites

You'd do something like this :

 

Menu names :

Fee    = &Fee

Fi        = F&i

Fo         = F&o

Fum     = F&um

 

or whatever you like really - it's just there as a convenience and the ampersand is the shortcut key. You don't have to have it at all which may be easier if menus are dynamic.

Edited by xexuxjy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this