How to refer to rich edit control in another class - mfc

I have a simple MFC text editor and I am trying to implement a find function. I'm trying to refer to the control that stores all the text(I believe this is in the View class) from my 'Find Box' Dialog class. How do i access this rich edit control when it is in another class?

Change the constructor of the Find dialog to receive an additional parameter: a pointer to the rich edit control. Save the pointer in a Find dialog member variable. Then pass in the pointer value when you construct the Find dialog.

Related

How can I add a custom property to a class inherited from MFC's CEdit?

I'm working on a project which makes use of an inherited version of the CEdit class from MFC.
Up until now, we've been able to use a regular CEdit in the Dialog Editor because the functionality in the inherited class had no interaction with the visual dialog editor.
Now, we have a requirement to implement something like a 'linked list CEdit' which contains a field referencing the 'next' CEdit control, similar to the concept of tab-indexing each control.
It's obviously easy to add a field pointing to another control, but how do I cause this new field to appear in the list of properties in the visual dialog editor?
I've been reading about custom ActiveX controls in the book 'Programming Windows with MFC' but this approach seems quite involved, because we have an existing structure where the inherited control is not isolated in its own library project. It's just a regular CPP file inheriting from CEdit.
So - should I grind through the custom ActiveX control from Prosise, or is there a simpler way to see my custom properties in the visual designer?

Why does my edit control "add variable" popup box not have CString as an option

I'm very new to MFC and dialog boxes. I am attempting to follow a very simple YouTube tutorial: "VC++/C++ MFC tutorial 1: Creating a Dialog box for user input"
The video, and many other sources seem to have CString as a variable type for the edit control however I only have primitive types (see attached image).
Currently running VS2017
I have attempted to reconfigure some of project settings by creating a new project. however, I am just turning knobs blindly at this point.
Available Types on my version.
Shows the type (CString) that I was hoping to have.
When you right-click the actual class itself to add a variable it only shows a generic list of variable types. However, as you can see, you are not limited to the values in the drop-down list. You can also type in a value, like CString. This is the same in VS 2019:
When you right-click a control on a dialog, the IDE knows what type of variables it will usually map to. So if you right-click a EDIT control, and choose to map it to a value instead of a control, it defaults to CString.
This is documented on the Microsoft website:
If you're adding a member variable that isn't a dialog box control, select from the list of available types. For information about the types, see Fundamental Types.
If you're adding a member variable for a dialog box control, this box is filled with the type of object that is returned for a control or value. If you select Control, then Variable type specifies the base class of the control you select in the Control ID box. If the dialog box control can hold a value, and if you select Value, then Variable type specifies the appropriate type for the value that control can hold. For more information, see dialog box controls and variable types.

Is there a way to add my own button inside the edit common control?

Say, if I have a default EDIT common control in my MFC-based dialog window:
I'm looking for a way to add a small "X" (or delete) button inside of it (here's my Photoshop rendering of what I need):
Is there a way to do it by modifying the default edit control?
Please consider using new class CMFCEditBrowseCtrl. It does have method CMFCEditBrowseCtrl::EnableBrowseButton() to do exactly what you need.
If I wanted more than one button, I would investigate alternatives:
See the CMFCEditBrowseCtrl class' code. Then decide if derive a class from it and extend; or else derive from CEdit, copy CMFCEditBrowseCtrl code and extend.
Case the edit is multi-line, I would investigate the methods CEdit::SetRect and CEdit::SetRectNP. Case it is single-line I would look to CEdit::SetMargins. Then implement normal buttons over the text area of the edit.
Please refer this article for CMFCEditBrowseCtrl class..
https://www.codeproject.com/Articles/35722/MFC-Feature-Pack-CMFCEditBrowseCtrl

Embed custom control to CMFCPropertyGridCtrl Property Item

I want to embed two generic buttons like "Select" and "Cancel" to CMFCPropertyGridCtrl property line. Is there a painless way to do that?
Found a solution myself. You can use OnCreateEditor virtual method to send a custom control to a property. Note, that it will be shown on property edit. Another important note, that CMFCPropertyGridCtrl calls OnCreateEditor each time the user edits the property but before the control is destroyed it deletes the last received CWnd object itself. You should consider that. I have found no notes about that in MSDN CMFCPropertyGridProperty documentation (you know what to say).

How to implement Outlook Express alike address field control

I was thinking about inserting some object (button, panel or static text) into textctrl, like Outlook Express does this.
You can see from a pic "group1" is an object, you can double click on it, when you delete it, it gets deleted the whole text not just a part of it.
I made some research and this text field is just a simple RichEdit20W. I understand that I can do it by implementing some logic to a text field and so on, but it will not be proper way of doing it.
I wonder how they done that. Should I implement IRichEditOleCallback interface to achieve that? I will appreciate your answer very much.
Thanks!
The ability to insert an object is built-in to the RichEdit control, that's what Outlook is using, and you can do the same yourself. It seems you would need to implement your own OLE object for your own item, and then use the RichEdit's COM interface to insert it. You can see a sample on MSDN that gets the COM interface and inserts an object here.