Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

3-D controls with MFC

85 views
Skip to first unread message

Andreas Hjelming

unread,
May 17, 1995, 3:00:00 AM5/17/95
to
Here's a symantec document on how to utilize 3-D controls with MFC.

Sincerely,

Andreas Hjelming
Symantec C++ Development

===========================================================

Using CTL3D with the Microsoft Foundation Class Library

Using CTL3D in a Microsoft Foundation Class Library (C/C++ version 7.0 or Visual
C++ version 1.0) application requires additional steps. To add 3-D controls to a
Foundation class dialog box, you must:

1. Call Ctl3dRegister and Ctl3dAutoSubclass in the application's
CWinApp::InitInstance function:
Ctl3dRegister(AfxGetInstanceHandle());
Ctl3dAutoSubclass(AfxGetInstanceHandle());

You can also remove, or comment out, the call to SetDialogBkColor from the
InitInstance function. CTL3D and SetDialogBkColor can coexist, but they
perform similar functions (so it's overkill to have both).

2. Add an OnSysColorChange member to the application's main frame window, and
add ON_WM_SYSCOLORCHANGE to its message map. Call Ctl3dColorChange
from OnSysColorChange:


void CMainWindow::OnSysColorChange()
{
Ctl3dColorChange();
}

3. Add ExitInstance to the application's CWinApp class, and call Ctl3dUnregister

from this function:


int CTheApp::ExitInstance()
{
Ctl3dUnregister(AfxGetInstanceHandle());
return CWinApp::ExitInstance();
}

4. Link the application with appropriate CTL3D library.
There are different ways to link CTL3D. Read the section on Installing
CTL3D with your application below for a discussion on which CTL3D library
you should use.

We suggest using the automatic subclassing of CTL3D with the Foundation classes.
It simplifies the effort required to add 3-D effects to an application, and it
is easily removed when the application is updated to versions of Windows that
no longer benefit from CTL3D.

If automatic subclassing does not suit your application, our second suggestion
is to use the Ctl3dSubclassDlgEx function for each dialog box to which you want
to add 3-D effects. Do steps 1 thorugh 4 above, but leave out the call to
Ctl3dAutoSubclass. Then in the application's OnInitDialog function for the
dialog class, call Ctl3dSubclassDlgEx:

BOOL CAboutBox::OnInitDialog()
{
Ctl3dSubclassDlgEx(m_hWnd, CTL3D_ALL);
return TRUE;
}

If you are using automatic subclassing and a FormView class from the Foundation
classes, and you want to add 3-D effects for the form, you must call Ctl3dSubclassDlg
from the class's OnInitialUpdate function:

VOID CCheckView::OnInitialUpdate()
{
Ctl3dSubclassDlg(m_hWnd, CTL3D_ALL);
return TRUE;
}

Applications that are not using automatic subclassing and want a FormView to
have 3-D effects should call Ctl3dSubclassDlgEx from the OnInitialUpdate
function:

VOID CCheckView::OnInitialUpdate()
{
Ctl3dSubclassDlgEx(m_hWnd, CTL3D_ALL);
return TRUE;
}


Do not use CTL3D.DLL with the DLL version of the Foundation Class Library.
There is a possible conflict between these DLLs that does not occur with the
statically linked Foundation Class Library. If you must use a DLL version of MFC
then you must statically link in the DLL static link version of CTL3D, see
"Installing CTL3D with Your Application" below, with the MFC DLL.

===
Using CTL3D from C

To use CTL3D, follow the steps listed below.

1. Include CTL3D.H in each source file that contains a dialog procedure or
WinMain, or that uses a standard control.

2. Link the application with appropriate CTL3D library. There are different ways
to link CTL3D. Read the section on Installing CTL3D with your
application below for a discussion on which CTL3D library you should use.
3. Add a call to the Ctl3dRegister function when the application initializes.
WinMain is usually a good place to add this function call.

4. Add a call to Ctl3dColorChange in your application's WM_SYSCOLORCHANGE
message handler. WinMain is the best place to add this function call.
5. Add a call to Ctl3dUnregister at application destroy time. Add this call at
WM_DESTROY time if you subclass only dialog-box controls. If you subclass
controls in your main window, you may want to call Ctl3dUnregister just before
returning from WinMain.
6. Subclass the controls. You can do this in three ways:

A) Use automatic subclassing.

If your application runs under Windows version 3.1 or later,
it can use the automatic subclassing feature of CTL3D. To use
this feature, call Ctl3dAutoSubclass after Ctl3dRegister.
This automatically subclasses all controls in all dialog boxes,
including message boxes and the Windows common dialog boxes.
Earlier versions of CTL3D required hook procedures for some of
the common dialog boxes. This is no longer required. Automatic
subclassing sets a task-specific WH_CBT hook to locate dialog
boxes for the application. If your application sets a WH_CBT
hook, it should do so before calling Ctl3dAutoSubclass.
Your application's CBT hook procedure should also call
CallNextHookEx to ensure that CTL3D's CBT hook procedure
is called whenever the application's CBT hook is called.

B) Subclass each dialog box.

If your application runs under Windows version 3.0, or if you want to
change only specific dialog boxes to 3-D, add a call to Ctl3dSubclassDlg
or Ctl3dSubclassDlgEx in the WM_INITDIALOG message handler for each dialog
box. You must do this before your application subclasses any controls
itself:

case WM_INITDIALOG:
Ctl3dSubclassDlg(hdlg, CTL3D_ALL);
break;

or:

case WM_INITDIALOG:
Ctl3dSubclassDlgEx(hdlg, CTL3D_ALL);
break;

If your application uses Ctl3dSubclassDlg, the following steps are
required. If your application uses Ctl3dSubclassDlgEx, these steps are
not required. The application must also call the Ctl3dCtlColorEx function
in the WM_CTLCOLOR message handler for each dialog box, for example, by
using the following code:

case WM_CTLCOLOR:
return Ctl3dCtlColorEx(wm, wParam, lParam);

For applications running on Windows NT, the application must call
Ctl3dCtlColorEx for the WM_CTLCOLORBTN, WM_CTLCOLORDLG,
WM_CTLCOLOREDIT, WM_CTLCOLORLISTBOX, WM_CTLCOLORMSGBOX,
WM_CTLCOLORSCROLLBAR, and WM_CTLCOLORSTATIC messages. For
example:

case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLORSCROLLBAR:
case WM_CTLCOLORSTATIC:
return Ctl3dCtlColorEx(wm, wParam, lParam);

If you want CTL3D to draw a 3-D border for the
dialog box, add the following call to Ctl3dDlgFramePaint in the
WM_SETTEXT, WM_NCPAINT, and WM_NCACTIVATE message handlers for the
dialog
box (the dialog box must have the WS_DLGFRAME and DS_MODALFRAME styles):

case WM_SETTEXT
case WM_NCPAINT:
case WM_NCACTIVATE:
SetWindowLong(hdlg, DWL_MSGRESULT,
Ctl3dDlgFramePaint(hdlg, wm, wParam,Param);
return TRUE;

C) Subclass any control that does not appear in a dialog box.

If your application uses controls outside of dialog boxes, it must use
Ctl3dSubclassCtl to subclass these controls individually. When an
application calls Ctl3dCtlColorEx from a window procedure instead of a
dialog procedure, it should use the following code:


#ifdef WIN32
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLORSCROLLBAR:
case WM_CTLCOLORSTATIC:
#else
case WM_CTLCOLOR:
#endif
hbrush = Ctl3dCtlColorEx(wm, wParam, lParam)
if (hbrush != (HBRUSH) fFalse)
return hbrush;
else
return DefWindowProc(hwnd, wm, wParam, lParam);

Considerations

Ctl3dAutoSubClass only subclasses windows that have the standard
WC_DIALOG dialog window class. CTL3D adds 3-D effects only to the
following controls:

Standard Windows controls (list box, edit control, static control, button,
combo box). Controls that are not superclassed. Non-dialog box
controls (edit controls and list boxes) whose parents do not have
the WS_CLIPCHILDREN style.

CTL3D does not subclass buttons that have the BS_OWNERDRAW or
BS_LEFTTEXT style. CTL3D does not subclass static controls that have the
SS_ICON, SS_LEFT, SS_CENTER, SS_LEFTNOWORDWRAP, SS_SIMPLE style.
CTL3D creates 3-D effects for list boxes and edit controls outside the
control's client area. For this reason, the controls appear larger than
specified in the dialog definition or CreateWindow for the control. The
application designer may need to tweak the size of controls to account for this
increase.

CTL3D handles static frame controls differently than Windows does.
In fact, CTL3D implements its own static rectangles and frames:

Static controls with the SS_BLACKRECT or SS_BLACKFRAME style are
drawn as inset 3-D rectangles. Static controls with the SS_GRAYRECT or
SS_GRAYFRAME style are drawn as bas-relief 3-D rectangles.
Static controls with the SS_WHITERECT or SS_WHITEFRAME style are drawn
as outset 3-D rectangles.

