15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


subclassing CColorDialog

Serge Lalonde -- serge@infolytica.qc.ca
Monday, October 21, 1996

Environment: VC++ 4.2, Win NT 4.0

Hi there!

Has anyone ever tried using the CC_ENABLETEMPLATE flag when subclassing
from CColorDialog? I tried it with a simple dialog template (only one
button) and the call to DoModal() goes into la-la land and never returns
(and doesn't display the dialog either).

My dialog template was created with the following styles:
   Child, No border, Clip siblings on, 3d look on, Control on

These same styles work fine for a CFileDialog subclass that I have.
(By the way, thanks for the help with changing the OK button title.
SetControlText() did the trick).

Here is the stack trace that I get if I break in the debugger (this is
with the NT debugging symbols installed):

ZwUserWaitMessage@0 + 11 bytes
USER32! 77e89d7e()
InternalDialogBox@28 + 115 bytes
USER32! 77e9ade1()
ChooseColorX@4 + 250 bytes
ChooseColorA@4 + 253 bytes
AfxThunkChooseColor(tagCHOOSECOLORA * 0x0012f918) line 391 + 10 bytes
CColorDialog::DoModal() line 85 + 13 bytes
CDialogTestApp::OnPenDefaults() line 396
...

Here is the code in my constructor to set the template:

IPenDefaultDialog::IPenDefaultDialog
  (COLORREF clrInit, 
   DWORD    dwFlags,
   CWnd     *pParentWnd) 
   : CColorDialog(clrInit, dwFlags, pParentWnd)
{
   m_cc.Flags|= CC_ENABLETEMPLATE | CC_FULLOPEN;
   m_cc.lpTemplateName= MAKEINTRESOURCE(IDD_PEN_DEFAULT);

   return;
}

Removing CC_FULLOPEN from the flags makes no difference.

Is this a known bug? I can't find any references to it anywhere.
The online help makes references to this as if it should be possible
in the same way as its done with the CFileDialog.

Thanks in advance.
--
Have a tremendous day!
    _/_/_/_/ _/_/_/_/ _/_/_/    _/_/_/  _/_/_/_//  300 Leo Parizeau, Suite 2222
   _/       _/       _/    _/ _/       _/      /  Montreal, PQ, Canada H2W 2P4
  _/_/_/_/ _/_/_/   _/_/_/_/ _/  _/_/ _/_/_/  /  Voice: (514) 849-8752 x236
       _/ _/       _/  _/   _/    _/ _/      /__Fax: (514) 849-4239__
_/_/_/_/ _/_/_/_/ _/    _/   _/_/_/ _/_/_/_/ Lalonde, Infolytica Corp.



Dave_Rabbers@Quinton-Eng.CCMAIL.CompuServe.COM
Wednesday, October 23, 1996

[Mini-digest: 2 responses]

     I would suggest that instead of creating your own dialog template 
     from scratch, you modify the standard template which the common 
     color dialog uses.  The source for this is provided with VC++ as 
     file Color.dlg in MSDEV\INCLUDE (not MSDEV\MFC\INCLUDE).  
     Generally, if you remove any controls from this dialog, you can 
     expect failures within the common control library, since it expects 
     to find its controls (kind of like your code expecting to find your 
     controls!).  But you can move any unneeded controls totally off the 
     dialog, causing them to become invisible, although still present.
     
     I have done this successfully.  Under VC++ 4.2 and NT 4.0 as well 
     as other environments.
     
     Hope this gets you going.

-----From: Igor Nedelko 

You have to include the default color dialog template in your resource
(*.RC) file. The default template COLOR.DLG can be found in
MSDEV\INCLUDE directory. As soon as you include this dialog template you
can use CC_ENABLETEMPLATE style, because Windows is expecting all
existing controls. You can move the controls around or make them
invisible (or even add new ones), but they must exist !!! Don't forget
include DLGS.H and COLORDLG.H  in your *.RC file (they are located in
MSDEV\INCLUDE directory).





| Вернуться в корень Архива |