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

Started by
10 comments, last by NikiTo 6 years, 10 months ago

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)

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

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

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

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.

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++.

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.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

@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.

Thank you, @mhagain! The tutorial at http://zetcode.com/gui/winapi/menus/ did perfectly and easily the job for me.

I see they used L"&File".. can you briefly tell me what this "&" means? I remove it and it works the same way.

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

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.

This topic is closed to new replies.

Advertisement