示例#1
0
/*----------------------------------------------------------------------------------------------
	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);
}
示例#2
0
/*----------------------------------------------------------------------------------------------
	Handle window messages.
----------------------------------------------------------------------------------------------*/
bool IconComboCombo::FWndProc(uint wm, WPARAM wp, LPARAM lp, long & lnRet)
{
    if (wm == WM_GETDLGCODE)
    {
        lnRet = DLGC_BUTTON | DLGC_WANTARROWS;
        return true;
    }
    if (wm == WM_LBUTTONDOWN ||
            ((wm == WM_KEYDOWN || wm == WM_SYSKEYDOWN) && (wp == VK_DOWN || wp == VK_UP)))
    {
        // Show the popup icon chooser.
        RECT rc;
        ::GetWindowRect(m_hwnd, &rc);

        ::SetFocus(m_hwnd);

        //POINT pt = { rc.left, rc.bottom };
        WndCreateStruct wcs;
        wcs.InitChild(_T("STATIC"), m_hwnd, m_wid);
        ::SendMessage(GetParent(m_hwnd), WM_COMMAND, MAKEWPARAM(m_wid, CBN_DROPDOWN),
                      (LPARAM)m_hwnd);

        m_fPushed = true;
        IconComboPopupPtr qcop;
        qcop.Create();
// Need more args if we implement this fully.
//		qcop->DoPopup(wcs, m_pival, pt);
        m_fPushed = false;
    }
    return SuperClass::FWndProc(wm, wp, lp, lnRet);
}
示例#3
0
/*----------------------------------------------------------------------------------------------
	Make an edit box to allow editing. hwnd is the parent hwnd. rc is the size of the child
	window. Store the hwnd and return true.
	@param hwnd
	@param rc
	@param dxpCursor
	@param fTopCursor
	@param tpte
	@return true if successful

	TODO: To handle extra long field contents (and RTL?) the button cannot be a child of the
	edit control, because they must occupy seperate rectangles inside the field proper.
----------------------------------------------------------------------------------------------*/
bool AfDeFeEdBoxBut::BeginEdit(HWND hwnd, Rect &rc, int dxpCursor, bool fTopCursor,
	TptEditable tpte)
{
	if (!SuperClass::BeginEdit(hwnd, rc, dxpCursor, fTopCursor))
		return false;
	DeEditPtr qde;
	qde.Create();
	qde->SetEditable(tpte);
	qde->m_pdee = this;
	IActionHandler * pacth = BeginTempEdit();
	ILgWritingSystemFactoryPtr qwsf;
	GetLpInfo()->GetDbInfo()->GetLgWritingSystemFactory(&qwsf);
	AssertPtr(qwsf);
#if 1
	int nRet = 0;
	ComBool fRTL = FALSE;
	IWritingSystemPtr qws;
	CheckHr(qwsf->get_EngineOrNull(m_ws, &qws));
	if (qws)
		CheckHr(qws->get_RightToLeft(&fRTL));
	if (fRTL)
		qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_RIGHT | ES_AUTOHSCROLL, NULL, m_qtss,
			qwsf, m_ws, pacth);
	else
#endif
	qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_LEFT | ES_AUTOHSCROLL, NULL, m_qtss,
		qwsf, m_ws, pacth);
	m_hwnd = qde->Hwnd();
	Rect rcT(rc.left + 2, rc.top + 1, rc.right, rc.bottom);
	nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width(), rcT.Height(), true);
#if 99-99
	Rect rcParentClient;
	Rect rcParent;
	::GetClientRect(hwnd, &rcParentClient);
	::GetWindowRect(hwnd, &rcParent);
	Rect rcEdit;
	Rect rcEditClient;
	::GetWindowRect(m_hwnd, &rcEdit);
	::GetClientRect(m_hwnd, &rcEditClient);
#endif
	Rect rcTb;
	::GetClientRect(m_hwnd, &rcTb);
	rcTb.left = rcTb.right - 16;
	rcTb.bottom = rcTb.top + Min((int)rcTb.bottom - (int)rcTb.top, (int)kdxpButtonHeight);

	WndCreateStruct wcsButton;
	wcsButton.InitChild(_T("BUTTON"), m_hwnd, kwidEditChild);
	wcsButton.style |= WS_VISIBLE | BS_OWNERDRAW;
	wcsButton.SetRect(rcTb);

	DeButtonPtr qdb;
	qdb.Create();
	qdb->CreateAndSubclassHwnd(wcsButton);
	qdb->m_pdee = this;
	m_hwndButton = qdb->Hwnd();

#if 1-1
	// Resize the edit control window to exclude the button
	nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width() - 18, rcT.Height(), true);
#endif
	// Add text to the window.
	::SendMessage(m_hwnd, FW_EM_SETSTYLE, m_chrp.clrBack, (LPARAM)&m_qfsp->m_stuSty);
	::SendMessage(m_hwnd, EM_SETMARGINS, EC_RIGHTMARGIN | EC_LEFTMARGIN, MAKELPARAM(0, 18));
	::ShowWindow(m_hwnd, SW_SHOW);
	//::SendMessage(m_hwnd, WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), 0);
	// Foreground/background colors are set via WM_CTLCOLOREDIT in AfDeFeWnd.
	// Set cursor to desired offset.
	//int ich;
	//ich = LOWORD(::SendMessage(m_hwnd, EM_CHARFROMPOS, 0, dxpCursor));
	// For some reason the above always comes back with -1 instead of the correct index.
	// Is this a bug in TssEdit or am I doing something wrong?
	//::SendMessage(m_hwnd, EM_SETSEL, ich, ich);
	//::mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // Send LButton to place cursor in edit ctrl.
#if 99-99
	Rect rcEditNew;
	Rect rcEditNewClient;
	Rect rcBut;
	Rect rcButClient;
	::GetWindowRect(m_hwnd, &rcEditNew);
	::GetClientRect(m_hwnd, &rcEditNewClient);
	::GetWindowRect(m_hwndButton, &rcBut);
	::GetClientRect(m_hwndButton, &rcButClient);
#endif

	return true;
}
示例#4
0
/*----------------------------------------------------------------------------------------------
	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);
}