Click here to Skip to main content
15,895,859 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionAddFontResourceEx Pin
RaymondM25-Jan-09 21:52
RaymondM25-Jan-09 21:52 
AnswerRe: AddFontResourceEx Pin
RaymondM25-Jan-09 21:53
RaymondM25-Jan-09 21:53 
GeneralRe: AddFontResourceEx Pin
Randor 26-Jan-09 17:22
professional Randor 26-Jan-09 17:22 
GeneralRe: AddFontResourceEx Pin
RaymondM26-Jan-09 19:13
RaymondM26-Jan-09 19:13 
GeneralRe: AddFontResourceEx [modified] Pin
Randor 26-Jan-09 21:09
professional Randor 26-Jan-09 21:09 
GeneralRe: AddFontResourceEx Pin
RaymondM27-Jan-09 4:47
RaymondM27-Jan-09 4:47 
GeneralRe: AddFontResourceEx Pin
Randor 27-Jan-09 7:52
professional Randor 27-Jan-09 7:52 
QuestionWindow Handle from CreateWindow will colse itself when thread exit? Pin
fitatc25-Jan-09 21:33
fitatc25-Jan-09 21:33 
first, the MSDN about CreateWindow() not mention of close the handle of window it returns.
Confused | :confused: is it means that we donnot need to care about it?(Sorry about the title if it is true)

second, I test of this in the code like this
HWND hWnd;
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
hWnd = CreateWindow(
			 L"BUTTON"
			,L"dmyWnd"
			,WS_DISABLED
			,CW_USEDEFAULT
			,CW_USEDEFAULT
			,0
			,0
			,NULL
			,NULL
			,::AfxGetInstanceHandle()
			,NULL
			);
        while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
	{ 
		if (bRet == -1)
		{
			// handle the error and possibly exit
			TRACE(L"[Thread] ERROR\n");
		}
		else
		{
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		}
	}
	return 0;
} 

_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); // called by MainThread


I try to call
int nRt = ::GetWindowText(hWnd, cs, 256);
before and after I
::PostThreadMessage(threadID, WM_QUIT, 0, 0);
to end the thread.
The result is sccess when thread alive and invalid handle when thread exit.

Confused | :confused: I am not sure if this can prove that window handle is be safely closed.Could any one tell me
that is it true "Window Handle from CreateWindow will colse itself when thread exit"
AnswerRe: Window Handle from CreateWindow will colse itself when thread exit? Pin
Stuart Dootson25-Jan-09 21:55
professionalStuart Dootson25-Jan-09 21:55 
AnswerRe: Window Handle from CreateWindow will colse itself when thread exit? Pin
Stephen Hewitt26-Jan-09 0:33
Stephen Hewitt26-Jan-09 0:33 
AnswerRe: Window Handle from CreateWindow will colse itself when thread exit? Pin
Randor 26-Jan-09 13:27
professional Randor 26-Jan-09 13:27 
GeneralRe: Window Handle from CreateWindow will colse itself when thread exit? Pin
fitatc26-Jan-09 13:46
fitatc26-Jan-09 13:46 
QuestionShow/Hide part of a CView / CFormView Pin
swarnalucky25-Jan-09 20:17
swarnalucky25-Jan-09 20:17 
AnswerRe: Show/Hide part of a CView / CFormView Pin
SutterA25-Jan-09 22:05
SutterA25-Jan-09 22:05 
GeneralRe: Show/Hide part of a CView / CFormView Pin
swarnalucky26-Jan-09 3:49
swarnalucky26-Jan-09 3:49 
GeneralRe: Show/Hide part of a CView / CFormView Pin
SelvaKr26-Jan-09 14:34
SelvaKr26-Jan-09 14:34 
GeneralRe: Show/Hide part of a CView / CFormView Pin
SutterA2-Feb-09 23:15
SutterA2-Feb-09 23:15 
QuestionDesign Data structure. Pin
mikert_200825-Jan-09 20:10
mikert_200825-Jan-09 20:10 
AnswerRe: Design Data structure. Pin
David Crow26-Jan-09 2:52
David Crow26-Jan-09 2:52 
GeneralRe: Design Data structure. Pin
mikert_200826-Jan-09 16:59
mikert_200826-Jan-09 16:59 
QuestionDisplaying Symbol issue......... Pin
shaina223125-Jan-09 18:52
shaina223125-Jan-09 18:52 
AnswerRe: Displaying Symbol issue......... Pin
Rajesh R Subramanian25-Jan-09 19:47
professionalRajesh R Subramanian25-Jan-09 19:47 
AnswerRe: Displaying Symbol issue......... Pin
CPallini25-Jan-09 22:24
mveCPallini25-Jan-09 22:24 
GeneralRe: Displaying Symbol issue......... Pin
toxcct26-Jan-09 1:56
toxcct26-Jan-09 1:56 
GeneralRe: Displaying Symbol issue......... Pin
CPallini26-Jan-09 2:28
mveCPallini26-Jan-09 2:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.