Search code examples
c++dialogresource-files

How do I implement this code into a dialog type resource file?


// Epvolume.rc -- Resource script

#include "resource.h"
#include "windows.h"
#include "commctrl.h"

//
// Dialog box
//
VOLUMECONTROL DIALOGEX 0, 0, 160, 60
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU | DS_SETFONT
CAPTION "Audio Endpoint Volume"
FONT 8, "Arial Rounded MT Bold", 400, 0, 0x0
BEGIN
    LTEXT      "Min",IDC_STATIC_MINVOL,10,10,20,12
    RTEXT      "Max",IDC_STATIC_MAXVOL,130,10,20,12
    CONTROL    "",IDC_SLIDER_VOLUME,"msctls_trackbar32",
               TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,20,140,12
    CONTROL    "Mute",IDC_CHECK_MUTE,"Button",
               BS_AUTOCHECKBOX | WS_TABSTOP,20,40,70,12
END

I don't know a thing about resource files, I tried to make it a dialog resource type but I don't quite know how to enter this code into that dialog file because I don't really know how to work it. Just to clear things up, when I make a new dialog file it gives me a blank dialog, which I don't know how to edit, maybe I'm doing something wrong? I don't know where to put the code


Solution

  • You need to open the resource file as text rather than with the designer. In solution explorer select the resource script file and hit ctrl+alt+0. You can then cut-and-paste text as usual.

    Most of the time when simply laying out a new dialog it is easier to use the designer but editting it as text is much easier when you have existing resources you want to bring into a project.

    Note that you will also need to edit resources.h to add the various control symbol names (for example IDC_SLIDER_VOLUME) as well as modifying _APS_NEXT_CONTROL_VALUE to be the next unused value.