2012-02-13 2 views
0

저는 C++/CLI를 사용하여 달리 네이티브 DLL 용 WPF 인터페이스를 만들고 있습니다.WindowInteropHelper가 C++/CLI에서 생성되지 않습니다.

닫히지 않고 최소화 할 수있는 창을 만들고 싶습니다. 필자는 검색 한 결과 WIN32 호출 만 수행 할 수있는 유일한 방법이라는 것을 알았습니다. 그래서 다음 코드를 사용하고 있습니다.

// window_ is a Window^initialized from XAML and checked against nullptr 
// its WindowStyle is SingleBorderWindow 

System::Windows::Interop::WindowInteropHelper helper(window_); 
IntPtr winhandle = helper.Handle; 
void * winhandleptr = winhandle.ToPointer(); 
HWND hWnd = static_cast<HWND>(winhandleptr); 
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_SYSMENU); 

하지만 winhandle0의 값을 가져옵니다. SetWindowLong() 호출이 잘못된 핸들로 실패합니다.

내가 뭘 잘못하고 있니?

답변

1

시도해도 제대로 작동합니다. 창은 다음과 같다 : 내가 생각할 수있는

enter image description here

유일한 고장 모드가 기본 윈도우가 생성되기 전에, 너무 빨리 코드라는 점이다. Loaded 이벤트가 필요합니다. 내 이벤트는 다음과 같습니다.

private void Window_Loaded(object sender, RoutedEventArgs e) { 
     cpptemp8.Class1.FixWindow(this); 
    } 

더 많은 작업이 필요합니다. 최소화 버튼이 없습니다. Alt + F4를 사용하여 창을 닫으면 계속 작동합니다.

관련 문제