Thread: help me using lib from Visual C++ 6

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Former Member
    Join Date
    Oct 2001
    Posts
    955

    Unhappy help me using lib from Visual C++ 6

    I am starting myself in the use of microsoft's command-line lib...

    I made a simple lib which creates a window by using classes, it has an interesting member function: RegisterClass(try and guess what it does ).
    I want the user to use this function to register a single class, specifying the icon, if the hIcon is NULL, I want it to use the default icon, which is a resource.
    the part of the code is shown below:

    int cMyWindow::RegisterClass(LPCSTR ClassName,HICON hIcon)
    {
    WNDCLASSEX wc;
    int ret;
    this->cClassName = new(char[strlen(ClassName)+1]);
    strcpy(this->cClassName,ClassName);
    wc.cbClsExtra=0;
    wc.cbSize=sizeof(WNDCLASSEX);
    wc.cbWndExtra=0;
    wc.hbrBackground=(HBRUSH)(GetStockObject(BLACK_BRU SH));
    wc.hCursor=LoadCursor(NULL,IDC_ARROW);
    //THE INTERESTING STUFF STARTS HERE
    if(hIcon==NULL)
    {
    int id=IDI_ICON1;
    LPTSTR res=MAKEINTRESOURCE(id);
    wc.hIcon=LoadIcon(this->hInstance,res);
    ret=GetLastError();
    }
    else
    {
    wc.hIcon=hIcon;
    ret=GetLastError();
    }
    //THE INTERESTING STUFF ENDS HERE
    wc.hIconSm=NULL;
    wc.hInstance=this->hInstance;
    wc.lpfnWndProc=WndProc;
    wc.lpszClassName=ClassName;
    wc.lpszMenuName=NULL;
    wc.style=0;
    if(RegisterClassEx(&wc))
    {
    return 1;
    }
    else
    {
    throw cError("Class Registration failed\nError found in Line 160");
    return 0;
    }
    }

    the
    wc.hIcon=LoadIcon(this->hInstance,res);

    used to be
    wc.hIcon=LoadIcon(this->hInstance,MAKEINTRESOURCE(IDI_ICON1);

    but I split it up to see what happened!

    when i run it, it runs ok until the MAKEINTRESOURCE, it returns
    0x0000060, or something like that (i guess it works!)

    but the LoadIcon returns 0!

    when I call GetLastError, it returns 0 (Function success)

    I don't know what's going on here.

    the command line I use to create the lib is:
    lib /MACHINE:IX86 hello.obj hello.res

    so I don't think that the problem is that I am not linking the resource file!

    and, when I run the program which uses the lib, it works, but it doesn't show my icon, it shows the messy windows icon!

    Help me please
    Last edited by oskilian; 10-06-2001 at 02:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM