CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    76

    making a custom cursor in an MDI app

    Hi guys,

    Okay, i have another question. in my MDI app i would like to have a custom cursor when the mouse is over a view window.

    I have made the appropriate .cur file with the cursor's bitmap,
    and have an IDC_CURSOR1.

    I was hoping to tell Windows to switch cursors when it received
    the ON_WM_SETCURSOR() message.

    i tried first putting this in the view object, then in the child frame object.

    both times, it gave me this kind of error:

    ChildFrm.cpp(18) : error C2440: 'static_cast' : cannot convert from 'bool (__thiscall CChildFrame::* )(CWnd *,UINT,UINT)' to 'BOOL (__thiscall CWnd::* )(CWnd *,UINT,UINT)'

    and pointed to ON_WM_SETCURSOR(). It seems that ON_WM_SETCURSOR should be in a CWnd object. But isn't CChildFrame derived from CWnd?

    how can i use ON_WM_SETCURSOR() in my app? where should i catch this message so that i can switch to my custom cursor?

    i am trying to follow the example of Prosise's MFC book p. 140:

    Code:
    ON_WM_SETCURSOR()
    .
    .
    .
    
    BOOL CMainWindow::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) {
         if (nHitTest == HTCLIENT) {
               ::SetCursor(my_cursor);
               return TRUE;
         }
        
         return CFrameWnd::OnSetCursor(pWnd, nHitTest, message);
    }
    thanx!

  2. #2
    Join Date
    Oct 2003
    Posts
    76
    along the same lines, i also have a piece of code that i want to run when the view window has come up. In particular i want to run GetClientRect() to find out its size. if i run this in the CDocView constructor, i get an error. i guess it's because the window is not yet constructed.

    so i wanted to put it in a function that is called the moment it is created. I tried adding a ON_WM_CREATE message to my CDocView class but i got a similar error message:

    : 'static_cast' : cannot convert from 'void (__thiscall CSilmapEditView::* )(LPCREATESTRUCT)' to 'int (__thiscall CWnd::* )(LPCREATESTRUCT)'

    where can i put the ON_WM_CREATE() message map?

    why can't i do it in the view object.

    sorry about all the questions, guys, i guess i'm just a little consfused by the multiple document architecture.

    thanx

  3. #3
    Join Date
    Sep 1999
    Location
    Colorado, USA
    Posts
    1,002
    Look at both error messages. The compiler is telling you that the funciton signatures are different.

    In the first error message (Set Cursor)0.
    0, it is BOOL and bool as the return type - two different data types. BOOL is not bool.

    In the second message, it is void and int - again, 2 different return types.

    For your second problem with getting the client rect, override OnInitialUpdate()

    For the first problem, you should catch the WM_SETCURSOR message in the view. Just straighten out the error in the fxn signatures.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured