Control for drawing a bevelline
Posted
by Hans Buehler
on April 6th, 1999
This is one of my first extensions to the MFC ... since I just have been
asked to publish it, here is what I expected to come from Microsoft:
A static control that displays a bevel line (i.e. a 3d-shaded-Line).
How to put a bevelline in my dialog:
- In the dialog resource editor, put a CStatic (Text) in the position of the
bevelline. Give the control an ID other than IDC_STATIC.
I recommend to give it a minimal height if you want a horzontal line, a minimal width if you want a vertical line (see further notes below). - Using ClassWizard, add a member variable (type control) for the control (i.e. m_wndBevel).
- Open the dialog's implementation file, #include the header file "cdxCBevelLine.h" and replace the word "CStatic" of your newly created control by "cdxCBevelLine".
- Don't forget to add both cdxCBevelLine.h and cdxCBevelLine.cpp to your project's file list.
Further notes:
- Using the constructor, you can alternatively change the public
member m_bSunken to false which indicates that the bevelline should
appear high, not lowered.
During run-time, you can manually set m_bSunken and call CWnd::Invalidate() and CWnd::UpdateWindow(). - The control will determine its orientation from the size of the area it occupies; i.e. if the window's height is bigger than its width, the bevelline will be drawn vertically, otherwise horizontally.
Future plannings:
- Add the possibility to add a text to a horizontal line :)
Source code follows....
cdxCBevelLine.h:
#if !defined(AFX_CDXCBEVELLINE_H__0609E262_670A_11D1_A589_444553540000__INCLUDED_)
#define AFX_CDXCBEVELLINE_H__0609E262_670A_11D1_A589_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// cdxCBevelLine.h : header file
/*
* cdxCBevelLine
* =============
* Display a bevelline.
*
* To put a bevelline into your dialog, create a static control that acts as a placeholder,
* create a member variable of type control ("CStatic") for it, open the dialog's
* include file, include this file and replace the "CStatic" by a "cdxCBevelLine".
*
* (w)1997 Hans B|hler, hans.buehler@student.hu-berlin.de
* freeware.
*/
class cdxCBevelLine : public CStatic
{
public:
enum
{
LineWid = 1,
LineHi = 1
};
// Construction
public:
cdxCBevelLine(bool bSunken = true) : m_bSunken(bSunken) {}
virtual ~cdxCBevelLine() {}
BOOL Create(const RECT& rect, CWnd* pParentWnd)
{ return CStatic::Create(NULL,WS_CHILD|WS_VISIBLE,rect,pParentWnd); }
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(cdxCBevelLine)
//}}AFX_VIRTUAL
// Implementation
public:
bool m_bSunken; // call Invalidate() and UpdateWindow() to redraw control
// Generated message map functions
protected:
//{{AFX_MSG(cdxCBevelLine)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CDXCBEVELLINE_H__0609E262_670A_11D1_A589_444553540000__INCLUDED_)
cdxCBevelLine.cpp:
// cdxCBevelLine.cpp : implementation file
#include "stdafx.h"
#include "cdxCBevelLine.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// cdxCBevelLine
BEGIN_MESSAGE_MAP(cdxCBevelLine, CStatic)
//{{AFX_MSG_MAP(cdxCBevelLine)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// cdxCBevelLine message handlers
void cdxCBevelLine::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect r;
GetClientRect(&r);
DWORD hiCol = ::GetSysColor(!m_bSunken ? COLOR_3DHIGHLIGHT : COLOR_3DSHADOW);
DWORD loCol = ::GetSysColor(m_bSunken ? COLOR_3DHIGHLIGHT : COLOR_3DSHADOW);
if(r.bottom > r.right)
{
// vertical
r.right /= 2;
r.left = r.right - LineWid;
r.right += LineWid;
}
else
{
// horizonzal
r.bottom /= 2;
r.top = r.bottom - LineHi;
r.bottom += LineHi;
}
dc.Draw3dRect(&r,hiCol,loCol);
}

Comments
Jordan shoes mentioned Gene to pay off the discredit, a division of Nike
Posted by TaddyGaffic on 04/20/2013 10:29amThe sole of shoes are made from high quality rubber material and come with the lining. One can easily search for Vans footwear in the various online stores where they are easily available at great discount prices. These come in almost an infinite amount of [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] color and are usually on the cheap side. Experts as well as the rights of employees in regards to the apple can annihilate the Nike Air Max For travel arrangements in developing abjection can be a acceptable accord added in comparison to they're prevention, nonetheless they do accommodate sports sports athletes while using high duke inside their profession. Bargain Nike Air Max 2009 aswell provides countless jobs inside the nations absolutely area it's hardly accessible to acquire a job. In Indonesia, for archetype nike air max 90, even acknowledging baby assets [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] in barter for plan Air Max, however, Nike bargain shoes inside a aught bulk adaptation and utilisation of the circadian needs.. Nike Zoom Vapor VI Tour Men`s tennis shoe is a great shoe popular in the tennis courts. It has Fly wire upper for ultra support and light weight ability, it sits on a frame that gives extra heel support and contains a full-length durable rubber support and herring bone pattern. It also has extra traction for all surfaces of play.. Write a Shakespeare Sonnet without any effort! Express loving [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] feelings in a sonnet in Shakespeare's own words in 15 minutes. The rhyme scheme of a Sonnet is a,b,a,b,c,d,c,d,e,f,e,f,g,g. Think of a theme like "love" "death" or "deceit", then choose your lines in the rhyme pattern and put a Sonnet together using the programme
ReplyNo code needed!!!
Posted by Legacy on 10/16/2000 12:00amOriginally posted by: Stefan Amourette
Hello,
just put a picture control as one line at your dialog-recource and turn on two items at "extented format". client-edge and static-edge! That's all.
I use this nearly inside every project without any code added!
Greetings
Stefan
http://www.amourette.de
ReplyBeveled CStatics
Posted by Legacy on 11/04/1998 12:00amOriginally posted by: David Little
You can do this with the resource edit by adding a picture control (the one with the cactus on the button) and give it either no heighth (horizontal) or width (vertical).
ReplyEtched control.
Posted by Legacy on 10/28/1998 12:00amOriginally posted by: Cole
You can do this by using the picture control and having the type as etched. If you have the control with no width/height you get the same effect.
Reply