MFC edit control border

Hi, I'm trying to make various MFC applications with edit controls using VS2005 when I noticed my professor's edit controls were flat, 2D with just a blue border.  I have no idea how to accomplish this.  In VS2005, I open the IDD_FORMVIEW and add an edit control with no static edge or anything, just border set to true.  In the designer and the "Test Dialog" mode, the control looks correct:  2D, blue border, very simple.  But when I build and run, the blue border is gone and the edit control is now sunken and 3D.  My professor has no idea why his is different, since our edit controls use the same options.  I have also tried to do the exact same thing in VS2003 on a different computer, with the same results (except not even the designer and the Test Dialog mode show a 2D edit control, they show a 3D edit control).

i'm not sure if this has something to do with winxp visual styles or something else.  does anyone have any ideas how to fix this   I'm at the end of my wits, and I've googled for several days now and tried every little option to change it.
The only way I can even make a 2D edit control is to set static edge, border, and client edge to false.  But if I set border to false, I also lose the blue line bordering the edit control (it essentially blends into the background now).

Here's a picture of how his looks:
his nice 2D one

and here's how mine always comes out (notice how hard the 3D read-only edit control is to see):
mine 3D nightmare



Answer this question

MFC edit control border

  • Coc Patrick

    In Visual Studio C++ 2003 & 2005, the manifest will be included as the part of resource files. So you don't know to worry about that. You can make it as a custom resource in Visual C++ 6.
    Hope the link I have provided the way to do the same



  • Serge_OD

    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
    #ifdef _WIN32
    LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
    #pragma code_page(1252)
    #endif //_WIN32

    try ot put it after this line.


  • LORD ORION

    hehe, interestingly enough, I just added it to the end and added a few blank lines since so many parsers depend on blank lines at the end of a file. Anyway, I just reopened the rc file and it put the manifest statement where it wanted it, and even commented it.

    * WeelyTM impressed with Microsoft on that one.

    so yes, w00t! it works now! Thanks so much. It seems like a less than finessed way of getting visual styles, but it works. I must consult with my professor to see if he knows anything of manifests and why his works automatically vs mine not.

  • Alvin Chen

    Seems your application lacking of manifest for your application.

    See MSDN for Using Windows XP Visual Styles.

    It will work fine.

    HTH


  • gjutras

    Well, I'm trying it now but the instructions are very vague. I'm trying the first one.. I've already created a manifest file, but I'm not sure about part 1 and 3. Part 1 being:

    Link to ComCtl32.lib and call InitCommonControls.

    I found InitCommonControlsEx is already called, but I'm not sure about linking to ComCtl32.lib, if its already done or if I have to put in some include line somewhere manually.

    Also, step 3:
    Add the manifest to your application's resource file as follows:
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "YourApp.exe.manifest"


    I view the code for the .rc file, but its quite large and I'm not sure
    where to put this line.

    Thanks for the help btw.


  • Mathew1972

    Yes, I've seen that. I'll try it right now. Is there a way to automate the manifest thing Like, is there a way to make it automatically included and done for a project I ask because, as far as my professor knows, he has not done this procedure to include a manifest, yet his works as though he did.

  • James_Steven

    I found a simple answer today. I turned off unicode, and there is a line in stdafx.h that says

    #ifdef _UNICODE
    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")

    turning off unicode = turning off visual styles

  • aztec2_step

    Things are very simple.
    You can put it the manifest either with your executable or seperately.

    if you put the your app.exe.manifest in your exe's path it will automatically loads if you called InitCommon controls.

    else you may have to define it in the resource file (RC file).
    normally the additional resources are defined in the rc2 file which is placed inside the "res" directory and also the manifest.
    so you can give the complete path in rc file or rc2 file
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "res/SampleDialog.manifest"

    else you may have to put it in the current directory


  • MFC edit control border