1

Here's what the resource manager shows for this particular EditBrowseCtrl. You can see that the "Browse Mode" option is set to "Folder Browse". resource editor view

And here's what the actual dialog box looks like when I run the program(no browse button): no browse button

I've also tried to enable the folder browse button via the EnableFolderBrowseButton method, but the following just gives me a generic "encountered an improper argument" exception.

CMFCEditBrowseCtrl* pEdit;
pEdit = (CMFCEditBrowseCtrl*)GetDlgItem(IDC_MFCEDITBROWSE);
pEdit->EnableFolderBrowseButton();

As requested, here's the contents of the .rc file:

/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//

IDD_PREFERENCES_PROPPAGE DLGINIT
BEGIN
    IDC_MFCLINK1, 0x37c, 175, 0
0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x733e, 0x7379, 0x616c, 
0x2e74, 0x6f63, 0x3c6d, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 
0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x506c, 0x6572, 0x6966, 
0x3e78, 0x7468, 0x7074, 0x3a73, 0x2f2f, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 
0x5f6b, 0x7255, 0x506c, 0x6572, 0x6966, 0x3e78, 0x4d3c, 0x4346, 0x694c, 
0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x4d2f, 0x4346, 0x694c, 
0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 
0x5f6b, 0x7546, 0x6c6c, 0x6554, 0x7478, 0x6f54, 0x6c6f, 0x6974, 0x3e70, 
0x4146, 0x534c, 0x3c45, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 
0x546c, 0x7865, 0x5474, 0x6f6f, 0x746c, 0x7069, "\076" 
    IDC_MFCEDITBROWSE, 0x37c, 42, 0
0x4d3c, 0x4346, 0x6445, 0x7469, 0x7242, 0x776f, 0x6573, 0x4d5f, 0x646f, 
0x3e65, 0x3c32, 0x4d2f, 0x4346, 0x6445, 0x7469, 0x7242, 0x776f, 0x6573, 
0x4d5f, 0x646f, 0x3e65, 
    0
END

Any help is greatly appreciated.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Skewjo
  • 379
  • 3
  • 12
  • 1
    The issue does not duplicate using a barebones MFC dialog, so there must be differences elsewhere in the code not shown. See [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – dxiv Dec 31 '20 at 07:37
  • Hello again @dxiv. I can temporarily make the project public if necessary. That seems like the only way I'm going to be able to solve this problem, as I need the problem fixed in my current codebase, and I have no earthly idea where the issue could be. – Skewjo Dec 31 '20 at 14:14
  • 1
    Can you please show the RC snippet of the control from your dialog resource file? – Andrew Truckle Dec 31 '20 at 17:56
  • 1
    I saw this: https://stackoverflow.com/questions/46362484/cmfceditbrowsectrl-using-cwinapp-appears-as-a-classic-textbox. Out of interest are you using `CWinApp` or `CWinAppEx`? – Andrew Truckle Dec 31 '20 at 17:59
  • @AndrewTruckle I've posted the RC snippet. I saw that issue as well, but at the time I thought it didn't apply to me for some reason... I am using CWinApp. Will attempt to change it to CWinAppEx and get back to you. – Skewjo Dec 31 '20 at 19:33
  • Changing the base app class from ```CWinApp``` to ```CWinAppEx``` does not fix the original issue with the resource view option failing to work, but it does give me a different error( ```Exception thrown: read access violation. pOldData```) when attempting to enable the browse button with the code above. Seems like it might be having an issue with the edit control not having a value already set? – Skewjo Dec 31 '20 at 20:07
  • 1
    Just one observation, the RC data you displayed was not for the actual control on the dialog but was initialization data. The actual control on the dialog itself would look a bit like `CONTROL "",IDC_MFCEDITBROWSE,"MfcEditBrowse",WS_BORDER | WS_TABSTOP | 0x80,17,51,330,14` in the file. It is in a different location of the RC. But not to worry. :) – Andrew Truckle Jan 01 '21 at 00:18
  • Ah, thank you for letting me know. IDK why, but I still feel compelled to post it, so here it is: ```CONTROL "",IDC_MFCEDITBROWSE,"MfcEditBrowse",WS_BORDER | WS_TABSTOP | 0x80,182,18,80,14``` – Skewjo Jan 01 '21 at 14:19

1 Answers1

2

I finally figured out that my issue was overriding OnInitDialog without calling the base class OnInitDialog (CDialogEx::OnInitDialog).

Skewjo
  • 379
  • 3
  • 12
  • 1
    Ah, yes. You always need to call your base classes, which is normally added by default when you add your overrides via the IDE. Well done on resolving the issue. – Andrew Truckle Dec 31 '20 at 21:19
  • Thanks. This was definitely an oops on my part. I wrote this particular function override "by-hand", which kind of caused the issue. – Skewjo Dec 31 '20 at 23:34