Esempio n. 1
0
int CSkinComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;

	//变量定义
	COMBOBOXINFO ComboBoxInfo;
	ComboBoxInfo.cbSize=sizeof(ComboBoxInfo);

	//绑定控件
	if (GetComboBoxInfo(&ComboBoxInfo)==TRUE)
	{
		if (ComboBoxInfo.hwndItem!=NULL) 
		{
			m_SkinComboBoxEdit.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxEdit.SubclassWindow(ComboBoxInfo.hwndItem);
		}

		if (ComboBoxInfo.hwndList!=NULL) 
		{
			m_SkinComboBoxList.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxList.SubclassWindow(ComboBoxInfo.hwndList);
		}
	}

	return 0;
}
Esempio n. 2
0
int CSkinComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;

	//变量定义
	COMBOBOXINFO ComboBoxInfo;
	ComboBoxInfo.cbSize=sizeof(ComboBoxInfo);

	//绑定控件
	if (GetComboBoxInfo(&ComboBoxInfo)==TRUE)
	{
		if (ComboBoxInfo.hwndItem!=NULL) 
		{
			m_SkinComboBoxEdit.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxEdit.SubclassWindow(ComboBoxInfo.hwndItem);
		}

		if (ComboBoxInfo.hwndList!=NULL) 
		{
			m_SkinComboBoxList.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxList.SubclassWindow(ComboBoxInfo.hwndList);
		}
	}

	//设置默认字体
	SetFont(CFont::FromHandle(RenderEngine->GetDeaultFont()));

	return 0;
}
static HWND getTextItem(HWND comboBox) {
	COMBOBOXINFO cbi;
	ZeroMemory(&cbi, sizeof(cbi));
	cbi.cbSize = sizeof(cbi);
	GetComboBoxInfo(comboBox, &cbi);
	return cbi.hwndItem;
}
Esempio n. 4
0
void CCherryComboBox::OnMouseLeave()
{
	COMBOBOXINFO comboBoxInfo = { sizeof(COMBOBOXINFO) };
	GetComboBoxInfo(&comboBoxInfo);

	// 버튼이 눌린 상태면
	if (/* comboBoxInfo.stateButton == STATE_SYSTEM_PRESSED || */ !m_bDropDown)
	{
		// Normal
		m_pCurrentImage = &m_images[STATUS_NORMAL];
	}

	if (m_bTracking)
	{
		TRACKMOUSEEVENT trackMouseEvent;
		trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT);
		trackMouseEvent.dwFlags = TME_CANCEL;
		trackMouseEvent.hwndTrack = GetSafeHwnd();
		trackMouseEvent.dwHoverTime = 1;
		_TrackMouseEvent(&trackMouseEvent);

		m_bTracking = FALSE;
	}

	m_bHover = FALSE;
	SetCurrentFont(GetNormalFont());

	if (m_bEnableHoverHandCursor)
		SetClassLong(GetSafeHwnd(), GCL_HCURSOR, (LONG)AfxGetApp()->LoadStandardCursor(IDC_ARROW));

	Invalidate(FALSE);

	CComboBox::OnMouseLeave();
}
Esempio n. 5
0
void NewGUI_ComboBox_GetInfo(HWND hComboBox, HWND* phComboBox,
	HWND* phEditBox, HWND* phListBox)
{
	COMBOBOXINFO cbi;
	ZeroMemory(&cbi, sizeof(COMBOBOXINFO));
	cbi.cbSize = sizeof(COMBOBOXINFO);
	VERIFY(GetComboBoxInfo(hComboBox, &cbi));

	if(phComboBox != NULL) *phComboBox = cbi.hwndCombo;
	if(phEditBox != NULL) *phEditBox = cbi.hwndItem;
	if(phListBox != NULL) *phListBox = cbi.hwndList;
}
Esempio n. 6
0
wyBool  
TabMessage::Create()
{
    wyWChar* items[] = {
        _(L"All"),
        _(L"Queries with errors"),
        _(L"Queries with warnings"),
        _(L"Queries with errors/warnings"),
        _(L"Queries with result set"), 
        _(L"Queries without result set")
    };

    wyInt32 count, i, width = 0;
    HDC     hdc;
    HFONT   hfont = GetStockFont(DEFAULT_GUI_FONT);
    RECT    rect = {0};
    COMBOBOXINFO cbinfo = {0};

    CreateQueryMessageEdit(m_hwndparent, m_pmdi);
    m_hwndcombo = CreateWindowEx(0, L"combobox", L"", WS_CHILD | CBS_DROPDOWNLIST | WS_VISIBLE, 
        0, 0, 0, 0, m_hwndparent, (HMENU)IDC_TOOLCOMBO, (HINSTANCE)GetModuleHandle(0), NULL);
    SendMessage(m_hwndcombo, WM_SETFONT, (WPARAM)hfont, 0);
    cbinfo.cbSize = sizeof(COMBOBOXINFO);
    GetComboBoxInfo(m_hwndcombo, &cbinfo);
    SetWindowLongPtr(cbinfo.hwndList, GWLP_USERDATA, (LONG_PTR)this);
    //m_origlistproc = (WNDPROC)SetWindowLongPtr(cbinfo.hwndList, GWLP_WNDPROC, (LONG)ComboListProc);
   
    count = sizeof(items)/sizeof(items[0]);
    hdc = GetDC(m_hwndcombo);
    hfont = SelectFont(hdc, hfont);

    for(i = 0; i < count; ++i)
    {
        SendMessage(m_hwndcombo, CB_ADDSTRING, 0, (LPARAM)items[i]);
        DrawText(hdc, items[i], -1, &rect, DT_CALCRECT | DT_NOPREFIX);

        if(rect.right > width)
        {
            width = rect.right;
        }
    }

    SelectFont(hdc, hfont);
    ReleaseDC(m_hwndcombo, hdc);
    SendMessage(m_hwndcombo, CB_SETCURSEL, 0, 0);
    GetWindowRect(m_hwndcombo, &rect);
    SetWindowPos(m_hwndcombo, NULL, 0, 0, width + (cbinfo.rcButton.right - cbinfo.rcButton.left) + 10, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE);
    //SendMessage(m_hwndcombo, CB_SETDROPPEDWIDTH, width + 10, 0);
	return wyTrue;
}
Esempio n. 7
0
void CInPlaceList::OnKillFocus(CWnd* pNewWnd)
{
    CComboBox::OnKillFocus(pNewWnd);

    COMBOBOXINFO cbInfo;
    cbInfo.cbSize = sizeof(COMBOBOXINFO);
    GetComboBoxInfo(&cbInfo);

    HWND hwnd = pNewWnd->GetSafeHwnd();
    if (cbInfo.hwndCombo == hwnd || cbInfo.hwndItem == hwnd || cbInfo.hwndList == hwnd)
        return;

    // Only end editing on change of focus if we're using the CBS_DROPDOWNLIST style
    EndEdit();
}
// Function to create Combo Box as child of Custom Combo Box
wyBool
CCustomComboBox::CreateCtrls(HWND hwnd, LPARAM lParam)
{
    CREATESTRUCT    *ctst = (CREATESTRUCT *)lParam;
    wyInt32         ret = 0;
    DWORD           style = CBS_DROPDOWN | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP | WS_CHILD | WS_CLIPCHILDREN;
    HFONT           hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
    m_id            = (wyInt32)ctst->hMenu;
    m_hwndParent    = ctst->hwndParent;
    m_hwnd          = hwnd;

    if((ctst->style &  CBS_OWNERDRAWFIXED))
        style |=  CBS_OWNERDRAWFIXED;
    m_hwndCombo     = CreateWindowExW(NULL, WC_COMBOBOX, NULL, 
                                style, 
                                0, 0, ctst->cx,ctst->cy, 
                                hwnd, (HMENU)IDC_COMBOCUSTOM, GetModuleHandle(NULL), 0);
    
    if(m_hwndCombo == NULL)
        return wyFalse;

    SendMessage(m_hwndCombo, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
    
    ShowWindow(m_hwndCombo, SW_SHOW);

    ret = GetComboBoxInfo(m_hwndCombo, &m_cbif);

    m_editRect.bottom   = m_cbif.rcItem.bottom;
    m_editRect.right    = m_cbif.rcItem.right;
    m_editRect.left     = m_cbif.rcItem.left;
    m_editRect.top      = m_cbif.rcItem.top;
    
    if(ctst->style & WS_DISABLED)
    {
        SendMessage(hwnd, WM_ENABLE, FALSE, NULL);
    }

    SetWindowLongPtr(m_hwndCombo, GWLP_USERDATA, (LONG_PTR) this);
    m_origComboCtrlProc = (WNDPROC)SetWindowLongPtr(m_hwndCombo, GWLP_WNDPROC, (LONG_PTR) CCustomComboBox::ComboCtrlProc);
    
    SetWindowLongPtr(m_cbif.hwndItem, GWLP_USERDATA, (LONG_PTR)this);
    m_origEditCtrlProc = (WNDPROC)SetWindowLongPtr(m_cbif.hwndItem, GWLP_WNDPROC, (LONG_PTR) CCustomComboBox::EditCtrlProc);

    return wyTrue;
}
/**
   Adjusting height of dropped list of cbHwnd combobox to fit
   itemsCount items, but not more than MAX_VISIBLE_CB_ITEMS
   ComboBox_SetMinVisible not used because it was introduced in XP.
*/
int adjustDropdownHeight(HWND cbHwnd, unsigned int itemsCount)
{
  COMBOBOXINFO  dbcbinfo;
  RECT          ddRect;
  int           newHeight = 0;

  dbcbinfo.cbSize= sizeof(COMBOBOXINFO);
  ComboBox_GetDroppedControlRect(cbHwnd, &ddRect);
  newHeight= ddRect.bottom - ddRect.top;

  if ( GetComboBoxInfo(cbHwnd, &dbcbinfo) )
  {
    itemsCount= itemsCount < 1 ? 1 : (itemsCount > MAX_VISIBLE_CB_ITEMS
                                      ? MAX_VISIBLE_CB_ITEMS
                                      : itemsCount );

    /* + (itemsCount - 1) - 1 pixel spaces between list items */
    newHeight= itemsCount*ComboBox_GetItemHeight(cbHwnd) + (itemsCount - 1);
    MoveWindow(dbcbinfo.hwndList, ddRect.left, ddRect.top, ddRect.right-ddRect.left, newHeight, FALSE);
  }

  return newHeight;
}
Esempio n. 10
0
void CSkinComboBox::PreSubclassWindow()
{
	//变量定义
	COMBOBOXINFO ComboBoxInfo;
	ComboBoxInfo.cbSize=sizeof(ComboBoxInfo);

	//绑定控件
	if (GetComboBoxInfo(&ComboBoxInfo)==TRUE)
	{
		if (ComboBoxInfo.hwndItem!=NULL) 
		{
			m_SkinComboBoxEdit.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxEdit.SubclassWindow(ComboBoxInfo.hwndItem);
		}

		if (ComboBoxInfo.hwndList!=NULL) 
		{
			m_SkinComboBoxList.SetOwnerWnd(GetSafeHwnd());
			m_SkinComboBoxList.SubclassWindow(ComboBoxInfo.hwndList);
		}
	}

	CComboBox::PreSubclassWindow();
}
Esempio n. 11
0
static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	OptionsPageData *opd;
	OptionsDlgData *dat = (OptionsDlgData*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
	HWND hwndTree = GetDlgItem(hdlg, IDC_PAGETREE);

	switch (message) {
	case WM_CTLCOLORSTATIC:
		switch (GetDlgCtrlID((HWND)lParam)) {
		case IDC_WHITERECT:
		case IDC_KEYWORD_FILTER:
			SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
			return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
		}
		break;

	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);

		if (!ServiceExists(MS_MODERNOPT_SHOW))
			ShowWindow(GetDlgItem(hdlg, IDC_MODERN), FALSE);
		{
			PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam;
			OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage;

			COMBOBOXINFO cbi;
			cbi.cbSize = sizeof(COMBOBOXINFO);
			GetComboBoxInfo(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
			mir_subclassWindow(cbi.hwndItem, OptionsFilterSubclassProc);

			if (IsAeroMode()) {
				mir_subclassWindow(cbi.hwndCombo, AeroPaintSubclassProc);
				mir_subclassWindow(cbi.hwndItem, AeroPaintSubclassProc);
			}

			Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", "");
			Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS);
			EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
			dat = new OptionsDlgData;
			SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat);
			SetWindowText(hdlg, psh->pszCaption);

			LOGFONT lf;
			dat->hBoldFont = (HFONT)SendDlgItemMessage(hdlg, IDC_APPLY, WM_GETFONT, 0, 0);
			GetObject(dat->hBoldFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;
			dat->hBoldFont = CreateFontIndirect(&lf);

			dat->hPluginLoad = HookEventMessage(ME_SYSTEM_MODULELOAD, hdlg, HM_MODULELOAD);
			dat->hPluginUnload = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, hdlg, HM_MODULEUNLOAD);
			dat->currentPage = -1;

			ptrT lastPage, lastGroup, lastTab;
			if (ood->pszPage == NULL) {
				lastPage = db_get_tsa(NULL, "Options", "LastPage");

				if (ood->pszGroup == NULL)
					lastGroup = db_get_tsa(NULL, "Options", "LastGroup");
				else
					lastGroup = mir_a2t(ood->pszGroup);
			}
			else {
				lastPage = mir_a2t(ood->pszPage);
				lastGroup = mir_a2t(ood->pszGroup);
			}

			if (ood->pszTab == NULL)
				lastTab = db_get_tsa(NULL, "Options", "LastTab");
			else
				lastTab = mir_a2t(ood->pszTab);

			OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp;
			for (UINT i = 0; i < psh->nPages; i++, odp++) {
				opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
				if (!LoadOptionsPage(odp, opd)) {
					mir_free(opd);
					continue;
				}
				dat->arOpd.insert(opd);

				if (!lstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup))
					if ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab))
						dat->currentPage = (int)i;
			}

			GetWindowRect(GetDlgItem(hdlg, IDC_STNOPAGE), &dat->rcDisplay);
			MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcDisplay, 2);

			// Add an item to count in height
			TCITEM tie;
			tie.mask = TCIF_TEXT | TCIF_IMAGE;
			tie.iImage = -1;
			tie.pszText = _T("X");
			TabCtrl_InsertItem(GetDlgItem(hdlg, IDC_TAB), 0, &tie);

			GetWindowRect(GetDlgItem(hdlg, IDC_TAB), &dat->rcTab);
			MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcTab, 2);
			TabCtrl_AdjustRect(GetDlgItem(hdlg, IDC_TAB), FALSE, &dat->rcTab);

			FillFilterCombo(hdlg, dat);
			PostMessage(hdlg, DM_REBUILDPAGETREE, 0, 0);
		}
		return TRUE;

	case DM_REBUILDPAGETREE:
		RebuildPageTree(hdlg, dat);
		break;

	case HM_MODULELOAD:
		LoadOptionsModule(hdlg, dat, (HINSTANCE)lParam);
		break;

	case HM_MODULEUNLOAD:
		UnloadOptionsModule(hdlg, dat, (HINSTANCE)lParam);
		break;

	case PSM_CHANGED:
		EnableWindow(GetDlgItem(hdlg, IDC_APPLY), TRUE);

		opd = dat->getCurrent();
		if (opd)
			opd->changed = 1;

		return TRUE;

	case PSM_GETBOLDFONT:
		SetWindowLongPtr(hdlg, DWLP_MSGRESULT, (LONG_PTR)dat->hBoldFont);
		return TRUE;

	case WM_NOTIFY:
		switch (wParam) {
		case IDC_TAB:
		case IDC_PAGETREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_ITEMEXPANDING:
				SetWindowLongPtr(hdlg, DWLP_MSGRESULT, FALSE);
				return TRUE;

			case TCN_SELCHANGING:
			case TVN_SELCHANGING:
				opd = dat->getCurrent();
				if (opd && opd->hwnd != NULL) {
					PSHNOTIFY pshn;
					pshn.hdr.code = PSN_KILLACTIVE;
					pshn.hdr.hwndFrom = dat->arOpd[dat->currentPage]->hwnd;
					pshn.hdr.idFrom = 0;
					pshn.lParam = 0;
					if (SendMessage(dat->arOpd[dat->currentPage]->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) {
						SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE);
						return TRUE;
					}
				}
				break;

			case TCN_SELCHANGE:
			case TVN_SELCHANGED:
				ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_HIDE);

				opd = dat->getCurrent();
				if (opd && opd->hwnd != NULL)
					ShowWindow(opd->hwnd, SW_HIDE);

				if (wParam != IDC_TAB) {
					TVITEM tvi;
					tvi.hItem = dat->hCurrentPage = TreeView_GetSelection(hwndTree);
					if (tvi.hItem == NULL) {
						ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
						break;
					}

					tvi.mask = TVIF_HANDLE | TVIF_PARAM;
					TreeView_GetItem(hwndTree, &tvi);
					dat->currentPage = tvi.lParam;
					ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
				}
				else {
					TCITEM tie;
					tie.mask = TCIF_PARAM;
					TabCtrl_GetItem(GetDlgItem(hdlg, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hdlg, IDC_TAB)), &tie);
					dat->currentPage = tie.lParam;

					TVITEM tvi;
					tvi.hItem = dat->hCurrentPage;
					tvi.mask = TVIF_PARAM;
					tvi.lParam = dat->currentPage;
					TreeView_SetItem(hwndTree, &tvi);
				}

				opd = dat->getCurrent();
				if (opd == NULL) {
					ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_SHOW);
					break;
				}
				if (opd->hwnd == NULL) {
					opd->hwnd = CreateDialogIndirectParamA(opd->hInst, opd->pTemplate, hdlg, opd->dlgProc, opd->dwInitParam);
					if (opd->flags & ODPF_BOLDGROUPS)
						EnumChildWindows(opd->hwnd, BoldGroupTitlesEnumChildren, (LPARAM)dat->hBoldFont);

					RECT rcPage;
					GetClientRect(opd->hwnd, &rcPage);
					int w = opd->width = rcPage.right;
					int h = opd->height = rcPage.bottom;

					RECT rc;
					GetWindowRect(opd->hwnd, &rc);

					opd->offsetX = 0;
					opd->offsetY = 0;

					opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage);
					if (opd->insideTab) {
						SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcTab.left + dat->rcTab.right - w) >> 1, dat->rcTab.top, w, h, 0);
						ThemeDialogBackground(opd->hwnd, TRUE);
					}
					else {
						SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcDisplay.left + dat->rcDisplay.right - w) >> 1, (dat->rcDisplay.top + dat->rcDisplay.bottom - h) >> 1, w, h, 0);
						ThemeDialogBackground(opd->hwnd, FALSE);
					}
				}

				if (wParam != IDC_TAB) {
					opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage);
					if (opd->insideTab) {
						// Make tabbed pane
						int pages = 0, sel = 0;
						HWND hwndTab = GetDlgItem(hdlg, IDC_TAB);
						TabCtrl_DeleteAllItems(hwndTab);

						TCITEM tie;
						tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
						tie.iImage = -1;
						for (int i = 0; i < dat->arOpd.getCount(); i++) {
							if (!CheckPageShow(hdlg, dat, i))
								continue;

							OptionsPageData *p = dat->arOpd[i];
							if (lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup))
								continue;

							tie.pszText = TranslateTH(p->hLangpack, p->ptszTab);
							tie.lParam = i;
							TabCtrl_InsertItem(hwndTab, pages, &tie);
							if (!lstrcmp(opd->ptszTab, p->ptszTab))
								sel = pages;
							pages++;
						}
						TabCtrl_SetCurSel(hwndTab, sel);
						ShowWindow(hwndTab, opd->insideTab ? SW_SHOW : SW_HIDE);
					}

					if (opd->insideTab)
						ThemeDialogBackground(opd->hwnd, TRUE);
					else
						ThemeDialogBackground(opd->hwnd, FALSE);
				}

				ShowWindow(opd->hwnd, SW_SHOW);
				if (((LPNMTREEVIEW)lParam)->action == TVC_BYMOUSE)
					PostMessage(hdlg, DM_FOCUSPAGE, 0, 0);
				else
					SetFocus(hwndTree);
			}
