This was not a problem under Visual Studio 6. But in VS 2003.Net it persists.
It appears that in some situations the editor incorrectly formats CONTROL statements. This only seems to happen when the control has a Help ID, but it does not always happen even then.
An example:
CONTROL "",IDC_CFG_LISTER_ITEM_COLOUR_FG,"dopus.dropdown.button", 0x5,137,16,30,13,0,0,HIDC_CFG_LISTER_ITEM_COLOUR_FG
In this example, there is one too many parameters. The ",0,0" preceding the HIDC_xxx should only be ",0", eg:
CONTROL "",IDC_CFG_LISTER_ITEM_COLOUR_FG,"dopus.dropdown.button", 0x5,137,16,30,13,0,HIDC_CFG_LISTER_ITEM_COLOUR_FG
When this resource script is complied it produces the following errors:
Compiling resources....\language.rc(290) : error RC2111 : invalid control type.\language.rc(290) : error RC2113 : END expected in dialog.\language.rc(291) : error RC2135 : file not found:.\language.rc(292) : error RC2135 : file not found:.\language.rc(294) : error RC2108 : expected numerical dialog constant
Removing the erroneous ",0" fixes the problem, however the next time any dialog in the resource file is edited, the ",0"s are all put back in.
Workaround
Workaround would be to set the HELP ID property dynamically at runtime.You can follow the below steps to achieve this:
Let us assume we want to add help id to a TAB control having ID IDC_TAB1.
Open resource.hm file and add the #define as given below to specify value for HELP ID
#define HIDC_TAB1 1000 // some unique value for each control
If resource.hm file does not exist add a new file by name “resource.hm” in the Headers folder of the project. Also add, #include reaource.hm file in dialog editor’s header file.
Go to ::OnInitDialog() function of the Dialog and add the following code.
BOOL CSRTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
----
----
CWnd* pwnd = this->GetDlgItem(IDC_TAB1);
pwnd->SetWindowContextHelpId(HIDC_TAB1);
return TRUE; // return TRUE unless you set the focus to a control
}
The same is depicted in the figure below:-
However, you would be happy to know, that the issue is fixed in VS2005.Net.
Using VS2003.Net, we created a MFC application (dialog box editor) and added a Tab control on to the editor. Build fails and enumerates the compilation errors as posted by you.
Then the same was emulated using VS2005.Net and the solution build perfectly without any compilation errors. Opening the .rc file complied with VS2005.Net in notepad, you will find that the code generated is what is below:-
CONTROL "",IDC_TAB1,"SysTabControl32",0x0,53,33,50,30,0,HIDC_TAB1
In VS2003.Net, the same procedure resulted in
CONTROL "",IDC_TAB1,"SysTabControl32",0x0,53,33,50,30,0,0,HIDC_TAB1
No comments:
Post a Comment