Thread: graphics....linking resource files...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    255

    graphics....linking resource files...

    ok i have the cpp file rc file and header file and im trying to link them together: on DEV C++ i put this all in a project i hit rebuild all it links it makes the .dll file then i goto run and it says:

    host application not found! goto execution menu parameters and that part confuses me i dont get that parameters thing



    Code:
    #include <windows.h>
    #include "resource.h"
    
    const char g_szClassName[] = "myWindowClass";
    
    // Step 4: the Window Procedure
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch(msg)
        {
                           case WM_LBUTTONDOWN:
    // BEGIN NEW CODE
            {
                char szFileName[MAX_PATH];
                HINSTANCE hInstance = GetModuleHandle(NULL);
    
                GetModuleFileName(hInstance, szFileName, MAX_PATH);
                if(MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION == IDOK));
                MessageBox(hwnd, "TO TELL YOU","I HATE YOU ALL", MB_OK | MB_ICONINFORMATION);
            
            
            }
    //END NEW CODE
            case WM_CLOSE:
                 {
                          bool close;
                         
                          //LABEL4:
                          if(MessageBox(NULL,"ONLY THE LUBEMAN CAN CLOSE THIS!!!!", "So Are You The LUBEMAN???", MB_YESNO | MB_ICONERROR == IDNO));
                          {
                          close = false;
                          //if(close == true)
                          MessageBox(NULL,"Thank you","HAVE a good day and remeber USE THE LUBE LUBEMAN!!!!", MB_OK);
                          
                          //DestroyWindow(hwnd);
                          //goto label5;
                          }
                          if (close == true)
                          MessageBox(NULL, "NO LUBEMAN!!!!", "GIVE ME LUBEMAN", MB_OKCANCEL | MB_ICONERROR);
                         // {
                          //goto LABEL4;
                          //}
                         
                    // LABEL:
                        //  if(MessageBox(NULL, "CLICK YES IF YOU ARE GAY", "ARE YOU GAY", MB_YESNO | MB_ICONERROR) == IDYES);
                         // else goto LABEL;   
                       //   MessageBox(NULL, "HAHAHAHA COming out of denial feels good eh?.","yes?",MB_OK );  
                DestroyWindow(hwnd);
                }
            break;
            label5: case WM_DESTROY:
                PostQuitMessage(0);
            break;
            default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine, int nCmdShow)
        
        
    
    {
          //LABEL:
                  //        if(MessageBox(NULL, " ?????????????RANDOM ERROR????????"," Is dócha nach bhfuil seans ar bith ann?", MB_YESNO | MB_ICONERROR) == IDYES);
                         // else goto LABEL;
       /* if (MessageBox(NULL, "Click YES ..........", "MSG Box Test", MB_YESNOCANCEL | MB_ICONINFORMATION) == IDYES)
        if (MessageBox(NULL, "YOU CLICKED YES YOU DUMB FOOL", "MSG Box Test", MB_OK | MB_ICONINFORMATION) == IDOK)
        for(int i = 0;i < 3;i++){
         if (MessageBox(NULL, "Click OK", "MSG Box Test", MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
    {
    MessageBox(NULL, "you clicked ok", "OK", MB_OK | MB_ICONINFORMATION);
    }
     else if (MessageBox(NULL, "Click OK", "MSG Box Test", MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
    {
    MessageBox(NULL, "CLICKED CANCEL AHA!", "LOL!", MB_OK | MB_ICONWARNING);
    }}*/
    /*     if (MessageBox(NULL, "Click OK", "MSG Box Test", MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
    {
    MessageBox(NULL, "you clicked ok", "OK", MB_OK | MB_ICONINFORMATION);
    }
    else if (MessageBox(NULL, "Click OK", "MSG Box Test", MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
    {
    MessageBox(NULL, "CLICKED CANCEL AHA!", "LOL!", MB_OK | MB_ICONWARNING);
    }*/
        
        /*if (MessageBox(NULL, "Click OK", "MSG Box Test", MB_OK | MB_ICONINFORMATION) == IDOK)
    {
    MessageBox(NULL, "you clicked ok", "OK", MB_OK | MB_ICONINFORMATION);
    }*/
        WNDCLASSEX wc;
        HWND hwnd;
        MSG Msg;
    
        //Step 1: Registering the Window Class
        wc.cbSize        = sizeof(WNDCLASSEX);
        wc.style         = 0;
        wc.lpfnWndProc   = WndProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
         wc.hIcon  = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
    
    
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
     wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
    
    
        wc.lpszClassName = g_szClassName;
       wc.hIconSm  = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0);
    
    
    
    
        if(!RegisterClassEx(&wc))
        {
            MessageBox(NULL, "Window Registration Failed!", "Error!",
                MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
        // Step 2: Creating the Window
        hwnd = CreateWindowEx(
            WS_EX_CLIENTEDGE,
            g_szClassName,
            "The title of my window",
            WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
            NULL, NULL, hInstance, NULL);
    
        if(hwnd == NULL)
        {
            MessageBox(NULL, "Window Creation Failed!", "Error!",
                MB_ICONEXCLAMATION | MB_OK);
                
            return 0;
        }
    
        ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    
        // Step 3: The Message Loop
        while(GetMessage(&Msg, NULL, 0, 0) > 0)
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
        return Msg.wParam;
    }
    Code:
    #include "resource.h"
    
    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "E&xit", ID_FILE_EXIT
        END
    
        POPUP "&Stuff"
        BEGIN
            MENUITEM "&Go", ID_STUFF_GO
            MENUITEM "G&o somewhere else", 0, GRAYED
        END
    END
    
    //IDI_MYICON ICON "menu_one.ico"

    Code:
    #define IDR_MYMENU 101
    #define IDI_MYICON 201
    
    #define ID_FILE_EXIT 9001
    #define ID_STUFF_GO 9002
    hooch

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    That is not a .DLL application. Plus, you can not just "run" a DLL, it is a dynamic link library which you can load at run-time or link in with a project. This allows selective loading of different code instead of considering all possibilities of a situation in the main application, as well as providing a lot of nifty things (resource DLLs, etc.) Just make a new project with that code in it as a "Win32 Application Project" or something of the sort and Run it. Should work fine. Despite the code whoring up on the MessageBox's. Meh. Re-post any problems you experience because I could not bring my weathered eyes to read that crazy .........

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    lol i forgot i commented all that out cause this my first adventure into graphics lol

    well i ment the dll thing it saids its compiling everything linking it all and the last thing is some dll file then i click on run and it saids that host application error

    its like it saids it compiles and links fine but bombs when i hit run?

    and what is that parameters it is talking about i dont that either?
    hooch

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    It will compile fine. I don't think there is anything prohibited from compiling that as a DLL. But you are not reading what I am saying, as I am avoiding reading what you are saying as it is a foreign language that I am not all that fluent in. But again, I said in my post, that DLL's are not runnable applications. They contain executable code but do not simply run, and need a host file to load the code into it's process space and use it. But that is besides the scope of this thread.

    What you need to do!

    1) Create a new project was a "Win32 Application".
    2) Add the same files you psoted to the project
    3) Compile and run it if no errors occur.
    Conditional 4) Learn english and report back.

    Try reading what I said in my earlier post. I explained these things. You were pretty rude and ignorant in not attempting to understand the help I tried to give you.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    well i thought u ment something else with the dll things nor do i have any clue what your natural langauge is so if i was rude sorry i mis understood your dll part since i didnt think it had relevance here aka im just blantantly confused

    and wait i just tried making an empty project and it works fine....hmm oh well lol now to get the menu items to do stuff when i click on them but yes thanks anyway sorry didnt mean to be rude didnt think i was being rude
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resource files and GIF files
    By csonx_p in forum Windows Programming
    Replies: 7
    Last Post: 06-20-2008, 08:48 AM
  2. Graphics, Resource Files
    By DeanDemon in forum C++ Programming
    Replies: 3
    Last Post: 12-28-2002, 08:57 AM
  3. Resource Files
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 09-10-2001, 09:20 AM
  4. Problems with resource files
    By Unregistered in forum C++ Programming
    Replies: 18
    Last Post: 08-31-2001, 08:45 AM