Compile error... Resource error to :/.

This is a discussion on Compile error... Resource error to :/. within the Windows Programming forums, part of the Platform Specific Boards category; (Borland bcc55 compiler, Windows XP) I just dived back into win32 programming hoping I might be able to solve my ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Question Compile error... Resource error to :/.

    (Borland bcc55 compiler, Windows XP)
    I just dived back into win32 programming hoping I might be able to solve my problems... But, nope, windows still hates me :P.

    I started reading forgers tutorial, I read all of it, then starting some code. Its a carbon copy from the one on the site, but it wont work. This line:

    Code:
       HBITMAP hbmOld = SelectObject(hdcMem, ScreenDisplay_Object); //Line 28
    (ScreenDisplay_Object is a global HBITMAP.)

    Code:
    C:\Borland\BCC55\Bin>bcc32 -tW c:\M.cpp
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    c:\M.cpp:
    Error E2034 c:\M.cpp 44: Cannot convert 'void *' to 'HBITMAP__ *' in function
    __stdcall WndProc(HWND__ *,unsigned int,unsigned int,long)
    *** 1 errors in Compile ***
    Am I right in assuming SelectObject returns nothing? Well, based on that idea, I tried this:

    Code:
       HBITMAP hbmOld;
       SelectObject(hdcMem, ScreenDisplay_Object); //Line 29
    But, I get a resource error.

    Code:
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    Error: Unable to open file 'BIT.RC'
    
    C:\Borland\BCC55\Bin>
    Code:
    #include <windows.h>
    #pragma resource "Bit.rc"
    As far as I know #pragma should get the resource to open. Do I have to put it somewhere other than in the files directory?

    Heres the entire program as it stands now:

    Code:
    #include <windows.h>
    #pragma resource "Bit.rc"
    
    HBITMAP ScreenDisplay_Object = NULL;
    
    const char g_szClassName[] = "myWindowClass";
    
    #define IDB_BALL                        101
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
     switch(msg) {
    
      case WM_CLOSE:
       DestroyWindow(hwnd);
       break;
    
      case WM_DESTROY:
       DeleteObject(ScreenDisplay_Object);
       PostQuitMessage(0);
       break;
    
      case WM_CREATE:
       ScreenDisplay_Object = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BALL));
       if(ScreenDisplay_Object == NULL)
        MessageBox(hwnd, "Could not load object!", "Error", MB_OK | MB_ICONEXCLAMATION);
       break;
    
      case WM_PAINT: {
       BITMAP bm;
       PAINTSTRUCT ps;
    
       HDC hdc = BeginPaint(hwnd, &ps);
    
       HDC hdcMem = CreateCompatibleDC(hdc);
       HBITMAP hbmOld;
       SelectObject(hdcMem, ScreenDisplay_Object); //
    
       GetObject(ScreenDisplay_Object, sizeof(bm), &bm);
    
       BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
    
       SelectObject(hdcMem, hbmOld);
       DeleteDC(hdcMem);
     
       EndPaint(hwnd, &ps);
       }
       break;
    
      default:
       return DefWindowProc(hwnd, msg, wParam, lParam);
     }
     return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
     WNDCLASSEX wc;
     HWND hwnd;
     MSG Msg;
    
     wc.cbSize        = sizeof(WNDCLASSEX);
     wc.style         = 0;
     wc.lpfnWndProc   = WndProc;
     wc.cbClsExtra    = 0;
     wc.cbWndExtra    = 0;
     wc.hInstance     = hInstance;
     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
     wc.lpszMenuName  = NULL;
     wc.lpszClassName = g_szClassName;
     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
     if(!RegisterClassEx(&wc)) {
      MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
      return 0;
     }
    
     hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "The title of my window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
    
     if(hwnd == NULL) {
      MessageBox(NULL, "Window Creation Failed!", "Error!",
      MB_ICONEXCLAMATION | MB_OK);
      return 0;
     }
    
     ShowWindow(hwnd, nCmdShow);
     UpdateWindow(hwnd);
    
     while(GetMessage(&Msg, NULL, 0, 0) > 0) {
      TranslateMessage(&Msg);
      DispatchMessage(&Msg);
     }
    
     return Msg.wParam;
    }
    Gah, working windows resource files always makes my head ache >.>. As I said, this is basicaly the forgers tutorial with some minor adjustments. Anyone else using borlands compiler figured out how to compile theyse? And, will making that alteration to the tutorial completely change how the program acts? (Seems like it would, but it doesnt compile in the first place -,-)

    Thank you!
    Last edited by Blackroot; 08-23-2006 at 04:44 AM.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    I tried compiling via makefile / .bat:

    Code:
    #Rpg.mak
    CFLAGS=-c
    LFLAGS=-aa
    STARTUPOBJS=c0w32.obj 
    LIBS=import32.lib cw32.lib
    MYOBJS=C:\Rpg.obj
    RESOBJS=C:\Bit.rc
    EXENAME=C:\Rpg.exe
    
    $(EXENAME): $(MYOBJS) $(RESOBJS)
    	ilink32 $(LFLAGS) $(STARTUPOBJS) $(MYOBJS),$(EXENAME),,$(LIBS),,$(RESOBJS)
    Code:
    rem build.bat
    set path=c:\borland\bcc55\bin;%path%
    make -f Rpg.mak
    It places a few files in my c drive, but no executable. The bin files version of rpg.exe is not updated either. Grr..
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Error E2034 c:\M.cpp 44: Cannot convert 'void *' to 'HBITMAP__ *' in function
    __stdcall WndProc(HWND__ *,unsigned int,unsigned int,long)
    Errors like this usually arise because you are attempting to compile c source code (where such casts are unnecessary) as c++. You therefore have two choices: recompile as c or cast to the desired type(the error message tells you explicitly which type).

    Source code and resource scripts are compiled separately into objects which are linked into the final exe; the process is slightly more fiddly with Borland because the resource objects can only be added to the exe once it's been built, despite the documentation claiming otherwise. I'd avoid the #pragma resource "Bit.rc" and stick with using the makefile to build the project; it should already contain all the rules necessary to compile source code and resource scripts and link everything together.

    I'd recommend trying out another compiler like MinGW (dev-cpp or code::blocks ides are popular) or msvc-express; both are free.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Switching compilers is probably a good idea, borland doesnt seem to concerned about windows stuff -,-. I'll try mingw, because I tend to like the command line compiling for whatever reason :P.

    Well, now to dl mingw to fully compile this :P. Thanks for the suggestion, I forgot other compilers existed lol -,~.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 01:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 12:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 07:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 08:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 01:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21