A Line Picker


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

The following application uses source code from Icon Picker Combo Box by Joel Wahlberg and A Color Picker by Luis Ortega.

The LinePickerDlg class implements a dialog designed to allow the selection of Style, Width, and Color attributes for a CPen object:

Environment: VC6

To use this Line Picker dialog, follow these steps:

How to Include Line Picker in Your Project

  • Include the following files in your project:
    • LinePickerDlg.cpp
    • LinePickerDlg.h
    • Colorbtn.cpp
    • Colorbtn.h
    • Linecbbox.cpp
    • Linecbbox.h
  • Copy "Other.rc" into your "res" directory.
  • Add this line to your rc2 file: #include "Other.rc". Make sure to place a Carriage Return after this line, to avoid the "fatal error RC1004: unexpected end of file found" message.
  • Include the line #include "LinePickerDlg.h" in your C++ file.
  • Include the line #define IDD_LINEPICKERDLG (5110) in your class header file or in your "Resource.h" file.

How to Use Line Picker

Use the following code to modify the line attributes:

// Create Dialog
CLinePickerDlg *pdlg;
pdlg = new CLinePickerDlg();

// Initialize
// (make sure member variables themselves have been previously
//  initialized)

// Run modal loop
if(IDOK == pdlg->RunModalLoop(MLF_SHOWONIDLE)){
  // Retrieve new line attributes...
  m_crColor = pdlg->GetColor();
  m_nStyle  = pdlg->GetStyle();
  m_nWidth  = pdlg->GetWidth();
  // ...and redraw Dialog

// Clean up!
delete pdlg;

To draw thick dotted lines—for instance, from within your OnPaint() method—you will need to use the second version of the CPen constructor:

lb.lbStyle = BS_SOLID;
lb.lbColor = m_crColor;
CPen CurPen(PS_GEOMETRIC | m_nStyle, m_nWidth, &lb);
CPen *pOldPen = dc.SelectObject(&CurPen);


Download demo project - 46 Kb
Download source - 12 Kb

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date