To stop CTL3D from using its own static controls, do not pass the
CTL3D_STATICFRAMES flag to the Ctl3dSubclassDlg function. (See the "Function
Reference" section later in this article for a description of Ctl3dSubclassDlg.)

If static controls are not disabled (grayed), you need not pass CTL_3DSTATICTEXTS
to the Ctl3dSubclassDlg or Ctl3dSubclassDlgEx function.
For future compatibility, an application should not rely on subtle changes in the
way CTL3D draws controls.
CTL3D draws a 3-D border for dialogs that have the WS_DLGFRAME and
DS_MODALFRAME styles. To disable this feature, see the WM_DLGBORDER
message in the "Messages" section later in this article.

When using automatic subclassing, CTL3D sends a WM_CTLCOLOR message to
the application's dialog boxes. The application can respond to the message and
return a handle to a brush, or it can return FALSE and have CTL3D respond to the
message. Dialog procedures usually return FALSE when they do not handle a
particular message, so additional programming is necessary only if the application
wants to handle WM_CTLCOLOR messages for a particular dialog box.

John Grant

unread,
May 17, 1995, 3:00:00 AM5/17/95
to
In article <3pctjv$n...@mars.efn.org> Ahje...@symantec.com (Andreas Hjelming) writes:
>Here's a symantec document on how to utilize 3-D controls with MFC.
>
>Sincerely,
>
>Andreas Hjelming
>Symantec C++ Development
[...300 lines of stuff deleted...]

I think a pointer to the document could have been just as useful,
particularly since the same document was just posted yesterday.
Also, what makes it any different than the docs available from
ftp.microsoft.com?

Is it just me, or has anyone else noticed the sudden 'presence'
of technical evangelists from Symantec in many groups, including
the Windows groups and the comp.lang groups. I can just visualize
the corporate memo now...

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Memo
From: Symantec Marketing
To: all employees

We have decided to try a new tactic to boost the market for
Symantec products. All Symantec personnel are now going to
be required to start reading the newsgroups. If you find any
question or discussion which is in any way related to Windows
programming, particularly a discussion of compilers, then
you will attempt to answer that question or get involved in the
discussion, referrring as often as possible to Symantec products
whether it is relevant or not. Even if it isn't a question about
compiler capabilities, try to say something like
'hey our compiler can do that too'

It is hoped that this hammerhead approach will raise our corporate
profile, by burning the word 'Symantec' in the minds of all of
the developers.

So get out there and evangelize! Good luck to you all."
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Hey, no offence, Symantec. I'm sure your products are just as good
and/or bad as the others. I'm just cynical about the marketing method.
--
John A. Grant jag...@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa

Derek Kowald

unread,
May 19, 1995, 3:00:00 AM5/19/95
to
>>Here's a symantec document on how to utilize 3-D controls with MFC.
>>
>>Sincerely,
>>
>>Andreas Hjelming
>>Symantec C++ Development
> [...300 lines of stuff deleted...]

> Is it just me, or has anyone else noticed the sudden 'presence'
> of technical evangelists from Symantec in many groups, including
> the Windows groups and the comp.lang groups. I can just visualize
> the corporate memo now...

[snip]
I think your absolutly right. I follow quite a few programming
related newsgroups. And I'm seeing a lot of responces from Symantic.
For what its worth, heres my two cents:
I LOVE IT.
If Symanntic are willing to help by reading the news groups and offering
support, fine. And being a comercial company you've got to expect the plug at
the bottom of the post.
Personally I'd like to know if this is a new policy for Symantic. If they are
going to continue to 'help out' in the news groups I'll be swaping to there
compiler in the future.
Later,
DGK.

Directeurschaphetdirecteurshappen Schappen

unread,
Aug 31, 2023, 11:17:33 PM8/31/23
to
Pe vineri, 19 mai 1995, la 14:00:00 UTC+7, Derek Kowald a scris:
> >>Here's a symantec document on how to utilize 3-D controls with MFC.
> >>
> >>Sincerely,
> >>
> >>Andreas Hjelming
> >>Symantec C++ Development

Directeurschaphetdirecteurshappen Schappen

unread,
Aug 31, 2023, 11:18:03 PM8/31/23
to
Pe vineri, 19 mai 1995, la 14:00:00 UTC+7, Derek Kowald a scris:
> >>Here's a symantec document on how to utilize 3-D controls with MFC.
> >>
> >>Sincerely,
> >>
> >>Andreas Hjelming
> >>Symantec C++ Development
0 new messages