Esempio n. 12
0
CInPlaceList::CInPlaceList(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
                           int nRow, int nColumn,
                           Strings& Items,
                           CString sInitText,
                           UINT nFirstChar)
{
    m_nNumLines = 2;
    m_sInitText = sInitText;
    m_nRow		= nRow;
    m_nCol      = nColumn;
    m_nLastChar = 0;
    m_bEdit = FALSE;

    // Create the combobox
    DWORD dwComboStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
                         CBS_AUTOHSCROLL | dwStyle;

    if (!Create(dwComboStyle, rect, pParent, nID))
        return;

    COMBOBOXINFO cbInfo;
    cbInfo.cbSize = sizeof(COMBOBOXINFO);
    GetComboBoxInfo(&cbInfo);

    m_edit.SubclassWindow(cbInfo.hwndItem);
    m_ListBox.SubclassWindow(cbInfo.hwndList);

    // Add the strings
    for (size_t i = 0; i < Items.size(); i++)
        AddString(Items[i]);

    // Get the maximum width of the text strings
    int nMaxLength = 0;
    CClientDC dc(GetParent());
    CFont* pOldFont = dc.SelectObject(pParent->GetFont());

    for (size_t i = 0; i < Items.size(); i++)
        nMaxLength = max(nMaxLength, dc.GetTextExtent(Items[i]).cx);

    nMaxLength += (::GetSystemMetrics(SM_CXVSCROLL) + dc.GetTextExtent(_T(" ")).cx*2);
    dc.SelectObject(pOldFont);

    // Resize the edit window and the drop down window

    SetFont(pParent->GetFont());

    SetDroppedWidth(nMaxLength);
    SetHorizontalExtent(0); // no horz scrolling

    // Set the initial text to m_sInitText
    SetWindowText(m_sInitText);		// No text selected, so restore what was there before
    ShowDropDown();

    SetFocus();

    // Added by KiteFly. When entering DBCS chars into cells the first char was being lost
    // SenMessage changed to PostMessage (John Lagerquist)
    switch (nFirstChar)
    {
    case VK_RETURN:
        break;

    default:
        PostMessage(WM_CHAR, nFirstChar);
    }
}
Esempio n. 13
0
INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{	
	switch(msg) {
	case WM_INITDIALOG:
		{
			int startupmode,exitmode;
			COMBOBOXINFO cbi={0};
			cbi.cbSize = sizeof(cbi);

			opses_count=0;
			g_opHdlg=hdlg;
			bOptionsInit=TRUE;
			TranslateDialogDefault(hdlg);
			hMarked = Skin_GetIconByHandle(iconList[1].hIcolib);
			hNotMarked = Skin_GetIconByHandle(iconList[2].hIcolib);

			hIcon=(bChecked=IsMarkedUserDefSession(opses_count))?hMarked:hNotMarked;

			SetDlgItemInt(hdlg, IDC_TRACK,ses_limit=db_get_b(0, MODNAME, "TrackCount", 10), FALSE);
			SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
			SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE));

			SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
			SetDlgItemInt(hdlg, IDC_STARTDELAY, db_get_w(NULL, MODNAME, "StartupModeDelay", 1500), FALSE);
			startupmode = db_get_b(NULL, MODNAME, "StartupMode", 3);
			exitmode = db_get_b(NULL, MODNAME, "ShutdownMode", 2);

			g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0);
			g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0);
			g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1);
			g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0);

			CheckDlgButton(hdlg,IDC_EXCLHIDDEN,g_bExclHidden?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_LASTHIDDENWARN,g_bWarnOnHidden?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_WARNINGS,g_bOtherWarnings?BST_CHECKED:BST_UNCHECKED);
			CheckDlgButton(hdlg,IDC_CRASHRECOVERY,g_bCrashRecovery?BST_CHECKED:BST_UNCHECKED);


			if (startupmode == 1)
				CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
			else if (startupmode == 3) {
				CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
				CheckDlgButton(hdlg,IDC_CHECKLAST,BST_CHECKED);
			}
			else if (startupmode == 2) {
				CheckDlgButton(hdlg,IDC_RLOADLAST,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			}
			else if (startupmode == 0)	{
				CheckDlgButton(hdlg,IDC_RNOTHING,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			}

			if (exitmode == 0) {
				CheckDlgButton(hdlg,IDC_REXDSAVE,BST_CHECKED);
				EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE);
			}
			else if (exitmode == 1)
				CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED);
			else if (exitmode == 2)
				CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED);

			LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
			if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
				SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
				if (!OpLoadSessionContacts(0,opses_count))
					EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}

			GetComboBoxInfo(GetDlgItem(hdlg,IDC_LIST),&cbi);
			mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc);

			hComboBoxEdit=cbi.hwndItem;
			hComboBox=cbi.hwndCombo;

			SetWindowPos( hComboBoxEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );

			bOptionsInit=FALSE;
		}
		break;

	case WM_CTLCOLORLISTBOX:
		switch(GetDlgCtrlID((HWND) lparam)) {
		case IDC_OPCLIST:
			SetBkMode((HDC) wparam, TRANSPARENT);
			return (BOOL) CreateSolidBrush(GetSysColor(COLOR_3DFACE));
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lparam)->code) {
		case PSN_APPLY:
			{
				int iDelay=GetDlgItemInt(hdlg, IDC_STARTDELAY,NULL, FALSE);
				db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
				db_set_b(0, MODNAME, "TrackCount", (BYTE)(ses_limit=GetDlgItemInt(hdlg, IDC_TRACK,NULL, FALSE)));
				if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
					db_set_b(NULL, MODNAME, "ShutdownMode", 2);
				else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
					db_set_b(NULL, MODNAME, "ShutdownMode", 0);
				else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
					db_set_b(NULL, MODNAME, "ShutdownMode", 1);

				if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
					if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
						db_set_b(NULL, MODNAME, "StartupMode", 1);
					else
						db_set_b(NULL, MODNAME, "StartupMode", 3);
				}
				else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
					db_set_b(NULL, MODNAME, "StartupMode", 2);
				else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
					db_set_b(NULL, MODNAME, "StartupMode", 0);

				db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
				db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
				db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
				db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
			}
			return 1;

		case CLN_CHECKCHANGED:
			if (((LPNMHDR)lparam)->idFrom  == IDC_EMCLIST)
			{
				int iSelection = (int)((NMCLISTCONTROL *)lparam)->hItem;
				HANDLE hContact = db_find_first();
				for ( ; hContact; hContact = db_find_next(hContact))
					if (SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection)
						break;
				if (hContact)
					EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				else
					EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
			}
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wparam)) {
		case IDC_LIST:
			switch(HIWORD(wparam)) {
			case CBN_EDITCHANGE:
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				bSesssionNameChanged=TRUE;
				break;

			case CBN_SELCHANGE:
				{
					HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
					int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
					if (index != CB_ERR) {
						opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
						SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
						if (IsMarkedUserDefSession(opses_count)) {
							hIcon=hMarked;
							bChecked=TRUE;
							RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
						}
						else {
							hIcon=hNotMarked;
							bChecked=FALSE;
							RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
						}
						OpLoadSessionContacts(0,opses_count);
						if (!hOpClistControl)
							EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
						else {
							for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
								SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,0);

							for (int i=0 ; session_list_t[i] > 0; i++) {
								HANDLE hContact = (HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
								SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact, 1);
							}
							EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
						}
					}
				}break;
			}break;

		case IDC_EDIT:
			if (!hOpClistControl) {
				ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_HIDE);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
				//EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
				SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("View"));
				hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE, _T(CLISTCONTROL_CLASS), _T(""),
					WS_TABSTOP |WS_VISIBLE | WS_CHILD , 
					14,198,161,163,hdlg, (HMENU)IDC_EMCLIST, hinstance, 0);

				SetWindowLongPtr(hOpClistControl, GWL_STYLE,
					GetWindowLongPtr(hOpClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
				SendMessage(hOpClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);

				SendMessage(hOpClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0);

				for (int i=0 ; session_list_t[i] > 0; i++) {
					HANDLE hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
					SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1);
				}
			}
			else {
				ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_SHOWNA);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
				SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("Edit"));
				DestroyWindow(hOpClistControl);
				hOpClistControl=NULL;
			}
			break;

		case IDC_SAVE:
			{
				int i=0;
				for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
					BYTE res =(BYTE)SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_GETCHECKMARK,
						SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
					if (res) {
						SetSessionMark(hContact,1,'1',opses_count);
						SetInSessionOrder(hContact,1,opses_count,i);
						i++;
					}
					else {
						SetSessionMark(hContact,1,'0',opses_count);
						SetInSessionOrder(hContact,1,opses_count,0);
					}
				}
				if (bSesssionNameChanged) {
					if (GetWindowTextLength(hComboBoxEdit)) {
						TCHAR szUserSessionName[MAX_PATH]={'\0'};
						GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName));
						RenameUserDefSession(opses_count,szUserSessionName);
						SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT ,0,0);
						LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
					}
					bSesssionNameChanged=FALSE;
				}
				EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
			}
			break;

		case IDC_DEL:
			DelUserDefSession(opses_count);

			SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
			SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);

			LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);

			opses_count=0;

			if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
				SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
				if (!OpLoadSessionContacts(0,opses_count))
					EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}
			else {
				EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE);
				EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
			}
			break;

		case IDC_STARTDIALOG:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_RLOADLAST:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_RNOTHING:
			EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
			EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXSAVE:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXDSAVE:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;

		case IDC_REXASK:
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE);
			EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE);
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
			break;
		}

		if (HIWORD(wparam) == CBN_DROPDOWN&&!hOpClistControl) {
			SendMessage(hComboBoxEdit,EM_SETSEL ,0,0);
			SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
			SendMessage(hComboBoxEdit,WM_KILLFOCUS ,0,0);
			HideCaret(hComboBoxEdit);
		}

		if ((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam) == IDC_LIST)&&!hOpClistControl) {
			SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
			HideCaret(hComboBoxEdit);
		}

		if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam)!=EN_CHANGE || (HWND)lparam != GetFocus()))
			return 0;

		if (lparam&&!bOptionsInit&&(HIWORD(wparam) == BN_CLICKED)&& (GetFocus() == (HWND)lparam)
			&&((LOWORD(wparam) == IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY))))
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);

		return 0;

	case WM_CLOSE:
		EndDialog(hdlg,0);
		return 0;
	}
	return 0;
}
Esempio n. 14
0
DcxComboEx::DcxComboEx( UINT ID, DcxDialog * p_Dialog, HWND mParentHwnd, RECT * rc, TString & styles ) 
: DcxControl( ID, p_Dialog )
{
	LONG Styles = 0, ExStyles = 0;
	BOOL bNoTheme = FALSE;
	this->parseControlStyles( styles, &Styles, &ExStyles, &bNoTheme );

	this->m_Hwnd = CreateWindowEx(	
		ExStyles,
		DCX_COMBOEXCLASS,
		NULL,
		WS_CHILD | CBS_AUTOHSCROLL | Styles,
		rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top,
		mParentHwnd,
		(HMENU) ID,
		GetModuleHandle(NULL),
		NULL);

	if (!IsWindow(this->m_Hwnd))
		throw "Unable To Create Window";

	if ( bNoTheme ) {
		Dcx::UXModule.dcxSetWindowTheme( this->m_Hwnd , L" ", L" " );
		//SendMessage( this->m_Hwnd, CBEM_SETWINDOWTHEME, NULL, (LPARAM)(LPCWSTR)L" "); // do this instead?
	}

	this->m_EditHwnd = (HWND) this->getEditControl( );

	if ( IsWindow( this->m_EditHwnd ) ) {
		if ( bNoTheme )
			Dcx::UXModule.dcxSetWindowTheme( this->m_EditHwnd , L" ", L" " );

		try {
			LPDCXCOMBOEXEDIT lpce = new DCXCOMBOEXEDIT;

			lpce->cHwnd = this->m_Hwnd;
			lpce->pHwnd = mParentHwnd;

			//SetWindowLong( this->m_EditHwnd, GWL_STYLE, GetWindowLong( this->m_EditHwnd, GWL_STYLE ));// | ES_AUTOHSCROLL );
			lpce->OldProc = SubclassWindow( this->m_EditHwnd, DcxComboEx::ComboExEditProc );
			SetWindowLongPtr( this->m_EditHwnd, GWLP_USERDATA, (LONG) lpce );
		}
		catch ( std::bad_alloc ) {
			DestroyWindow(this->m_Hwnd);
			throw "Unable to Allocate Memory";
		}
	}

	HWND combo = (HWND)SendMessage(this->m_Hwnd,CBEM_GETCOMBOCONTROL,0,0);
	if (IsWindow(combo)) {
		if (bNoTheme)
			Dcx::UXModule.dcxSetWindowTheme( combo , L" ", L" " );

		COMBOBOXINFO cbi = { 0 };
		cbi.cbSize = sizeof(cbi);
		GetComboBoxInfo(combo, &cbi);

		if (styles.istok("sort")) { // doesnt work atm.
			if (IsWindow(cbi.hwndList)) {
				AddStyles(cbi.hwndList, GWL_STYLE, LBS_SORT);
			}
		}
		if (styles.istok("hscroll")) {
			//if (IsWindow(cbi.hwndCombo))
			//AddStyles(cbi.hwndCombo, GWL_STYLE, WS_HSCROLL);
			if (IsWindow(cbi.hwndList))
				AddStyles(cbi.hwndList, GWL_STYLE, WS_HSCROLL);
		}
	}
	//if (p_Dialog->getToolTip() != NULL) {
	//	if (styles.istok("tooltips")) {
	//		this->m_ToolTipHWND = p_Dialog->getToolTip();
	//		AddToolTipToolInfo(this->m_ToolTipHWND, this->m_Hwnd);
	//		AddToolTipToolInfo(this->m_ToolTipHWND, this->m_EditHwnd);
	//	}
	//}

	this->setControlFont( GetStockFont( DEFAULT_GUI_FONT ), FALSE );
	this->registreDefaultWindowProc( );
	SetProp( this->m_Hwnd, "dcx_cthis", (HANDLE) this );

	DragAcceptFiles(this->m_Hwnd, TRUE);

	// fix bug with disabled creation
	// todo: fix this properly
	if (Styles & WS_DISABLED) {
		EnableWindow(this->m_Hwnd, TRUE);
		EnableWindow(this->m_Hwnd, FALSE);
	}
}
Esempio n. 15
0
static int winListMapMethod(Ihandle* ih)
{
  char* class_name;
  DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS,
      dwExStyle = WS_EX_CLIENTEDGE;

  if (!ih->parent)
    return IUP_ERROR;

  if (ih->data->is_dropdown || ih->data->has_editbox)
  {
    class_name = "COMBOBOX";

    dwStyle |= CBS_NOINTEGRALHEIGHT;

    if (ih->data->is_dropdown)
      dwStyle |= WS_VSCROLL|WS_HSCROLL;
    else if (ih->data->sb)
    {
      dwStyle |= WS_VSCROLL|WS_HSCROLL;

      if (!iupAttribGetBoolean(ih, "AUTOHIDE"))
        dwStyle |= CBS_DISABLENOSCROLL;
    }

    if (ih->data->has_editbox)
    {
      dwStyle |= CBS_AUTOHSCROLL;

      if (ih->data->is_dropdown)
        dwStyle |= CBS_DROPDOWN;  /* hidden-list+edit */
      else
        dwStyle |= CBS_SIMPLE;  /* visible-list+edit */
    }
    else
      dwStyle |= CBS_DROPDOWNLIST;  /* hidden-list */

    if (iupAttribGetBoolean(ih, "SORT"))
      dwStyle |= CBS_SORT;
  }
  else
  {
    class_name = "LISTBOX";

    dwStyle |= LBS_NOINTEGRALHEIGHT|LBS_NOTIFY;

    if (ih->data->is_multiple)
      dwStyle |= LBS_EXTENDEDSEL;

    if (ih->data->sb)
    {
      dwStyle |= WS_VSCROLL|WS_HSCROLL;

      if (!iupAttribGetBoolean(ih, "AUTOHIDE"))
        dwStyle |= LBS_DISABLENOSCROLL;
    }

    if (iupAttribGetBoolean(ih, "SORT"))
      dwStyle |= LBS_SORT;
  }

  if (iupAttribGetBoolean(ih, "CANFOCUS"))
    dwStyle |= WS_TABSTOP;

  if (!iupwinCreateWindowEx(ih, class_name, dwExStyle, dwStyle))
    return IUP_ERROR;

  /* Custom Procedure */
  IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winListProc);

  /* Process background color */
  IupSetCallback(ih, "_IUPWIN_CTLCOLOR_CB", (Icallback)winListCtlColor);

  /* Process WM_COMMAND */
  IupSetCallback(ih, "_IUPWIN_COMMAND_CB", (Icallback)winListWmCommand);

  if (ih->data->is_dropdown || ih->data->has_editbox)
  {
    COMBOBOXINFO boxinfo;

    ZeroMemory(&boxinfo, sizeof(COMBOBOXINFO));
    boxinfo.cbSize = sizeof(COMBOBOXINFO);

    GetComboBoxInfo(ih->handle, &boxinfo);

    iupwinHandleAdd(ih, boxinfo.hwndList);
    iupAttribSetStr(ih, "_IUPWIN_LISTBOX", (char*)boxinfo.hwndList);

    /* subclass the list box. */
    IupSetCallback(ih, "_IUPWIN_LISTOLDPROC_CB", (Icallback)GetWindowLongPtr(boxinfo.hwndList, GWLP_WNDPROC));
    SetWindowLongPtr(boxinfo.hwndList, GWLP_WNDPROC, (LONG_PTR)winListComboListWinProc);

    if (ih->data->has_editbox)
    {
      iupwinHandleAdd(ih, boxinfo.hwndItem);
      iupAttribSetStr(ih, "_IUPWIN_EDITBOX", (char*)boxinfo.hwndItem);

      /* subclass the edit box. */
      IupSetCallback(ih, "_IUPWIN_EDITOLDPROC_CB", (Icallback)GetWindowLongPtr(boxinfo.hwndItem, GWLP_WNDPROC));
      SetWindowLongPtr(boxinfo.hwndItem, GWLP_WNDPROC, (LONG_PTR)winListEditWinProc);

      /* set defaults */
      SendMessage(ih->handle, CB_LIMITTEXT, 0, 0L);
    }
  }

  /* configure for DRAG&DROP */
  if (IupGetCallback(ih, "DROPFILES_CB"))
    iupAttribSetStr(ih, "DRAGDROP", "YES");

  IupSetCallback(ih, "_IUP_XY2POS_CB", (Icallback)winListConvertXYToPos);

  iupListSetInitialItems(ih);

  return IUP_NOERROR;
}
Esempio n. 16
0
LRESULT dsp_preset_switcher::on_message( HWND parent_wnd , UINT msg , WPARAM wp , LPARAM lp )
{
	switch( msg )
	{
		case WM_CREATE:
		{
			if( wnd_my_combo_box != NULL )
			{
				console::printf( CONSOLE_HEADER "Error: wnd_my_combo_box != NULL" );
				return -1;
			}
			if( ui_hfont != NULL )
			{
				console::printf( CONSOLE_HEADER "Error: ui_hfont != NULL" );
				return -1;
			}

			// get columns UI font
			ui_hfont = uCreateIconFont();
			if( ui_hfont == NULL )
			{
				console::printf( CONSOLE_HEADER "uCreateIconFont() failed" );
				return -1;
			}

			wnd_my_combo_box = CreateWindowEx( 0 , WC_COMBOBOX , nullptr , ( CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ) , 0 , 0 , INIT_WIDTH , CW_USEDEFAULT , parent_wnd , NULL , core_api::get_my_instance() , nullptr );
			if( wnd_my_combo_box == NULL )
			{
				console::printf( CONSOLE_HEADER "CreateWindowEx() failed" );

				DeleteFont( ui_hfont );
				ui_hfont = NULL;
				return -1;
			}

			dsp_preset_switcher::PARENT_HWND_LIST.remove_item( parent_wnd );
			dsp_preset_switcher::PARENT_HWND_LIST.add_item( parent_wnd );

			// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
			// Sets the font that a control is to use when drawing text.
			uSendMessage( wnd_my_combo_box , WM_SETFONT , ( WPARAM ) ui_hfont , MAKELPARAM( 1 , 0 ) );

			// get metrics
			RECT rc;
			GetWindowRect( wnd_my_combo_box , &rc );
			HEIGHT = RECT_CY( rc );

			// get dsp names and add to combo box
			pfc::list_t<pfc::string8> l;
			initEntries( l );

			// set initial selection
			const bool ret = setEntry( CFG_IDX );
			if( !ret )
				CFG_IDX = -1;

			// determine width
			// MSDN Remarks: After an application has finished drawing with the new font object , it should always replace a new font object with the original font object.
			CONST HDC dc = GetDC( wnd_my_combo_box );
			CONST HFONT font_old = SelectFont( dc , ui_hfont );
			for( t_size i = 0 , imax = l.get_count(); i < imax ; ++i )
			{
				const char *str = l[i].get_ptr();
				const int cx = ui_helpers::get_text_width( dc , str , strlen( str ) );
				min_width = max( min_width , ( t_size ) cx );
			}
			SelectFont( dc , font_old );
			ReleaseDC( parent_wnd , dc );

			// get min width
			COMBOBOXINFO cbi = { 0 };
			cbi.cbSize = sizeof( cbi );
			GetComboBoxInfo( wnd_my_combo_box , &cbi );

			RECT rc_client;
			GetClientRect( wnd_my_combo_box , &rc_client );
			min_width += RECT_CX( rc_client ) - RECT_CX( cbi.rcItem );

			return 0;
		}

		case WM_DESTROY:
		{
			dsp_preset_switcher::PARENT_HWND_LIST.remove_item( GetParent( wnd_my_combo_box ) );
			DestroyWindow( wnd_my_combo_box );
			wnd_my_combo_box = NULL;

			DeleteFont( ui_hfont );
			ui_hfont = NULL;

			return 0;
		}

		case WM_GETMINMAXINFO:
		{
			CONST LPMINMAXINFO ptr = ( LPMINMAXINFO ) lp;
			ptr->ptMinTrackSize.x = min_width;

			ptr->ptMinTrackSize.y = HEIGHT;
			ptr->ptMaxTrackSize.y = HEIGHT;
			return 0;
		}

		case WM_WINDOWPOSCHANGED:
		{
			CONST LPWINDOWPOS ptr = ( LPWINDOWPOS ) lp;
			if( !( ptr->flags & SWP_NOSIZE ) )
			{
				SetWindowPos( wnd_my_combo_box , HWND_TOP , 0 , 0 , ptr->cx , HEIGHT , SWP_NOZORDER );
			}

			return 0;
		}

		case WM_COMMAND:
		{
			if( wp == ( CBN_SELCHANGE << 16 ) )
			{
				int idx;
				pfc::string8 text;
				bool ret = getSelection( idx , text );
				if( !ret )
					break;

				CFG_IDX = idx;
				ret = selDspName( idx , text.get_ptr() );
				if( !ret )
					syncSelection( -1 );
				return 0;
			}

			break;
		}

		case WM_USER_DSP_CORE_CHANGE:
		{
			if( skip_msg )
			{
				skip_msg = false;
				return 0;
			}

			// just rescan DSP name entries and remove the current selected one
			pfc::list_t<pfc::string8> d;
			initEntries( d );
			CFG_IDX = -1;
			return 0;
		}

		case WM_USER_SYNC_CHANGE:
		{
			if( wp == -1 )
			{
				pfc::list_t<pfc::string8> l;
				initEntries( l );
				return 0;
			}

			skip_msg = true;
			setEntry( wp );
			return 0;
		}

		default:
		{
			//console::printf( CONSOLE_HEADER "default case: %u" , msg );
			break;
		}
	}

	// Calls the default window procedure to provide default processing for any window messages that an application does not process. 
	// This function ensures that every message is processed.
	return uDefWindowProc( parent_wnd , msg , wp , lp );
}