473,652 Members | 3,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CRichEditListBo x::DrawItem(LPD RAWITEMSTRUCT lpDrawItemStruc t)

{

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

if (lpDrawItemStru ct->itemID != -1)

{

COLORREF TextBkClr = SysColor (COLOR_WINDOW);

CString Text;

GetText (lpDrawItemStru ct->itemID, Text);

CRect rect;

GetItemRect (lpDrawItemStru ct->itemID, rect);

// Format the text and render it

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

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

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

UINT Bottom = ::MulDiv (rect.bottom, 1440, pDC->GetDeviceCap s
(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, EditStreamCallB ack

};

m_pRichEditTemp->SetSel (0,-1);

m_pRichEditTemp->SetBackgroundC olor (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->GetClientRec t (&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 1447

"Pat Moline" <Pa*******@disc ussions.microso ft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.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
1574
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 ListBoxes. I know its easy to use the properties dialog control it set the control to be single, or multiple, selection up front. But I'd like a way to set this property from inside the program, dynamically.
11
2190
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 start... Adding a line after this line like :
4
1706
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 seem to change anything. Always very long before having the list displayed. InitStorage is supposed to be used to allocate CListBox memory before using AddStgring() and InsertString() functions... Does anyone have succesfully used this...
2
1866
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 to allow a dynamic number of control1 to appear in control2). Everything renders correctly, however I could never retrieve data on postback from my embedded controls. Upon closer inspection, all of the embedded controls output without any "name"...
2
2520
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 is the usage of "Custom Attribute" in real life project. Can somebody please help me understand where are these informations really helpful in Development Environment; may be a few example(s) will help me understand.
4
1766
by: Smokey Grindle | last post by:
What is the best way to write dynamic controls in ASP.NET 2.0?
11
18111
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 ListView columns so it should be doable, thanks
7
10909
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: <Expander Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:CustomResources}, ResourceId=CustomExpanderStyle1}}" >
2
5218
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 is a brain freeze, but what could I possibly be missing? WtS
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.