이글루스 | 로그인
메뉴릿
카테고리
전체
공지사항
계획
Languages
Humanities
Mathematics
Education
Economics
Computers
HCI
Media
Engineering
Natural Science
TmaxSoft
BluemoonSoft
미분류
최근 등록된 덧글
짝짝짝 올 많이 컸네 일구
by izeye at 11/12
제가 갖고 있는 소스 파일..
by 언제나19 at 10/17
우왕 고맙습니다~~. ..
by 언제나19 at 10/16
http://nethack.byus..
by uriel at 10/16
근본적으로 activation ..
by uriel at 10/16
다운 안되는데여;;;;;
by 강병진 at 10/14
일단, 형변환 자체가 ..
by uriel at 04/11
어제는 괜히 xfix 실행..
by 언제나19 at 01/18
좀 기다리세요. 내년 4..
by 언제나19 at 11/04
바꾸어라.. 언제나19-..
by kang at 11/03
최근 등록된 트랙백
textcube를 다시 설치
by 공부가 본업.
gnuplot을 c 함수로 ..
by 상품 + 글 의견 남기기
gsl, gnu scientific li..
by 상품 + 글 의견 남기기
ubuntu, ati에서 dual..
by 상품 + 글 의견 남기기
Data browser로 sql d..
by 공부가 본업.
근황
by Yi jeon goo
근황
by Yi jeon goo
라이프로그
화려한 휴가
화려한 휴가

좋지 아니한가
좋지 아니한가

300
300

포토로그

언제나19의 포토로그
메모장 실험
메모장도 로그가 남나 실험
이전블로그
more...
이글루링크
◈ ◈ ◈ 바다가 머무는 ..
Mono log
Liard's newspaper
Yochin의 대전생활.
M log
art.oriented
* Sea of Blue *
이글루 파인더
rss

skin by 狂風
DestroyWindow 실험

 
DestroyWindow가 다른 thread에는 적용되지 않는다.

다른 process의 window를 죽이려고 시도해봤고,
같은 process에서 thread를 만들어서 window를 죽이려고 시도해 봤다.
덕분에, win32로 thread 만드는 연습만 한 번 한 셈.

윽 msdn에 이미 나온 내용이네. -_-

Remarks

A thread cannot use DestroyWindow to destroy a window created by a different thread.

If the window being destroyed is a child window that does not have the WS_EX_NOPARENTNOTIFY style, a WM_PARENTNOTIFY message is sent to the parent.


읽고 보니, 전에 한 번 읽고서 물론 그러겠거니 했던 기억이 난다.
에휴.

PostMessage 로 WM_QUIT 을 보내는 건 잘 된다.
다른 process도 잘 죽인다. 이래도 되나?

msdn에는 PostMessage 쓰지 말고, PostQuitMessage를 쓰라고 돼있지만.


thread 만들기는 http://www.codersource.net/win32_multithreading.html code를 참고했다.
출력할 때는 OutputDebugString 을 썼다.
char* 안쓰고, LP뭐시기 쓰는 거 짜증난다. API도 잘 몰라서.
wsprintf 랑 TCHAR* 를 썼다.




Window handle은 FindWindow로 찾았다.

 case WM_LBUTTONDOWN:
  //targetWindow = FindWindow(NULL, L"DestroiedWindowTest");
  targetWindow = FindWindow(NULL, L"Thread Window");
  if(!DestroyWindow(targetWindow))
   MessageBox(hWnd, L"Cant", L"caption", 0);
  else
   MessageBox(hWnd, L"Ok.", L"caption", 0);
  break;
 case WM_RBUTTONDOWN:
  //targetWindow = FindWindow(NULL, L"DestroiedWindowTest");
  targetWindow = FindWindow(NULL, L"Thread Window");
  if (!PostMessage(targetWindow, WM_DESTROY, NULL, NULL))
   MessageBox(hWnd, L"Cant post", L"caption", 0);
  else
   MessageBox(hWnd, L"Posted", L"caption", 0);
  break;


IDM_ABOUT 에 CreateThread를 넣었다.

  case IDM_ABOUT:
   DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
   DWORD dwGenericThread;
   TCHAR lszThreadParam[3];
   wsprintf(lszThreadParam, L"%d", 3);
   hThread = CreateThread(NULL, 0,
    StartThread, &lszThreadParam,
    0, &dwGenericThread);



같은 역할을 하는 window를 만들었다.

DWORD WINAPI StartThread(LPVOID iValue)
{
 //TCHAR lszParam[3];
 //strcpy((char*)lszParam, iValue);
 //int iStart = atoi(lszParam);
 //for (int i = iStart; i <= iStart+2; i++)
  OutputDebugString((LPCWSTR)iValue);
  HWND hWnd = CreateWindow(szWindowClass, L"Thread Window", WS_OVERLAPPEDWINDOW,
   CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
  if (!hWnd)
   OutputDebugString(L"Cant CreateWindow");
  ShowWindow(hWnd, SW_SHOW);
  UpdateWindow(hWnd);
  

 MSG msg;
 while (GetMessage(&msg, NULL, 0, 0))
 {
  //if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  {
   TranslateMessage(&msg);
   DispatchMessage(&msg);
  }
 }

 OutputDebugString(L"Thread end");
 return (int) msg.wParam;
 
}

by 언제나19 | 2008/11/13 23:17 | Computers | 트랙백 | 덧글(0)
트랙백 주소 : http://always19.egloos.com/tb/2165201
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글


◀ 이전 페이지 다음 페이지 ▶