Solved

Using color cursors !

Posted on 1998-10-21
3
428 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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

691 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