Solved

Getting error 1813: ERROR_RESOURCE_TYPE_NOT_FOUND, don't know why

Posted on 2004-08-19
24
5,656 Views
Last Modified: 2013-12-03
I've got a .NET 2003 solution where part of it is a large unmanaged C++ class (not MFC) that needs to request user input.      I created the dialog (IDD_DIALOG1) using the resource editor, then #include'd the resource.h file in the class file.  Both of the following tries at displaying the dialog box produces the 1813 error:

      iRet = DialogBox(NULL, TEXT("IDD_DIALOG1"), NULL, (DLGPROC)Calculate::ToldDlgProc);
      int iErr=GetLastError();

      iRet = DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)Calculate::ToldDlgProc);
      int iErr=GetLastError();

When I hover the mouse over IDD_DIALOG1 in the call to MAKEINTRESOURCE, the Intellisense tooltip displays "#define IDD_DIALOG1 103", so it seems to know at least what the ID is.  Following the DialogBox call, iRet is set to -1.

I've been trying to solve this for a couple days, and it's taking way too long.  It would sure be nice if it was as easy as displaying a MessageBox.  It probably isn't that difficult, but the urgency of this problem is worth 500 points to me.  Am I somehow missing a link between the class and the resource?

Thanks in advance for any help on this.

Stu
0
Comment
Question by:scrdb
  • 12
  • 9
24 Comments
 

Author Comment

by:scrdb
Comment Utility
I just realized I submitted this in the Win Prog area.  Maybe it should be in Visual C++ .NET, or C++?
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Why didn't you move it *with* my comment?

OK, again then. This should be

     iRet = DialogBox(NULL, IDD_DIALOG1, NULL, (DLGPROC)Calculate::ToldDlgProc);
    int iErr=GetLastError();

    iRet = DialogBox(NULL, IDD_DIALOG1, NULL, (DLGPROC)Calculate::ToldDlgProc);
    int iErr=GetLastError();

Since you already are using resource IDs, there's no need to use MAKEINTRESOURCE()
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Oh, and BTW, this one belongs more into the Windows programming area *veg* :o)
0
 

Author Comment

by:scrdb
Comment Utility
jkr,

You answered too fast!  I asked for the move only a few minutes after the original post.

Anyway, thanks for your response.  However, when I change the code to not use MAKEINTRESOURCE, I get a compiler error:

error C2664: 'DialogBoxParamA' : cannot convert parameter 2 from 'int' to 'LPCSTR'

Is there a better way to do this?  I really just want a simple "inputbox" function (like in VB), with an OK and Cancel, that can retrieve user input.

Thanks,

Stu
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Here I stand corrected, it indeed should be

    iRet = DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)Calculate::ToldDlgProc);
    int iErr=GetLastError();

Is your resorce file (.rc) included in your project?
0
 

Author Comment

by:scrdb
Comment Utility
Well, it seems to be included.  In the Solution Explorer, the file (T_Calc.rc) is shown under the Resource Files folder, which is under the T_Calc project.  Also, when I compile the resource (right-click on the .rc file and select compile), the T_Calc.res file is updated in the Debug folder.  In the Project properties settings, the Resources command line shows /fo"Debug/T_Calc.res".

I'm really stumped by this.  Do I have to do anything else to ensure that the resource file is included in the project?
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
That's pretty weird indeed. What are the contents of T_Calc.rc?
0
 

Author Comment

by:scrdb
Comment Utility
The contents of the file are as follows:

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 179
        TOPMARGIN, 7
        BOTTOMMARGIN, 88
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG1 DIALOGEX 0, 0, 186, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
    WS_SYSMENU
CAPTION "Input"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "&OK",IDOK,135,53,37,14
    PUSHBUTTON      "&Cancel",IDCANCEL,135,70,37,14
    LTEXT           "Static",IDC_STATIC,15,17,155,29
    EDITTEXT        IDC_EDIT1,17,59,108,15,ES_AUTOHSCROLL
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
That actually looks OK to me...
0
 

Author Comment

by:scrdb
Comment Utility
Just for grins, here's the contents of the resource.h file:

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by T_Calc.rc
//
#define IDD_DIALOG1                     103
#define IDC_EDIT1                       1010

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        104
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1011
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Hmm, just an idea - check whether AFX_TARG_ENU is defined somewhere, otherwise the DIALOGEX section will not be recognized by the resource compiler...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:scrdb
Comment Utility
It doesn't appear to be (tried two things: searched the project, and just pasted into code to see if Intellisense knows about it).  How is it to be defined?  Maybe I'm just missing an include file?  Wouldn't that be nice?
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
That should be set in the project settings. Just for fun, you could try to set

#define AFX_TARG_ENU

in your resource.h
0
 

Author Comment

by:scrdb
Comment Utility
What should it define?  Shouldn't it have an "as" part?
0
 

Author Comment

by:scrdb
Comment Utility
Never mind my last comment.  I wasn't thinking about it being used as a compiler directive.

I tried that and it didn't work.  It looks like the compiler sets the language and code page depending on whether AFX_TARG_ENU is #defined (AFX_TARG_ENU must just mean that the target is English).
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
>>AFX_TARG_ENU must just mean that the target is English

To be more precise, it means Enlish (US).

Have you already tried setting up your project from scratch again?
0
 

Author Comment

by:scrdb
Comment Utility
No.  I've felt that the time to do that, plus maybe missing a property setting, would be risky.  Of course, the amount of time I've spent on trying to do what should be a built-in function (in my opinion) has probably eclipsed that by now.

As I mentioned at the beginning of this question, this class is part of a larger solution (that also contains VB and managed C++ projects).  I'm a bit reluctant to blow away an entire project and start again, although if necessary I guess I'll have to.  Any tips on making it easier?
0
 

Author Comment

by:scrdb
Comment Utility
Well, I went ahead and created a new project, copied all the header and source files in, included the references, set the properties, etc.  Created a new dialog, compiled it, made sure the resource.h file was right, then ran it.  Still got the 1813 error.

I have 3 incidences left on my MSDN subscription.  I may go ahead and burn one if nobody has any other ideas...
0
 

Author Comment

by:scrdb
Comment Utility
OK, after a LONG talk with Microsoft support, the dialog box is showing.  As with most of these kinds of issues, the solution turned out to be relatively simple:

The .exe that is running is VB, and the resource is in the C++ dll.  So, the solution was to pass the handle to the C++ dll to the DialogBox function as follows:

iRet = ::DialogBox(::GetModuleHandle("T_Calc.dll"), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)Calculate::ToldDlgProc);

Now I just have to code the dialog to return the user's input.
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
No objections :o)
0
 

Author Comment

by:scrdb
Comment Utility
If I have a Premium account, does a refund of points even matter?  If so, I'm afraid I don't understand what the Adminstrative Comment above means.  I found the answer myself, and gave that answer in my last post.  What else do I need to do?
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
Comment Utility
Closed, 500 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now