visual c++ - MFC LoadString fails when attempting to load a string from afxres.rc -


when program attempts generate afx_idp_parse_real error user, fails load string stored in afxres.rc file. found this question already, solved because reference afxres.rc accidentally deleted program.rc file. not case me. program.rc file includes exact code listed in answer include afxres.rc file.

in debug mode, breaks on assert below.

int afxapi afxmessagebox(uint nidprompt, uint ntype, uint nidhelp) {  cstring string;  if (!string.loadstring(nidprompt))  {   trace(traceappmsg, 0, "error: failed load message box prompt string 0x%04x.\n", nidprompt);   assert(false);  }  if (nidhelp == (uint)-1)  nidhelp = nidprompt;  return afxmessagebox(string, ntype, nidhelp); } 

when running application via .exe, generates empty warning box since afx_idp_parse_real string not loaded; goes string in afxres.rc.

what cause application not load string afxres.rc?

just letting know not enough include afxres.rc file normally, way include header files cpp/h files. need include twice. if create brand new mfc project , check code of rc file (using "view code" option) notice there normal include:

///////////////////////////////////////////////////////////////////////////// // // generated textinclude 2 resource. // #include "afxres.h" 

and there textinclude section inside rc file:

2 textinclude  begin     "#include ""afxres.h""\r\n"     "\0" end 

you need make sure same thing in project. alternatively, can use "resource includes" wizard available via right click on resource view allows editing both sections via dialog box:

vc resource includes wizard


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -