/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool ListsPropDlg::OnInitDlg(HWND hwndCtrl, LPARAM lp) { GeneralPropDlgTabPtr qgenp; qgenp.Attach(NewObj GeneralPropDlgTab(this, m_ctidName)); qgenp->EnableLocation(true); qgenp->EnableSize(true); qgenp->EnableModified(true); qgenp->EnableDescription(true); AfDialogViewPtr qdlgv; qdlgv = qgenp; m_vqdlgv.Push(qdlgv); qdlgv.Attach(NewObj DetailsPropDlgTab(this)); m_vqdlgv.Push(qdlgv); m_hwndTab = ::GetDlgItem(m_hwnd, kcidLangProjPropDlgTab); // WARNING: If this ever gets changed to anything but a fixed length buffer, make sure // ti.pszText is set after loading each string, since the memory pointed to by strb // could be different each time. StrAppBuf strb; TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = const_cast<achar *>(strb.Chars()); // Add a tab to the tab control for each dialog view. strb.Load(kstidGeneralPropTab); TabCtrl_InsertItem(m_hwndTab, kidlgGeneral, &ti); strb.Load(kstidListsDetails); TabCtrl_InsertItem(m_hwndTab, kridDetailsPropDlg, &ti); // This section must be after at least one tab gets added to the tab control. RECT rcTab; ::GetWindowRect(m_hwndTab, &rcTab); TabCtrl_AdjustRect(m_hwndTab, false, &rcTab); POINT pt = { rcTab.left, rcTab.top }; ::ScreenToClient(m_hwnd, &pt); m_dxsClient = pt.x; m_dysClient = pt.y; // Subclass the Help button. AfButtonPtr qbtn; qbtn.Create(); qbtn->SubclassButton(m_hwnd, kctidHelp, kbtHelp, NULL, 0); ShowChildDlg(m_itabInitial); AfApp::Papp()->EnableMainWindows(false); ::SetFocus(m_hwndTab); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)m_strWndCaption.Chars()); return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- The hwnd has been attached. ----------------------------------------------------------------------------------------------*/ void DcMainWnd::PostAttach(void) { StrAppBuf strbT; // Holds temp string // Set the default caption text. strbT.Load(kstidDllClient); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars()); // This creates the main frame window and sets it as the current window. It also // creates the rebar and status bar. SuperClass::PostAttach(); // Create the menu bar. AfMenuBarPtr qmnbr; qmnbr.Create(); qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar"); m_vqtlbr.Push(qmnbr.Ptr()); CreateToolBar(qmnbr, true, true, 200); // Load window settings. LoadSettings(NULL, false); g_app.AddCmdHandler(this, 1); m_qstbr->RestoreStatusText(); // Create the client window. const int kwidChild = 1000; WndCreateStruct wcs; wcs.InitChild("DcClientWnd", m_hwnd, kwidChild); wcs.dwExStyle |= WS_EX_CLIENTEDGE; m_dccw.Create(); m_dccw->CreateHwnd(wcs); ::ShowWindow(m_dccw->Hwnd(), SW_SHOW); }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool RnTlsOptDlg::OnInitDlg(HWND hwndCtrl, LPARAM lp) { m_qrmw = dynamic_cast<RecMainWnd *>(MainWindow()); AfMdiClientWndPtr qmdic = m_qrmw->GetMdiClientWnd(); AssertPtr(qmdic); // Cancel the dialog if we aren't allowed to make changes. AfClientRecWndPtr qafcrw = dynamic_cast<AfClientRecWnd *>(qmdic->GetCurChild()); // This might not exist yet if the filter doesn't match anything during startup. if (qafcrw && !qafcrw->IsOkToChange()) { SuperClass::OnCancel(); return true; } Assert(m_cTabs == 6); // Ensure that the number of dialogs is what we expect. m_hwndTab = GetDlgItem(m_hwnd, kcidTlsOptDlgTab); AfLpInfo * plpi = m_qrmw->GetLpInfo(); AssertPtr(plpi); // Setup m_vuvs plpi->GetDbInfo()->GetCopyUserViewSpecs(&m_vuvs); SetVuvsCopy(); AfViewBarShell * pvwbrs = m_qrmw->GetViewBarShell(); AssertPtr(pvwbrs); // CAUTION! The order these are inserted is important since we use constant indexes to // access them (e.g., kidlgGeneral). AfDialogViewPtr qadv; qadv.Attach(NewObj TlsOptDlgCst(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgVw(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj FwFilterDlg(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgSort(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgOvr(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgGen(this)); m_vdlgv.Push(qadv); // Initialize the object classes that we can create in this dialog. TlsObject to; to.m_clsid = kclidRnEvent; to.m_nLevel = 0; to.m_strName.Load(kstidEventEntry); m_vto.Push(to); to.m_clsid = kclidRnAnalysis; to.m_nLevel = 0; to.m_strName.Load(kstidAnalEntry); m_vto.Push(to); // Initialize the Custom Define In vector. to.m_clsid = kclidRnEvent; to.m_nLevel = 0; to.m_strName.Load(kstidEventEntry); to.m_strClsName = "RnEvent"; m_vcdi.Push(to); to.m_clsid = kclidRnAnalysis; to.m_nLevel = 0; to.m_strName.Load(kstidAnalEntry); to.m_strClsName = "RnAnalysis"; m_vcdi.Push(to); to.m_clsid = kclidRnGenericRec; to.m_nLevel = 1000; // Level 1000 means ALL Entries to.m_strName.Load(kstidTlsOptCstAllEnt); to.m_strClsName = "RnGenericRec"; m_vcdi.Push(to); m_iDefaultCstDfn = m_vcdi.Size() - 1; // If we don't get a reasonable values from GetCurClsLevel, we just default to 0 for the // index. m_ivto = 0; for (int ivto = 0; ivto < m_vto.Size(); ++ivto) { if (m_vto[ivto].m_clsid == m_tgv.clsid && m_vto[ivto].m_nLevel == m_tgv.nLevel) { m_ivto = ivto; break; } } // Initialize the master view types supported by this dialog. TlsView tv; tv.m_vwt = kvwtBrowse; tv.m_fMaster = false; m_vtv.Push(tv); tv.m_vwt = kvwtDE; tv.m_fMaster = true; m_vtv.Push(tv); tv.m_vwt = kvwtDoc; tv.m_fMaster = false; m_vtv.Push(tv); // Update the General tab. TlsOptDlgGen * ptodg = dynamic_cast<TlsOptDlgGen *>(m_vdlgv[kidlgGeneral].Ptr()); AssertPtr(ptodg); ptodg->SetDialogValues(m_vuvs, &m_siwndClientDel); // Update the Custom Fields tab. TlsOptDlgCst * ptodc = dynamic_cast<TlsOptDlgCst *>(m_vdlgv[kidlgCustom].Ptr()); AssertPtr(ptodc); ptodc->SetDialogValues(m_vuvs, &m_siwndClientDel, &m_siCustFldDel); int iv1; // Update the Views tab. TlsOptDlgVw * ptodv = dynamic_cast<TlsOptDlgVw *>(m_vdlgv[kidlgViews].Ptr()); AssertPtr(ptodv); if (m_tgv.itabInitial == kidlgViews && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current view that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltView), sisel); if (sisel.Size()) iv1 = *sisel.Begin(); else { iv1 = -1; Assert(!qafcrw); } } if (iv1 >= 0) ptodv->SetDialogValues(m_vuvs, &m_siwndClientDel, iv1); // Update the Filters tab. FwFilterDlg * pfltdlg = dynamic_cast<FwFilterDlg *>(m_vdlgv[kidlgFilters].Ptr()); AssertPtr(pfltdlg); if (m_tgv.itabInitial == kidlgFilters && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current filter that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltFilter), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No Filter item. else { iv1 = -1; Assert(!qafcrw); } } pfltdlg->SetDialogValues(m_qrmw, Max(0, iv1)); // Update the Sort Methods tab. TlsOptDlgSort * psrtdlg = dynamic_cast<TlsOptDlgSort *>(m_vdlgv[kidlgSortMethods].Ptr()); AssertPtr(psrtdlg); if (m_tgv.itabInitial == kidlgSortMethods && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current sort method that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltSort), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No sort item. else { iv1 = -1; Assert(!qafcrw); } } psrtdlg->SetDialogValues(m_qrmw, Max(0, iv1)); // Update the Overlays tab. TlsOptDlgOvr * ptodo = dynamic_cast<TlsOptDlgOvr *>(m_vdlgv[kidlgOverlays].Ptr()); AssertPtr(ptodo); if (m_tgv.itabInitial == kidlgOverlays && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the first overlay that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltOverlay), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No Overlay item. else { iv1 = -1; Assert(!qafcrw); } } ptodo->SetDialogValues(plpi, Max(0, iv1), (m_tgv.itabInitial == kidlgOverlays && m_tgv.iv2 >= 0) ? m_tgv.iv2 : 0); // WARNING: If this ever gets changed to anything but a fixed length buffer, make sure // ti.pszText is set after loading each string, since the memory pointed to by strb // could be different each time. StrAppBuf strb; TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = const_cast<achar *>(strb.Chars()); // Add a tab to the tab control for each dialog view. strb.Load(kstidTlsOptCust); TabCtrl_InsertItem(m_hwndTab, kidlgCustom, &ti); strb.Load(kstidTlsOptView); TabCtrl_InsertItem(m_hwndTab, kidlgViews, &ti); strb.Load(kstidTlsOptFltr); TabCtrl_InsertItem(m_hwndTab, kidlgFilters, &ti); strb.Load(kstidTlsOptSort); TabCtrl_InsertItem(m_hwndTab, kidlgSortMethods, &ti); strb.Load(kstidTlsOptOvr); TabCtrl_InsertItem(m_hwndTab, kidlgOverlays, &ti); strb.Load(kstidTlsOptGen); TabCtrl_InsertItem(m_hwndTab, kidlgGeneral, &ti); // This section must be after at least one tab gets added to the tab control. RECT rcTab; ::GetWindowRect(m_hwndTab, &rcTab); TabCtrl_AdjustRect(m_hwndTab, false, &rcTab); POINT pt = { rcTab.left, rcTab.top }; ::ScreenToClient(m_hwnd, &pt); m_dxsClient = pt.x; m_dysClient = pt.y; // Subclass the Help button. AfButtonPtr qbtn; qbtn.Create(); qbtn->SubclassButton(m_hwnd, kctidHelp, kbtHelp, NULL, 0); ShowChildDlg(m_tgv.itabInitial); m_siwndClientDel.Clear(); m_siCustFldDel.Clear(); AfApp::Papp()->EnableMainWindows(false); SetFocus(::GetDlgItem(m_hwnd, kcidTlsOptDlgTab)); return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool DetailsPropDlgTab::OnInitDlg(HWND hwndCtrl, LPARAM lp) { HICON hicon = m_ppropd->GetIconHandle(); if (hicon) { ::SendMessage(::GetDlgItem(m_hwnd, kridDetailsPropTabObjIcon), STM_SETICON, (WPARAM)hicon, (LPARAM)0); } m_hfontLarge = AfGdi::CreateFont(16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, _T("MS Sans Serif")); if (m_hfontLarge) { ::SendMessage(::GetDlgItem(m_hwnd, kridDetailsPropTabBigName), WM_SETFONT, (WPARAM)m_hfontLarge, false); } ::SetWindowText(::GetDlgItem(m_hwnd, kridDetailsPropTabBigName), m_ppropd->GetName()); ::SetWindowText(::GetDlgItem(m_hwnd, kctidDetailsPropTabAbbr), m_ppropd->GetAbbr()); ::SetWindowText(::GetDlgItem(m_hwnd, kctidDetailsPropTabHelpF), m_ppropd->GetHelpFile()); ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabSort, BM_SETCHECK, m_ppropd->GetSorted(), 0); ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabDup, BM_SETCHECK, m_ppropd->GetDuplicates(), 0); if (m_ppropd->GetDepth() > 1) ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabHeir, BM_SETCHECK, BST_CHECKED, 0); else ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabHeir, BM_SETCHECK, BST_UNCHECKED, 0); // Initialize values for the Display combo box. HWND hwndCbo = ::GetDlgItem(m_hwnd, kctidDetailsPropTabDisp); StrAppBuf strb; strb.Load(kstidListsDetailsName); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidListsDetailsAN); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidListsDetailsAbbr); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); ::SendMessage(hwndCbo, CB_SETCURSEL , (WPARAM)m_ppropd->GetDispOpt(), 0); // Load "Writing System" Combo Box hwndCbo = ::GetDlgItem(m_hwnd, kctidDetailsPropTabWS); strb.Load(kstidWSAnals); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSVerns); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSAnalVerns); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSVernAnals); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); int iWSCboSel; int ws = m_ppropd->GetWs(); switch (ws) { case kwsAnals: iWSCboSel = 0; break; case kwsVerns: iWSCboSel = 1; break; case kwsAnalVerns: iWSCboSel = 2; break; case kwsVernAnals: iWSCboSel = 3; break; } ::SendMessage(hwndCbo, CB_SETCURSEL , (WPARAM)iWSCboSel, 0); m_fInitialized = true; return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- The hwnd has been attached. ----------------------------------------------------------------------------------------------*/ void HwMainWnd::PostAttach(void) { StrAppBuf strbT; // Holds temp string // Set the default caption text. strbT.Load(kstidHelloWorld); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars()); // This creates the main frame window and sets it as the current window. It also // creates the rebar and status bar. SuperClass::PostAttach(); const int rgrid[] = { kridTBarStd, kridHwTBarIns, kridHwTBarTools, kridHwTBarWnd, }; GetMenuMgr()->LoadToolBars(rgrid, SizeOfArray(rgrid)); // Create the menu bar. AfMenuBarPtr qmnbr; qmnbr.Create(); qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar"); m_vqtlbr.Push(qmnbr.Ptr()); // Create the toolbars. AfToolBarPtr qtlbr; qtlbr.Create(); qtlbr->Initialize(kridTBarStd, kridTBarStd, "Standard"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarIns, kridHwTBarIns, "Insert"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarTools, kridHwTBarTools, "Tools"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarWnd, kridHwTBarWnd, "Window"); m_vqtlbr.Push(qtlbr); // Load window settings. LoadSettings(NULL, false); g_app.AddCmdHandler(this, 1); m_qstbr->RestoreStatusText(); // Create the client window. const int kwidChild = 1000; WndCreateStruct wcs; wcs.InitChild("STATIC", m_hwnd, kwidChild); m_qwndHost.Create(); m_qwndHost->CreateAndSubclassHwnd(wcs); Assert(memcmp(&CLSID_SaCtrlEvent, &DIID__DSAEvents, isizeof(GUID)) == 0); CComCoClass<SaCtrlEvent>::CreateInstance(&m_qsce); IUnknownPtr qunk; CheckHr(AtlAxCreateControlEx(L"SA.SACtrl.1", m_qwndHost->Hwnd(), NULL, NULL, &qunk, DIID__DSAEvents, (IUnknown *)m_qsce.Ptr())); CheckHr(qunk->QueryInterface(DIID__DSA, (void **)&m_qctrl)); m_qsce->Init(this, m_qctrl); StrUni stu(L"baluchi.wav"); CheckHr(m_qctrl->put_WaveFile(stu.Bstr())); CheckHr(m_qctrl->raw_SetGraphs(GRAPH_MAGNITUDE, GRAPH_MAGNITUDE)); CheckHr(m_qctrl->put_ShowContextMenu(false)); CheckHr(m_qctrl->put_ShowCursorContextMenu(false)); ::ShowWindow(m_qwndHost->Hwnd(), SW_SHOW); g_app.AddCmdHandler(this, 1); }