The system palette dialog box can be divided into three parts: basic colors, custom colors, and extended.
In the create a palette dialog box, you only need to define a choosecolor variable, configure the members of this struct, and then call the choosecolor function with this variable as the parameter.
Choosecolor struct:
Typedef struct {<br/> DWORD lstructsize; <br/> hwnd hwndowner; <br/> hwnd hinstance; <br/> colorref rgbresult; <br/> colorref * lpcustcolors; <br/> DWORD flags; <br/> lparam lcustdata; <br/> lpcchookproc lpfnhook; <br/> lpctstr lptemplatename; <br/>} choosecolor, * lpchoosecolor;
The size of the lstructsize struct, usually initialized to sizeof (choosecolor ).
The handle of the window in the hwndowner create palette dialog box, which can be null.
A member of the result returned by rgbresult.
Lpcustcolors color buffer. The size is 16 colorref and the initial value of custom colors.
Flages is the most complex member. All attributes and features are determined by this member and can have a series of values or.
/*
Hinstance, lcustdata, lpfnhook, and lptemplatename can ignore these four parameters if you do not use a complex template.
*/
If the cc_rgbinit bit is set for flages, the initial value of rgbresult in the dialog box is the color. If the value of rgbresult is not in basic colors, the first one is selected by default.
If cc_fullopen is set for flages, the three regions are displayed. If cc_preventfullopen is set, the extended region is not displayed, and the define custom colors button is invalid.
This is the three long labels.
After the struct is configured, call the choosecolor function to bring up the palette dialog box. If you click OK, the function returns true and the selected result is stored in rgbresult; if the add to m colors button is used before clicking OK, the value in the lpcustcolors buffer will change.
If you want to maintain the last configuration of 16 colors in the Custom colors during the second pop-up dialog, you only need to properly keep the lpcustcolors buffer.