Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using color cursors !

Posted on 1998-10-21
3
Medium Priority
?
439 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

604 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