Solved

Getting error 1813: ERROR_RESOURCE_TYPE_NOT_FOUND, don't know why

Posted on 2004-08-19
24
5,777 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 9
24 Comments
 

Author Comment

by:scrdb
ID: 11842687
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
ID: 11843203
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
ID: 11843208
Oh, and BTW, this one belongs more into the Windows programming area *veg* :o)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:scrdb
ID: 11843429
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
ID: 11843530
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
ID: 11843627
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
ID: 11843691
That's pretty weird indeed. What are the contents of T_Calc.rc?
0
 

Author Comment

by:scrdb
ID: 11843730
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
ID: 11843935
That actually looks OK to me...
0
 

Author Comment

by:scrdb
ID: 11844035
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
ID: 11844087
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
 

Author Comment

by:scrdb
ID: 11844199
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
ID: 11844390
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
ID: 11844583
What should it define?  Shouldn't it have an "as" part?
0
 

Author Comment

by:scrdb
ID: 11844723
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
ID: 11844758
>>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
ID: 11844861
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
ID: 11852630
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
ID: 11856497
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
ID: 11873904
No objections :o)
0
 

Author Comment

by:scrdb
ID: 11892954
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
ID: 11916902
Closed, 500 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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