Drahoš Maďar
Drahoš Maďar

Reputation: 567

C++ compiler error - RC2108 : expected numerical dialog constant

I'm working with VS2005 to target WinCE device, currently building MFC GUI. I'm getting an error related to row

CTEXT IDC_PG,168,183,63,63

saying

my_app.rc(95) : error RC2108 : expected numerical dialog constant

I'm convinced that CTEXT line is problematic (error is pointing at line after this one. I have moved CTEX line from middle of the block to the end, I was getting error for line after CTEXT also when it was n the mid) but I have no idea what might be incorrect here.

This is full block of code:

BEGIN
   LTEXT           "Static",IDC_SEL,337,122,63,61,SS_NOTIFY
   LTEXT           "Static",IDC_ESC,337,183,62,63,SS_NOTIFY
   LTEXT           "Static",IDC_RETURN,337,122,63,123,SS_NOTIFY
   LTEXT           "Static",IDC_RB,337,45,63,61,SS_NOTIFY
   LTEXT           "Static",IDC_LB,337,0,63,61,SS_NOTIFY
   LTEXT           "Static",IDC_DN,337,61,63,61,SS_NOTIFY
   LTEXT           "Static",IDC_UP,337,0,63,61,SS_NOTIFY
   LTEXT           "Static",IDC_SET,274,183,63,63,SS_NOTIFY
   LTEXT           "Static",IDC_VYPLN,0,183,211,63,SS_NOTIFY
   LISTBOX         IDC_LF,1,1,338,182,LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_TABSTOP
   CTEXT           "Static",IDC_PHOTO,0,0,337,245
   CTEXT           "Static",IDC_BG,0,0,400,245
   LTEXT           "Static",IDC_ESC2,202,182,62,63,SS_NOTIFY
   CTEXT           IDC_PG,168,183,63,63    //PagingWidget
END

Thanks in advance for shedding some light on this.

Upvotes: 0

Views: 2697

Answers (2)

Michaël Roy
Michaël Roy

Reputation: 6481

If, on the other hand, you only want to be able to access a widget at runtime, to change its contents, Right click on the dialog -> Create class, make sure the type is CDialog. Then, you can create variables for the controls (widgets) by right clicking on them -> Create variable.

The rule of thumb for control variables, is to create control variables for dyamic controls that will change contents during the lifetime of the dialog.

For simpler dialogs, which only diplay and gather data from the user, it's best to us common-types variables that will automatically fill your controls on entry, and gather data one successful exit.

Suggested reading: https://msdn.microsoft.com/en-us/library/0khz1cy9(v=vs.90).aspx

Hopefully this is what you want to do. You will need to have a working resource file to use MFC's code generation capabilities.

Upvotes: 0

Michaël Roy
Michaël Roy

Reputation: 6481

Your explained your problem in this one sentence: "I dont want to make it "Static" as im planning to use that widget to show currentPage"

The compiled resources in your project that is resource.h, and all *.rc and *rc2 files can contain only static data that is linked with you application. All resource items must have an ID (a UINT as seen from your application code but a STRING for the OS) that is constant and defined at compile time.

If you need to create controls dynamically, you must do so in the code. You can manage them by having them as members of your dialog class, or in dynamic memory in a vector of pointers (CWnd's cannot be copied). MFC provides CObArray which provides some basic RAII for dynamically allocated CWnd*.

If you really feel the need to have to reference rectangles on your dialog to place your dynamic controls, insert some dummy, invisible static controls on the dialog with the editor.

Alternatively, if you know already the maximum number of widgets you'll need, place them as static items on the dialog resource, and show /hide items in the OnInitDialog() member function for your dialog.

Sorry, for bringing you the bad news... I hope you have a good backup.

Upvotes: 1

Related Questions