Solved

Using color cursors !

Posted on 1998-10-21
3
415 Views
Last Modified: 2013-12-03
How can I use colored cursors in my MFC application ?
I have try this but no cursor are loaded :

IDC_MYCOLORCURSOR is a 16 color cursor defined in the
resource.

BOOL CMyDialog::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message)
 {
  HCURSOR hCursor = LoadCursor(IDC_MYCOLORCURSOR);
  if (hCursor) // hCursor is always NULL. Why ?
   {
    ::SetCursor(hCursor);
    return TRUE;
   }

  return CDialog::OnSetCursor(pWnd,nHitTest,message);
 }

I have also try this :

static HANDLE g_hCursor;

BOOL CMyDialog::OnInitDialog()
 {
  ......
  g_hCursor = LoadImage(AfxGetInstanceHandle(), "IDC_MYCOLORCURSOR", IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
   // g_hCursor is always NULL (Also when the cursor is monochrome). Why ?
  ......
 }

BOOL MyDialog::DestroyWindow()
 {
  if (g_hCursor) DestroyCursor((HCURSOR)g_hCursor);
  ....
 }

BOOL CMyDialog::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message)
 {
  HCURSOR hCursor = (HCURSOR)g_hCursor;
  if (hCursor)
   {
    ::SetCursor(hCursor);
    return TRUE;
   }

  return CDialog::OnSetCursor(pWnd,nHitTest,message);
 }
0
Comment
Question by:mike_marquet
3 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 20 total points
ID: 1415521
Here's an OnSetCursor from my app, it works quite well:

BOOL CGBarTime::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    switch(m_mouseRegion) {
    case DISP_CURRENT:
        SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE));
        return TRUE;

    case NONE:
        if( m_pInstInfo && m_pRuler && (m_editRegion == NONE) &&
            m_pInstInfo->CommandGet() == CInstInfo::CMD_STOP) {
            SetCursor(AfxGetApp()->LoadCursor(IDC_ZOOM));
        }
        return TRUE;
    }

      return CWnd::OnSetCursor(pWnd, nHitTest, message);
}

0
 

Author Comment

by:mike_marquet
ID: 1415522
I have already test this and it doesn't work !
When I create a color cursor whith the workshop (for example, an 16 colors cursor) and I load this cursor with your method, the cursor never appears.
I must also tell that whith the workshop, when I use for example the red color and then an other color, all colors became black.

How must I proceed to create a color cursor with the workshop of visual C++ 5.0 ?
0
 

Expert Comment

by:masaki031599
ID: 1415523
Create 256 color icon resource with VC.


HCURSOR cursor = (HCURSOR)( AfxGetApp()->LoadIcon(IDI_ICON256) );

SetCursor( cursor );


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now