How to Change an MFC Modeless Dialog to be the child of a CView in an MDI application?
문제
I have an MFC application that is a Doc/View/Frame implementation. One dialog is running as a modeless dialog which pops up on demand (from a menu option). I'm looking to add the modeless dialog to an MDI child view. Basically, I want to load the template from the resource file, and create it as a child of the CView in my new trio (doc/view/frame) that I am adding to the template lists for the MDI.
I've tried a few things in my derived CMyView class:
void CMyView::OnInitialUpdate()
{
m_ListDialog = new Dialogs::CListDialog( m_config, this );
m_ListDialog->Create( Dialogs::CListDialog::IDD, this );
m_ListDialog->ShowWindow( SW_SHOW );
}
I've tried calling SetWindowPos, ModifyStyle (WS_CHILD, WS_VISIBLE, DS_CONTROL). I've tried modifying the resource file to set the child and control manually.
Everytime it calls Create, the ListDialog's m_hWnd is left as 0. This tells me it's not getting created properly. Any call to SetWindowPos() or ShowWindow() fails because the m_hWnd is 0 (debug assertion fails).
What do I need to do to get a modeless dialog to be constructed, created, and appear as a child to CMyView in my MDI application?
해결책
I don't know. But...
You have several alternative choices which could be suitable depending on how your application should looks.
1/using CFormView
.
If your view is dedicated to the dialog then you can derive a view from the MFC class CFormView. The purpose of this view is to display a dialog.
Juste create a new application using the wizard and I think you should be able to choose the CFormView class as your view class, then copy the generated file into your existaing application.
2/ Using a CSplitterWnd
. One view being a CFormView and the other your current CView.
3/ using CDialogBar
If your view already displays something, you can add your dialog as a tool bar using the class CDialogBar.
다른 팁
jQuery를 사용하여 고유 한 식별자로 가장 가까운 항목을 찾습니다.양식의 모든 필드에는 ID="SPFILEDDATETIME"이있는 날짜 필드에서 찾은 것처럼 고유 한 ID가 아닙니다.그러나 해당 레이블 열에는 필드 이름이 포함되어 있으며이 것은 고유해야합니다.
이것을 후크로 사용하십시오.그런 다음 클래스 이름 "MS-FORMBODY"로 고유 한 요소의 형제 자매로 이동할 수 있습니다.예 :
$('td.ms-formlabel:contains("Text2")').siblings(".ms-formbody").css("background", "yellow");
.
는 를 보여줍니다
또는 텍스트 값을 검색하려면 와 같은 것을 사용하십시오.
$('td.ms-formlabel:contains("Text2")').siblings(".ms-formbody").text()
.
경고에서 :
alert($('td.ms-formlabel:contains("Text2")').siblings(".ms-formbody").text());
.
또는 로 행을 숨 깁니다.
$('td.ms-formlabel:contains("Text2")').parent().hide();
.