Husam Chekfa
Husam Chekfa

Reputation: 77

CMFCEditBrowseCtrl - which control to use in the .rc file ? - MFC C++

I am working on an MFC project with part of it requesting the user to choose a folder destination.

Right now, I have it implemented using a non-editable CEdit box whose value is set by the path chosen by the user, who chooses it by clicking a CButton button which calls the CFolderPickerDialog found here.

However, it looks rather messy and I would prefer using the sleeker CMFCEditBrowseCtrl, which from my research and understanding (and please do correct me if I am wrong about this), can make what is essentially one object with both the box that holds a string (in this case a folder path) and a button which opens up a folder browse dialog, like this one here, above the 100% in the linked image.

My trouble is implementing this in the .rc file. Other C.... objects like CEdit or CListBox require the user to add them to the .rc file with CONTROLS found here. For example, CEdit uses EDITTEXT and CListBox uses LISTBOX.

My question is which control is used for CMFCEditBrowseCtrl ?

Ideally, I could use a style in the .rc file to make the box un-editable, and can only be changed when the user browses for a folder. Then the box will contain the folder path.

Upvotes: 1

Views: 260

Answers (2)

SoronelHaetir
SoronelHaetir

Reputation: 15162

The docs at CMFCEditBrowseCtrl say to use an EDIT control in the dialog resource then to use CMFCEditBrowseCtrl for the bound member.

All this would be easier to do with class wizard but can be accomplished manually as well.

Upvotes: 0

Andrew Truckle
Andrew Truckle

Reputation: 19137

Why aren't you just dragging a MFC EditBrowse Control from the Resource Editor?

enter image description here

In my RC file this control is defined like this:

CONTROL         "",IDC_MFCEDITBROWSE_LOCAL_BACKUP_FOLDER,"MfcEditBrowse",WS_BORDER | WS_TABSTOP | 0x80,18,173,327,14

And yes, I use it exactly for the purpose you described.

Upvotes: 1

Related Questions