PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

ChooseColor()

I have been trying to get a Colour Dialog to appear in the settings part of one of my apps, and for that I use

Code:

static void SetItemColour( COLORREF & aColour, HWND hWnd )
{
CHOOSECOLOR cc;
cc.lStructSize = sizeof( CHOOSECOLOR );
cc.hwndOwner = hWnd;
cc.hInstance = 0;
cc.rgbResult = aColour;
cc.lpCustColors = 0;
cc.Flags = CC_ANYCOLOR | C_FULLOPEN | CC_RGBINIT;
cc.lCustData = 0;
cc.lpfnHook = 0;
cc.lpTemplateName = 0;

if ( ChooseColor( &cc; ) )
{
aColour = cc.rgbResult;
}
}


Unfortunately, I keep on getting an "Unresolved Reference" to ChooseColor(), but I have included coredll.lib in my Project Settings, as the documentation says.

Am I missing something? This is the only bit missing before I release the app as a mini-freeware Today module, so it is quite frustrating!

Cheers!
AL
Hiya.

1. Surely it's in commdlg.lib not coredll.lib?

2. With a small bug-fix, (C_FULLOPEN to CC_FULLOPEN), it runs on my iPAQ and doesn't crash or anything... but... in the help:

The Color common dialog does not support user-defined colors if the target device screen is less than 480 pixels in width.


... so it doesn't actually do anything on mine. I haven't investigated the return value or error codes yet either - let me know if you'd like me to.

Cheers,

Refractor
Thanks for that Refractor! I meant "commctrl.lib", but obviously that one was also the wrong one :)

As for the typo, that was me on the copy&paste; to PM, rather than in my own code.

I got it working, but as you say, it is a bit useless because of the inability to have custom colours in it...

Thanks a bunch!
AL
Take a look at Code Guru. If you're using MFC then they have a ton of controls you can use, such as color choosers. You would have to "port" them to CE, which usually isn't too difficult.

Dan East