winapi - Add custom colors to TfontDialog in Delphi 7 -


how can add values color box in tfontdialog? or please tell me components can select font custom color? use delphi 7.

thanks.

i found way... how can show tcolordialog when color box changed on itemindex = 0?

 procedure tform1.fontdialog1show(sender: tobject); const  idcolorcmb = $473;  smycolorname: pchar = 'clmoneygreen';  cmycolor: tcolor = clmoneygreen; begin  senddlgitemmessage(fontdialog1.handle, idcolorcmb, cb_insertstring, 0,  integer(smycolorname));  senddlgitemmessage(fontdialog1.handle, idcolorcmb, cb_setitemdata, 0,    colortorgb(cmycolor)); end; 

i think works:

interface  tfontdialog = class(dialogs.tfontdialog) const   idcolorcmb = $473; protected   procedure wndproc(var message: tmessage); override;   procedure doshow; override; end;  ...  implementation  procedure tform1.formcreate(sender: tobject); begin   fontdialog1.execute(); end;  { tfontdialog }  procedure tfontdialog.doshow; const   smycolorname: pchar = 'custom...';   cmycolor: tcolor = $0033ccff; begin   senddlgitemmessage(handle, idcolorcmb, cb_insertstring, 0, integer(smycolorname));   senddlgitemmessage(handle, idcolorcmb, cb_setitemdata, 0, colortorgb(cmycolor)); end;  procedure tfontdialog.wndproc(var message: tmessage); begin   inherited;   message     if (msg = wm_command) , (wparamhi = cbn_selendok) , (wparamlo = idcolorcmb) , (senddlgitemmessage(handle, idcolorcmb, cb_getcursel, 0, 0) = 0)       tcolordialog.create(self)         try           color := tcolor(senddlgitemmessage(self.handle, idcolorcmb, cb_getitemdata, 0, 0));           options := [cdfullopen];           if execute(self.handle)             senddlgitemmessage(self.handle, idcolorcmb, cb_setitemdata, 0, colortorgb(color));                   free;         end; end; 

but notice, david correctly argues in comments below, code might fail if dialog box should change (significantly enough) in future version of windows. might or might not showstopper op.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -