Thread: Cannot resolve overloaded function

  1. #1

    Cannot resolve overloaded function

    I'm getting the following error:

    Code:
    cannot resolve overloaded function `CtrlProc' based on conversion to type `long int'
    My problem is that, as far as I know my function CtrlProc isn't overloaded to my understanding of it.

    Code:
    class MCCBase{
        public:
        EnableSubClass(BOOL cmd,BOOL create,BOOL size,BOOL move,BOOL draw,BOOL paint);
        LRESULT CALLBACK CtrlProc(HWND,UINT,WPARAM,LPARAM);
    ...
    Code:
    void MCCBase::EnableSubClass(BOOL cmd,BOOL create,BOOL size,BOOL move,BOOL draw,BOOL paint)
    {
        if(cmd == TRUE)  SetWindowLong(ctrl,GWL_WNDPROC,CtrlProc);
    }
    I see no reason why it is happening.
    Last edited by Mithoric; 11-29-2003 at 01:55 AM.

  2. #2
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Could you give the piece of code where you are getting the error?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You posted the correct definiton of EnableSubClass, but forgot to post the possibly incorrect definition of CtrlProc
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Oops, I've edited the above to show the line where the error is occuring...

    Also I haven't actually defined CtrlProc beyond the prototype, could that be the problem?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Also I haven't actually defined CtrlProc beyond the prototype, could that be the problem?
    Yes, that's a problem
    Especially if you're already trying to call it from somewhere
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Ok well I defined it and still I get the same error.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I'm tired, and my ability to read your mind is a little off at the moment.
    Care to share what you actually wrote with the group?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    lol, sorry.
    It's probably easier if I post everything as it might be something else (although I don't see how) doing it..

    Controls.h
    Code:
    #include <windows.h>
    
    class MCCBase{
        public:
         MCCBase();
         ~MCCBase();
         void SetMetrics(int,int,int,int);
         void SetMetrics(LPRECT);
         void SetCaption(LPSTR);
         void GetMetrics(LPRECT);
         void SetParentWnd(HWND*);
         void EnableSubClass(BOOL,BOOL,BOOL,BOOL,BOOL,BOOL);
         void OnCreate(LPCREATESTRUCT);
         void OnSize(int,int);
         void OnMove(int,int);
         void OnPaint(HDC);
         void OnDraw(UINT,LPDRAWITEMSTRUCT);
         LRESULT CALLBACK CtrlProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
        private:
         int x,y,cx,cy,create,size,move,paint,draw;
         DWORD style,exStyle;
         char *className,label;
         HWND ctrl,parent;
    
    };
    Controls.cpp
    Code:
    #include "controls.h"
    
    MCCBase::MCCBase()
    {
      int x=0,y=0,cx=0,cy=0;
      DWORD style=0,exStyle=0;
      char *className="",*label="";
      HWND ctrl=NULL,parent=NULL;
    }
    
    MCCBase::~MCCBase()
    {
    
    }
    
    LRESULT CALLBACK MCCBase::CtrlProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
    {
        switch(message)
        {
        case WM_CREATE
        default:
         return DefWindowProc(hwnd,message,wParam,lParam);
        }
        return 0;
    }
    
    void MCCBase::EnableSubClass(BOOL cmd,BOOL create,BOOL size,BOOL move,BOOL draw,BOOL paint)
    {
        if(cmd == TRUE)
          SetWindowLong(ctrl,GWL_WNDPROC,CtrlProc);
    }

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Just a guess....


    SetWindowLong(ctrl,GWL_WNDPROC,MCCBase::CtrlProc);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Same error.
    Code:
    cannot resolve overloaded function `CtrlProc' based on conversion to type `long int'

  11. #11
    I don't think this is going to be a very flexible so it doesn't matter now..
    I'll find a better way.

    Thanks anyway!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM