티스토리 뷰

정보 보관 ver1.0

MFC 전역 함수

James Wetzel 2011. 11. 8. 19:52

AfxMessageBox

int AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 );

int AFXAPI AfxMessageBox( UINT nIDPrompt, UINT nType = MB_OK, UINT nIDHelp = (UINT) -1 );

Return Value

Zero if there is not enough memory to display the message box; otherwise one of the following values is returned:

  • IDABORT The Abort button was selected.

  • IDCANCEL The Cancel button was selected.

  • IDIGNORE The Ignore button was selected.

  • IDNO The No button was selected.

  • IDOK The OK button was selected.

  • IDRETRY The Retry button was selected.

  • IDYES The Yes button was selected.

If a message box has a Cancel button, the IDCANCEL value will be returned if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing the ESC key has no effect.

The functions AfxFormatString1 and AfxFormatString2 can be useful in formatting text that appears in a message box.

Parameters

lpszText

Points to a CString object or null-terminated string containing the message to be displayed in the message box.

nType

The style of the message box. Apply any of the message-box styles to the box.

nIDHelp

The Help-context ID for the message; 0 indicates the application’s default Help context will be used.

nIDPrompt

A unique ID used to reference a string in the string table.

Remarks

Displays a message box on the screen. The first form of this overloaded function displays a text string pointed to by lpszText in the message box and uses nIDHelp to describe a Help context. The Help context is used to jump to an associated Help topic when the user presses the Help key (typically F1).

The second form of the function uses the string resource with the ID nIDPrompt to display a message in the message box. The associated Help page is found through the value of nIDHelp. If the default value of nIDHelp is used (– 1), the string resource ID, nIDPrompt, is used for the Help context. For more information about defining Help contexts, see the article Help Topics in Visual C++ Programmer’s Guide and Technical Note 28.

See Also CWnd::MessageBox 

 

AfxGetApp

CWinApp* AfxGetApp( );

Return Value

A pointer to the single CWinApp object for the application.

Remarks

The pointer returned by this function can be used to access application information such as the main message-dispatch code or the topmost window.

AfxGetMainWnd

CWnd* AfxGetMainWnd( );

Return Value

If the server has an object that is in-place active inside a container, and this container is active, this function returns a pointer to the frame window object that contains the in-place active document.

If there is no object that is in-place active within a container, or your application is not an OLE server, this function simply returns the m_pMainWnd of your application object.

If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.

Remarks

If your application is an OLE server, call this function to retrieve a pointer to the active main window of the application instead of directly referring to the m_pMainWnd member of the application object.

If your application is not an OLE server, then calling this function is equivalent to directly referring to the m_pMainWnd member of your application object.

See Also CWinThread::m_pMainWnd 

 

AfxGetAppName

LPCTSTR AfxGetAppName( );

Return Value

A null-terminated string containing the application’s name.

Remarks

The string returned by this function can be used for diagnostic messages or as a root for temporary string names. 

 

AfxGetInstanceHandle

HINSTANCE AfxGetInstanceHandle( );

Return Value

An HINSTANCE to the current instance of the application. If called from within a DLL linked with the USRDLL version of MFC, an HINSTANCE to the DLL is returned.

Remarks

This function allows you to retrieve the instance handle of the current application. AfxGetInstanceHandle always returns the HINSTANCE of your executable file (.EXE) unless it is called from within a DLL linked with the USRDLL version of MFC. In this case, it returns an HINSTANCE to the DLL.

See Also AfxGetResourceHandle, AfxSetResourceHandle 

AfxBeginThread

CWinThread* AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );

CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );

Return Value

Pointer to the newly created thread object.

Parameters

pfnThreadProc

Points to the controlling function for the worker thread. Cannot be NULL. This function must be declared as follows:

UINT MyControllingFunction( LPVOID pParam );

pThreadClass

The RUNTIME_CLASS of an object derived from CWinThread.

pParam

Parameter to be passed to the controlling function as shown in the parameter to the function declaration in pfnThreadProc.

nPriority

The desired priority of the thread. If 0, the same priority as the creating thread will be used. For a full list and description of the available priorities, see SetThreadPriority in the Win32 Programmer’s Reference.

nStackSize

Specifies the size in bytes of the stack for the new thread. If 0, the stack size defaults to the same size stack as the creating thread.

dwCreateFlags

Specifies an additional flag that controls the creation of the thread. This flag can contain one of two values:

  • CREATE_SUSPENDED Start the thread with a suspend count of one. The thread will not execute until ResumeThread is called.

  • 0 Start the thread immediately after creation.

lpSecurityAttrs

Points to a SECURITY_ATTRIBUTES structure that specifies the security attributes for the thread. If NULL, the same security attributes as the creating thread will be used. For more information on this structure, see the Win32 Programmer’s Reference.

Remarks

Call this function to create a new thread. The first form of AfxBeginThread creates a worker thread. The second form creates a user-interface thread.

AfxBeginThread creates a new CWinThread object, calls its CreateThread function to start executing the thread, and returns a pointer to the thread. Checks are made throughout the procedure to make sure all objects are deallocated properly should any part of the creation fail. To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.

For more information on AfxBeginThread, see the articles Multithreading: Creating Worker Threads and Multithreading: Creating User-Interface Threads in Visual C++ Programmer’s Guide.

See Also AfxGetThread 

 

AfxEndThread

void AfxEndThread( UINT nExitCode );

Parameters

nExitCode

Specifies the exit code of the thread.

Remarks

Call this function to terminate the currently executing thread. Must be called from within the thread to be terminated.

For more information on AfxEndThread, see the article Multithreading: Terminating Threads in Visual C++ Programmer’s Guide.

See Also AfxBeginThread

728x90
반응형