This function enables device resolution awareness in device application projects.

void AfxEnableDRA(BOOL bEnable);


  • bEnable
    Specifying TRUE enables device resolution awareness; specifying FALSE, or not calling the function, disables device resolution awareness.


The Device Resolution Awareness feature allows the application to respond to changes in resolution at run time, such as changing from portrait to landscape mode.

Use the AfxEnableDRA() function when you instantiate CDialog directly. In this situation you are using the OnSize method defined in dlgcore.cpp and implemented in the MFC DLL and LIB. In these library versions, AfxIsDRAEnabled() is used to perform a run-time check to determine whether or not to call DRA::RelayoutDialog(...). AfxIsDRAEnabled() returns true only if AfxEnableDRA(TRUE) has previously been called.


When you use wizards to create an MFC project for devices, the generated code implements an override (CDialog::OnSize(int, int)) for CDialog-derived classes. Device resolution awareness is then checked at compile time, and the decision to call or not call DRA::RelayoutDialog(...) is made.


AfxEnableDRA(TRUE); //Enable Device Resolution Awareness
void CDialog::OnSize(UINT nType, int cx, int cy)
    if (AfxIsDRAEnabled())
            DRA::GetDisplayMode() != DRA::Portrait ? 
                m_lpszWideTemplateName : m_lpszTemplateName);
        CWnd::OnSize(nType, cx, cy);

See Also

Other Resources

Unique MFC for Devices Classes