How to add color picker in mfc? - visual-c++

i want be able to select any color i want, just like the attached pic.
yes i want to learn this c++ or mfc . I find it more powerfull . Could u explain to me exactly how to add it to my project. I also want the color iteslf and it code appers in picture box and textbox.
Thanks

Use CColorDialog class in mfc is used to pick the color from mfc
// Get the selected color from the CColorDialog.
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();
}
This sample will popup dialog to select the color and after selecting the color and click ok button then color variable will contain the selected color.
Use this color in your application.
EDIT
You can customize your combo box or list box to add the color pick tool.
Refer this link : CodeProjectSample

CMFCColorDialog is what you seem to be looking for. To make it act like a drop-down, you'll need to position it below the down-arrow button (e.g., using MoveWindow).

Since you don't seem to have the MFC Feature Pack, check the Ultimate Toolbox at http://www.codeproject.com/KB/MFC/UltimateToolbox.aspx. Its Graphical User Interface classes have a Color Picker.

For Visual Studio versions prior 2008, you can use BCGSoft's color pikcer (http://www.bcgsoft.com). MFC color dialog is based on this one.

I had a similar problem with CMFCColorButton. I added the graphic resource with the ToolBox on my dialog design, but I could't assign a control variable because it did not recognize CMFCColorButton.
The answer was to include afxcolorbutton.h in the header of stdafx.h. Maybe you can fix it in the same way.
I hope this helps

Related

Android Studio where is color picker for Flutter plugin

In Android Studio, we have color picker when developing in Java/Kotlin (natively) like this.
But while developing for Flutter, I can't see any options to pick my own color. Is there some plugin required to do that?
The color picker is not clickable in Android Studio running Flutter( Dart code), see picture below. But i found a work around using the Color class and manually opening color picker. Then pick a color and copy/paste it like this:
Here is how i do it:
1. Double tap shift to run search
2. Type Color or Picker
3. Open Color Picker from the search list
4. Copy/paste the HEX color code into your color class.
Expert tip:
Add color picker to a keyboard shortcut. You can find the settings for Keymap, under File > Settings > Keymap
You must have heard of the materials.io website from google, which provides many materials like designs, icons, tools, resources and components for easy developing. Now Color Tool is also available. You must add the website to your browsers shortcut if you are a developer. Here's the link for chosing color : https://www.material.io/resources/color/#!/?view.left=0&view.right=0&primary.color=E91E63
Another way I found is :
Type 'Colors.' and press control+space to see the available colors.
Select the color using arrow or mouse.
Press control+Q for the quick documentation.
And on the documentation windows, click on the edit button which opens the
'colors.dart' file.
Here all the colors with all shades are available. These shortcuts are for windows.
Once you open the file, you can always come back here to chose the next shade. But will not be the comfortable method like android project.
Hope a easier way to do this will come with the later update.

How to change color of TEdit when focused

It's probably easy question, bu I can't find an answer.
I want to change background color of TEdit component when I click on it (on Focus), and the background should back to previous color when I click somewhere else.
P.S. I use a Firemonkey and it's multiplatform app, so I need to use a style.
The easiest way (and best) - place TRectangle without Stroke into Tedit, set its Align to Client and change its Fill color in Object Inspector.
Hard way:
Tedit is using bitmap from styles. You can see your current style for Tedit - place StyleBook, Load your style from file, find 'editstyle' object.
You can create a new style for Tedit (copy 'editstyle' in your current style, and name it like editstyle1, select background > Source Link in Object Inspector - select part on global style bitmap with your color, then you can change to new style like Edit1.StyleLookup := 'editstyle1';
Also use a useful forum: http://fire-monkey.ru with Google Translate.

Ncurses: Dialog box background color be changed?

I am working on Linux Operating System. I want to display a dialog box on an item selection from a drop down menu implemented in ncurses, but the problem is that the dialog box fills up the screen with blue background and further nothing can be done.So, is there a way to display ncurses dialog box inside current window preserving existing ncurses components?
Thanks in advance.
You might use CDK (Curses development kit) to the create dialog box. It provides many other widgets that you can use such as,
Alphalist
Button
Buttonbox
Calendar
Entry Field
File Viewer
Floating Scale
Floating Slider
Graph
Histogram etc...
see this

How to skin MFC main menu

I got a menu in an existing MFC application that has a standard MFC main menu.
But I would like to change its background colour so that it appears to more seamlessly belong to the rest of the application.
First picture: An MFC main menu. The application is skinned blue, as seen in the toolbar, but the menu is still standard grey background colour.
Second Picture: Spotify's menu, skinned to fit into the rest of the
colors.
I have not found any examples on anything similar. Could you please point me towards how to achieve this?
Approaches I thought of:
Subclassing CMenu to my own SkinnedMenu, but it is not created by our code but by a GetMenu() call in a mainframe class deriving from CFrameWnd. The only thing I can find here is its method signature, defined in afxwin.h so then how could I make use my own subclassed menu?
Removing the entire menu and add my own custom menu buttons, in a row, making it look like a menu. Maybe this is what spotify have done, as they have also removed the Windows window frame.
Editing the existing CMenu in some way, but the only customization I am able to find right now is modifying its MENUINFO. For example if I set info.hbrBack = skin.GetSysColorBrush(COLOR_MENU) the only colour that changes is the background of the dropdown, not the main menu itself.
Other :)

Only 16 colors for CColorDialog?

Someone knows some way of putting only 16 colors in the CColorDialog of Visual Studio c++ when it is opened?
I don't think that's possible with the standard MFC CColorDialog.
But if you really only need 16 colors, wouldn't it make more sense to use something more simple like a combo box to pick a color, in stead of a full dialog?
Here's a Code Project article with an example implementation of a Color Picker Combo Box:

Resources