473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trying to create a custom CListBox control that uses a CRichEditCt

Today, we have an informational dialog where the information is displayed in
a RichText control. The only action for the user is to press the OK button
to dismiss the dialog.

My desire is to enhance this dialog by adding a “Go To” button where the
user would select one of the informational items in the list, press the “Go
To” button, the dialog would disappear, and then the “go to” action occurs.
I still need to display the information using RichText.

Following an example, I attempted to create a custom CListBox control where
the items in the listbox would be displayed using the CRichTextCtrl. The
custom CListBox control contains owner methods of DrawItem and MeasureItem.
The first draft for DrawItem is included. This code appears to work but is
far from perfect. It lacks code for item selection and in my sample code I
can get it to write outside of the boundary of the control. Furthermore, I
am not sure what needs to be done for MeasureItem method.

void CRichEditListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)

{

CDC* pDC = CDC::FromHandle (lpDrawItemStruct->hDC);

if (lpDrawItemStruct->itemID != -1)

{

COLORREF TextBkClr = SysColor (COLOR_WINDOW);

CString Text;

GetText (lpDrawItemStruct->itemID, Text);

CRect rect;

GetItemRect (lpDrawItemStruct->itemID, rect);

// Format the text and render it

UINT Left = ::MulDiv (rect.left, 1440, pDC->GetDeviceCaps
(LOGPIXELSX));

UINT Top = ::MulDiv (rect.top, 1440, pDC->GetDeviceCaps
(LOGPIXELSY));

UINT Right = ::MulDiv (rect.right, 1440, pDC->GetDeviceCaps
(LOGPIXELSX));

UINT Bottom = ::MulDiv (rect.bottom, 1440, pDC->GetDeviceCaps
(LOGPIXELSY));

CRect Rect (Left, Top, Right, Bottom);

FORMATRANGE fr;

fr.hdc = pDC->m_hDC;

fr.hdcTarget = pDC->m_hDC;

fr.rc = Rect;

fr.rcPage = Rect;

fr.chrg.cpMin = 0;

fr.chrg.cpMax = -1;

UINT StreamType;

if (Text.Left (6) == "{\\rtf1")

StreamType = SF_RTF;

else

StreamType = SF_TEXT;

EDITSTREAM es =

{

(DWORD)&Text, 0, EditStreamCallBack

};

m_pRichEditTemp->SetSel (0,-1);

m_pRichEditTemp->SetBackgroundColor (FALSE, TextBkClr);

m_pRichEditTemp->Clear ();

m_pRichEditTemp->StreamIn (StreamType, es);

m_pRichEditTemp->FormatRange (&fr, TRUE);

// Update the display with the new formatting

CRect rcClient;

m_pRichEditTemp->GetClientRect (&rcClient);

m_pRichEditTemp->DisplayBand (&rcClient);

}

}

I have examined the internet and information is scarce. My hope is that
some one can point me in the correct direction or can suggest another
approach.

Thank you for your support.

Nov 17 '05 #1
1 1438

"Pat Moline" <Pa*******@discussions.microsoft.com> wrote in message
news:F1**********************************@microsof t.com...
Today, we have an informational dialog where the information is displayed
in
a RichText control. The only action for the user is to press the OK
button
to dismiss the dialog.

My desire is to enhance this dialog by adding a "Go To" button where the
user would select one of the informational items in the list, press the
"Go
To" button, the dialog would disappear, and then the "go to" action
occurs.
I still need to display the information using RichText.


Later versions of the RichEdit control support embedding hyperlinks, like an
HTML page. Perhaps this suits your need better than adding a "Go To"
button.

-- David
http://www.dcsoft.com
Dec 3 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brent Baker | last post by:
Is there a way to change a CListBox from single selection to multiple selection, or back again, from inside the program after the CListBox has been created? Our application has several...
11
by: zden Irmak | last post by:
Hello, In my VB.Net application I create a new instance of my form like : NewForm = new MyNewForm() But with this line, this new form is automatically shown. I want it to be hidden at the...
4
by: jmarc | last post by:
Doesn't seems to work! Filling a CListBox with over 75,000 strings in it, took more than 5 minutes ! I tried using InitStorage( nbitems, length_item ) before filling the listbox, and it doesn't...
2
by: J R M | last post by:
I've developed a custom control (it's basically a drop-down list and then a couple of textboxes to include meta-data for the selection) that I'm embedding into another custom control (the idea is...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
4
by: Smokey Grindle | last post by:
What is the best way to write dynamic controls in ASP.NET 2.0?
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
2
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello, I have an existing (WPF) Class Library project that I'd like to add a WPF Custom Control to. However, when I try to Add New Item, that isn't one of the available options. Perhaps this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.