?
Solved

Using color cursors !

Posted on 1998-10-21
3
Medium Priority
?
435 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 40 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

777 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