다음을 통해 공유


AfxRegisterClass

이 함수를 사용 하 여 DLL에서 MFC를 사용 하 여 창 클래스를 등록할 수 있습니다.

BOOL AFXAPI AfxRegisterClass(
   WNDCLASS* lpWndClass 
);

매개 변수

  • lpWndClass
    포인터는 WNDCLASS 창 클래스 등록 정보를 포함 하는 구조입니다.이 구조에 대 한 자세한 내용은 Windows SDK.

반환 값

True 이면 클래스를 성공적으로 등록 되어 있는 경우. 그렇지 않으면 FALSE.

설명

이 함수를 사용 하면 DLL이 언로드될 때 클래스를 자동으로 등록 된입니다.

비 DLL 빌드에는 AfxRegisterClass 식별자는 Windows 함수에 매핑되는 매크로 정의 RegisterClass, 응용 프로그램에서 등록 된 클래스를 자동으로 등록 되지 않은 때문입니다.사용 하는 경우 AfxRegisterClass 대신 RegisterClass, 응용 프로그램에서 및 DLL에는 변경 하지 않고 코드를 사용할 수 있습니다.

예제

// Register your unique class name that you wish to use
WNDCLASS wndcls;

memset(&wndcls, 0, sizeof(WNDCLASS));   // start with NULL defaults

wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;

//you can specify your own window procedure
wndcls.lpfnWndProc = ::DefWindowProc; 
wndcls.hInstance = AfxGetInstanceHandle();
wndcls.hIcon = LoadIcon(wndcls.hInstance, MAKEINTRESOURCE(IDI_MYICON));
wndcls.hCursor = LoadCursor(wndcls.hInstance, MAKEINTRESOURCE(IDC_ARROW));
wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndcls.lpszMenuName = NULL;

// Specify your own class name for using FindWindow later
wndcls.lpszClassName = _T("MyNewClass");

// Register the new class and trace if it fails
if(!AfxRegisterClass(&wndcls))
{
   TRACE("Class Registration Failed\n");
}

요구 사항

헤더: afxwin.h

참고 항목

개념

MFC 매크로 전역