메뉴 건너뛰기

OBG

Programming

MoA
조회 수 1615 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
ex)
CServerManagerDlg 메인 다이얼로그
 
스레드와 관련없는 함수들은 타 클래스에서
CServerManagerDlg* lpDlg = (CServerManagerDlg*)AfxGetMainWnd();
이렇게 선언해서 가져다 썼다.
하지만,
스레드안에서는 메인다이얼로그 포인터를 얻을수 없다.
이유인 즉
AfxGetMainWnd()
안으로 들어가보면
 
_AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd()
{
    CWinThread* pThread = AfxGetThread();
    return pTrhead != NULL ? pThread->GetMainWnd() : NULL;
}

내부에서 AfxGetThread() 함수를 사용하는 것을 볼수가 있다.
이것은 현재 스레드의 GetMainWnd() 함수를 호출한다.
이것은 다른 스레드에서 메인 윈도우의 핸들이 필요할때는 문제가 된다.
즉 다른 스레드에서 다음과 같이 AfxGetMainWnd() 함수를 호출하면 메인 윈도우의 핸들을 얻을수가 없게 된다.
해서
 
스레드에 연결된 모든 맴버 함수내에서는
CServerManagerDlg* lpDlg = (CServerManagerDlg*)AfxGetApp()->GetMainWnd();
이렇게 해주면 된다.

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 Tool/etc Programming 게시판 관련 2 MoA 2014.11.01 1708
186 C/C++ Essential C 링크 너울 2011.08.31 297
185 Library ExcelFormat Library Naya 2012.08.02 871
184 C/C++ extern "C" 에 관하여 MoA 2013.07.28 317
183 Python FastAPI 톺아보기 - 부제: python 백엔드 봄은 온다 OBG 2023.01.25 118
182 Tool/etc Flash CS5 and Version Control MoA 2013.10.11 346
181 C/C++ fopen 함수가 Multi Thread 에서 안전한가? MoA 2013.07.28 585
180 C/C++ fwrite(), fread() MoA 2013.07.28 615
179 API/MFC GetLastInputInfo 함수 MoA 2013.12.06 434
178 LLM Getting Started with Sentiment Analysis using Python OBG 2024.04.11 25
177 Site GOF 디자인패턴 정리 MoA 2013.07.28 351
176 서버 Golang Tutorial for Node.js Developers, Part I.: Getting started OBG 2022.06.16 129
175 Library Google의 C++ 라이브러리 Naya 2012.08.02 439
174 C/C++ Google의 C++ 라이브러리 MoA 2013.07.28 477
173 Site Great summary cheat sheet (OpenCV) MoA 2013.01.04 404
172 Library High-speed Charting Control MoA 2013.07.28 373
171 LLM How LLMs Work ? Explained in 9 Steps — Transformer Architecture OBG 2024.04.11 21
170 Web How to send dynamic charts with a Slack bot OBG 2022.05.31 136
169 Tool/etc How To Set Up Multi-Factor Authentication for SSH on Ubuntu 20.04 OBG 2023.01.17 96
168 Tool/etc How to stop programmers to copy the code from GitHub when they leave the company? OBG 2024.01.02 113
167 Tool/etc HuggingFace 공동창업자가 추천하는 AI 분야 입문 서적 OBG 2024.05.24 30
Board Pagination Prev 1 ... 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15
위로