Ejemplo n.º 1
0
void Explorerplusplus::OnTreeViewPaste(void)
{
	HTREEITEM hItem;
	LPITEMIDLIST pidl = NULL;
	TCHAR szFullFileName[MAX_PATH + 1];

	hItem = TreeView_GetSelection(m_hTreeView);

	if(hItem != NULL)
	{
		IDataObject *pClipboardObject = NULL;

		HRESULT hr = OleGetClipboard(&pClipboardObject);

		if(hr == S_OK)
		{
			CDropHandler *pDropHandler = CDropHandler::CreateNew();

			pidl = m_pMyTreeView->BuildPath(hItem);

			assert(pidl != NULL);

			GetDisplayName(pidl,szFullFileName,SHGDN_FORPARSING);

			/* Name must be double NULL terminated. */
			szFullFileName[lstrlen(szFullFileName) + 1] = '\0';

			pDropHandler->CopyClipboardData(pClipboardObject,
				m_hTreeView,szFullFileName,NULL,
				!m_bOverwriteExistingFilesConfirmation);

			CoTaskMemFree(pidl);

			pDropHandler->Release();
			pClipboardObject->Release();
		}
	}
}
Ejemplo n.º 2
0
void CPpcFolderDlg::OnBtnDown(HWND hDlg, WPARAM wParam)
{
	TV_ITEM tvi;
	HWND hWnd = GetDlgItem(hDlg, IDC_TREE_FOLDER);
	HTREEITEM hItem = TreeView_GetSelection(hWnd);
	if (!hItem)
		return;

	memset(&tvi, 0, sizeof(tvi));
	tvi.mask = TVIF_CHILDREN | TVIF_STATE;
	tvi.hItem = hItem;
	TreeView_GetItem(hWnd, &tvi);

	if (tvi.cChildren) {
		if (wParam == VK_RIGHT) {
			if (!(tvi.state & TVIS_EXPANDED))
				TreeView_Expand(hWnd, hItem, TVE_EXPAND);
			else {
				hItem = TreeView_GetChild(hWnd, hItem);
				TreeView_SelectItem(hWnd, hItem);
			}
		}
		else {
			if (tvi.state & TVIS_EXPANDED)
				TreeView_Expand(hWnd, hItem, TVE_COLLAPSE);
			else {
				hItem = TreeView_GetParent(hWnd, hItem);
				TreeView_SelectItem(hWnd, hItem);
			}
		}
	}
	else {
		if (wParam == VK_LEFT) {
			hItem = TreeView_GetParent(hWnd, hItem);
			TreeView_SelectItem(hWnd, hItem);
		}
	}
}
Ejemplo n.º 3
0
VOID
CDeviceView::DisplayPropertySheet()
{
#ifndef __REACTOS__
    pDevicePropertiesExW DevicePropertiesExW;
    HMODULE hModule;

    hModule = LoadLibraryW(L"devmgr.dll");
    if (hModule == NULL) return;

    DevicePropertiesExW = (pDevicePropertiesExW)GetProcAddress(hModule,
                                                               "DevicePropertiesExW");
    if (DevicePropertiesExW == NULL)
    {
        FreeLibrary(hModule);
        return;
    }
#endif

    TV_ITEM tvItem;

    tvItem.hItem = TreeView_GetSelection(m_hTreeView);
    tvItem.mask = TVIF_PARAM;

    if (TreeView_GetItem(m_hTreeView, &tvItem) &&
        (LPTSTR)tvItem.lParam != NULL)
    {
        DevicePropertiesExW(m_hTreeView,
                            NULL,
                            (LPTSTR)tvItem.lParam,
                            1,//DPF_EXTENDED,
                            FALSE);
    }

#ifndef __REACTOS__
    FreeLibrary(hModule);
#endif
}
Ejemplo n.º 4
0
void CAddBookmarkDialog::OnOk()
{
	HWND hName = GetDlgItem(m_hDlg,IDC_BOOKMARK_NAME);
	std::wstring strName;
	GetWindowString(hName,strName);

	HWND hLocation = GetDlgItem(m_hDlg,IDC_BOOKMARK_LOCATION);
	std::wstring strLocation;
	GetWindowString(hLocation,strLocation);

	if(strName.size() > 0 &&
		strLocation.size() > 0)
	{
		HWND hTreeView = GetDlgItem(m_hDlg,IDC_BOOKMARK_TREEVIEW);
		HTREEITEM hSelected = TreeView_GetSelection(hTreeView);
		CBookmarkFolder &BookmarkFolder = m_pBookmarkTreeView->GetBookmarkFolderFromTreeView(hSelected);

		CBookmark Bookmark = CBookmark::Create(strName,strLocation,_T(""));
		BookmarkFolder.InsertBookmark(Bookmark);
	}

	EndDialog(m_hDlg,1);
}
Ejemplo n.º 5
0
/* Header code - Directional Arrows */
static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (GetBackgroundBitmap() != NULL)
	{
		switch (uMsg)
		{	
	    case WM_MOUSEMOVE:
		{
			if (MouseHasBeenMoved())
				ShowCursor(TRUE);
			break;
		}

		case WM_KEYDOWN :
			if (wParam == VK_F2)
			{
				if (lpCurrentFolder->m_dwFlags & F_CUSTOM)
				{
					TreeView_EditLabel(hWnd,TreeView_GetSelection(hWnd));
					return TRUE;
				}
			}
			break;

		case WM_ERASEBKGND:
			return TRUE;
			break;

		case WM_PAINT:
			TreeCtrlOnPaint(hWnd, uMsg, wParam, lParam);
			break;
		}
	}

	/* message not handled */
	return CallWindowProc(g_lpTreeWndProc, hWnd, uMsg, wParam, lParam);
}
Ejemplo n.º 6
0
void XuLy_LV_NMDBLCLK(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	NMITEMACTIVATE *lpnmitem = (LPNMITEMACTIVATE) lParam;
	// Neu khong co item nao duoc chon thi thoat
	if (lpnmitem->iItem == -1)
		return;

	LVITEM kq;
	TCHAR szFileName[PATHFILE_MAX_LEN];

	kq.mask = LVIF_TEXT;
	kq.iItem = lpnmitem->iItem;
	kq.iSubItem = 0;
	kq.pszText = szFileName;
	kq.cchTextMax = PATHFILE_MAX_LEN;

	ListView_GetItem(hwndListView, &kq);

	HTREEITEM hParent = TreeView_GetSelection(hwndTreeView);
	HTREEITEM hItem = TV_FindItem(hParent, kq.pszText);

	if (hItem == NULL) // Item la tap tin
	{
		// Lay duong dan cua thu muc cha roi noi voi ten tap tin de co duoc duong
		// dan thuc su cua file
		TVITEM k;
		k.hItem = hParent;
		k.mask = TVIF_PARAM;
		TreeView_GetItem(hwndTreeView, &k);		
		TCHAR szFile[PATHFILE_MAX_LEN];
		wsprintf(szFile, _T("%s\\%s"), (TCHAR*) k.lParam, kq.pszText);
		// Thuc thi file
		ShellExecute(NULL , _T("open"), szFile, NULL, NULL, SW_SHOWNORMAL);
	}
	else
		TreeView_SelectItem(hwndTreeView, hItem);	
}
Ejemplo n.º 7
0
HTREEITEM TreeView_AddItem(int iImage, const TCHAR *text)
{
	HTREEITEM hCurrent = TreeView_GetSelection(g_hwndTree);

	TVINSERTSTRUCT tvs;
	tvs.item.mask                   =  TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;

	if (!hCurrent)
		tvs.hParent = TVI_ROOT;
	else
		tvs.hParent = hCurrent;

	tvs.item.pszText            = (LPSTR)text;    
	tvs.item.iSelectedImage = tvs.item.iImage = iImage;
	tvs.item.lParam = g_tvIndexCFG++;
	tvs.item.cchTextMax             = lstrlen(tvs.item.pszText) + 1;
	tvs.hInsertAfter = TVI_LAST;

	HTREEITEM hNewItem = TreeView_InsertItem(g_hwndTree, &tvs);
    
	if (hCurrent)
		TreeView_Expand(g_hwndTree, hCurrent, TVE_EXPAND);
	return hNewItem;
}
Ejemplo n.º 8
0
void plComponentDlg::IDeleteComponent(plMaxNode *component)
{
    if (!component)
        return;

    // Make sure this components interface isn't showing
    if (plComponentUtil::Instance().IsOpen())
        plComponentUtil::Instance().IComponentPreDelete(component->ConvertToComponent());
    
    // Delete the component from the scene
    theHold.Begin();
    fInterface->DeleteNode(component);
    theHold.Accept(_T("Delete Component"));

    // Delete the component from the tree
    HWND hTree = GetDlgItem(fhDlg, IDC_TREE);
    HTREEITEM hItem = TreeView_GetSelection(hTree);
    HTREEITEM hParent = TreeView_GetParent(hTree, hItem);
    TreeView_DeleteItem(hTree, hItem);

    // If that was the only component of this type, delete the type too
    if (!TreeView_GetChild(hTree, hParent))
    {
        HTREEITEM hCategory = TreeView_GetParent(hTree, hParent);
        TreeView_DeleteItem(hTree, hParent);

        // If this is the only type in this category, delete the category too!
        // Sadly, this is the most we can delete.
        if (!TreeView_GetChild(hTree, hCategory))
            TreeView_DeleteItem(hTree, hCategory);
    }

    // Update the rollups in case the selected object had this component attached
    if (plComponentUtil::Instance().IsOpen())
        plComponentUtil::Instance().IUpdateRollups();
}
Ejemplo n.º 9
0
void PrefsTreeCtrl::OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent,
                                      HINSTANCE hInst )
{
    ConfigTreeData *config_data = NULL;

    if( pnmtv->itemOld.hItem )
        config_data = FindModuleConfig( (ConfigTreeData *)pnmtv->itemOld.lParam );

    if( config_data && config_data->panel )
    {
        config_data->panel->Hide();
    }

    /* Don't use event.GetItem() because we also send fake events */
    TVITEM tvi = {0};
    tvi.mask = TVIF_PARAM;
    tvi.hItem = TreeView_GetSelection( hwndTV );
    TreeView_GetItem( hwndTV, &tvi );
    config_data = FindModuleConfig( (ConfigTreeData *)tvi.lParam );
    if( config_data )
    {
        if( !config_data->panel )
        {
            /* The panel hasn't been created yet. Let's do it. */
            config_data->panel =
                new PrefsPanel( parent, hInst, p_intf, p_prefs_dialog,
                                config_data->i_object_id,
                                config_data->psz_section,
                                config_data->psz_help );
        }
        else
        {
            config_data->panel->Show();
        }
    }
}
Ejemplo n.º 10
0
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HTREEITEM hSelection;
    HKEY hRootKey;
    LPCWSTR keyPath, s;
    WORD wID = LOWORD(wParam);

    UNREFERENCED_PARAMETER(message);

    switch (wID)
    {
        /* Parse the menu selections: */
    case ID_REGISTRY_EXIT:
        DestroyWindow(hWnd);
        break;
    case ID_VIEW_REFRESH:
        /* TODO */
        break;
    case ID_TREE_EXPANDBRANCH:
        (void)TreeView_Expand(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), TVE_EXPAND);
        break;
    case ID_TREE_COLLAPSEBRANCH:
        (void)TreeView_Expand(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), TVE_COLLAPSE);
        break;
    case ID_TREE_RENAME:
        SetFocus(g_pChildWnd->hTreeWnd);
        (void)TreeView_EditLabel(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
        break;
    case ID_TREE_DELETE:
        hSelection = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
        keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hSelection, &hRootKey);

        if (keyPath == 0 || *keyPath == 0)
        {
            MessageBeep(MB_ICONHAND);
        }
        else if (DeleteKey(hWnd, hRootKey, keyPath))
            DeleteNode(g_pChildWnd->hTreeWnd, 0);
        break;
    case ID_TREE_EXPORT:
        ExportRegistryFile(g_pChildWnd->hTreeWnd);
        break;
    case ID_EDIT_FIND:
        FindDialog(hWnd);
        break;
    case ID_EDIT_COPYKEYNAME:
        hSelection = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
        keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hSelection, &hRootKey);
        CopyKeyName(hWnd, hRootKey, keyPath);
        break;
    case ID_EDIT_NEW_KEY:
        CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
        break;
    case ID_EDIT_NEW_STRINGVALUE:
    case ID_EDIT_NEW_BINARYVALUE:
    case ID_EDIT_NEW_DWORDVALUE:
        SendMessageW(hFrameWnd, WM_COMMAND, wParam, lParam);
        break;
    case ID_SWITCH_PANELS:
        g_pChildWnd->nFocusPanel = !g_pChildWnd->nFocusPanel;
        SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
        break;
    default:
        if ((wID >= ID_TREE_SUGGESTION_MIN) && (wID <= ID_TREE_SUGGESTION_MAX))
        {
            s = Suggestions;
            while(wID > ID_TREE_SUGGESTION_MIN)
            {
                if (*s)
                    s += wcslen(s) + 1;
                wID--;
            }
            SelectNode(g_pChildWnd->hTreeWnd, s);
            break;
        }
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 11
0
LRESULT WINAPI ObjectBrowserProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    traceIn(ObjectBrowserProc);

    switch(message)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_OBJECTS_OPENMODULE:
                    LoadNewModule();
                    break;

                case ID_OBJECTS_UNLOADMODULE:
                    {
                        DWORD dwCurSel = SendMessage(hwndModuleList, LB_GETCURSEL, 0, 0);

                        if(dwCurSel != LB_ERR)
                        {
                            if(MessageBox(hwndModuleList, TEXT("Unloading a module will remove all objects associated with this module from this level.\r\n\r\nAre you sure you want to do this?"), TEXT("Unload Module"), MB_YESNO|MB_ICONQUESTION) == IDYES)
                            {
                                String strModuleName;
                                strModuleName.SetLength(255);
                                SendMessage(hwndModuleList, LB_GETTEXT, dwCurSel, (LPARAM)(CTSTR)strModuleName);

                                SendMessage(hwndModuleList, LB_DELETESTRING, dwCurSel, 0);

                                level->UnloadLevelModule(strModuleName);

                                UpdateObjectTreeAndModules();
                            }
                        }
                        else
                            MessageBox(hwnd, TEXT("You have to select a module to unload."), NULL, MB_OK);

                        break;
                    }

                case ID_OBJECTS_CLOSE:
                    DestroyWindow(hwnd);
                    editor->hwndObjectBrowser = NULL;
                    break;
            }
            break;

        case WM_NOTIFY:
            {
                NMTREEVIEW *info = (NMTREEVIEW*)lParam;

                if(info->hdr.code == TVN_SELCHANGED)
                {
                    HTREEITEM hItem = TreeView_GetSelection(hwndObjectTree);

                    TVITEMEX tvi;

                    zero(&tvi, sizeof(tvi));
                    tvi.mask  = TVIF_PARAM|TVIF_HANDLE;
                    tvi.hItem = hItem;
                    TreeView_GetItem(hwndObjectTree, &tvi);

                    Class *cls = (Class*)tvi.lParam;

                    editor->selectedEntityClass = cls;

                    if((levelInfo->curEditMode == EditMode_Create) && levelInfo->newObject && levelInfo->newObject->IsOf(GetClass(EntityPlacer)))
                    {
                        EntityPlacer *ep = (EntityPlacer*)levelInfo->newObject;
                        EditMode em = ep->prevEditMode;
                        EntityType et = ep->entityType;

                        delete levelInfo->newObject;
                        levelInfo->newObject = CreateObjectParam2(EntityPlacer, em, et);
                    }
                }

                break;
            }

        case WM_SIZE:
            {
                int cx = LOWORD(lParam);
                int cy = HIWORD(lParam);

                SetWindowPos(hwndObjectTree, NULL, 150, 0, cx-150, cy, SWP_NOMOVE);
                SetWindowPos(hwndModuleList, NULL, 0, 0, 150, cy, SWP_NOMOVE);
                break;
            }

        case WM_SIZING:
            {
                int borderXSize = 300;
                int borderYSize = 300;

                borderXSize += GetSystemMetrics(SM_CXSIZEFRAME)*2;
                borderYSize += GetSystemMetrics(SM_CYSIZEFRAME)*2;
                borderYSize += GetSystemMetrics(SM_CYCAPTION);
                borderYSize += GetSystemMetrics(SM_CYMENU);

                RECT *pRect = (RECT*)lParam;

                if((pRect->right - pRect->left) <= borderXSize)
                    pRect->right = pRect->left + borderXSize;

                if((pRect->bottom - pRect->top) <= borderYSize)
                    pRect->bottom = pRect->top + borderYSize;

                return TRUE;
            }

        case WM_CLOSE:
            DestroyWindow(hwnd);
            editor->hwndObjectBrowser = NULL;
            break;
    }

    return DefWindowProc(hwnd, message, wParam, lParam);

    traceOut;
}
Ejemplo n.º 12
0
INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
	if (!m_HandleCommands)
	{
		// Values are being changed/reset, no need to apply changes
		return FALSE;
	}

	switch (LOWORD(wParam))
	{
	case IDC_MANAGESKINS_ACTIVESKINS_BUTTON:
		{
			HMENU menu = CreatePopupMenu();

			// Add active skins to menu
			std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
			int index = 0;
			for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
			{
				std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
				name += ((*iter).second)->GetFileName();
				InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str());
				++index;
			}

			if (index > 0)
			{
				RECT r;
				GetWindowRect((HWND)lParam, &r);

				// Show context menu
				TrackPopupMenu(
					menu,
					TPM_RIGHTBUTTON | TPM_LEFTALIGN,
					(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
					--r.bottom,
					0,
					m_Window,
					NULL
				);
			}

			DestroyMenu(menu);
		}
		break;

	case IDC_MANAGESKINS_CREATEPACKAGE_BUTTON:
		{
			std::wstring file = Rainmeter->GetPath() + L"SkinInstaller.exe";
			RunFile(file.c_str(), L"/Packager");
		}
		break;

	case IDC_MANAGESKINS_LOAD_BUTTON:
		{
			if (!m_SkinWindow)
			{
				// Skin not active, load
				std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinFolderPath, m_SkinFileName);
				if (indexes.first != -1 && indexes.second != -1)
				{
					Rainmeter->ActivateSkin(indexes.first, indexes.second);

					// Fake selection change to update controls
					NMHDR nm;
					nm.code = TVN_SELCHANGED;
					nm.idFrom = IDC_MANAGESKINS_SKINS_TREEVIEW;
					nm.hwndFrom = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
					OnNotify(0, (LPARAM)&nm);
				}
			}
			else
			{
				m_HandleCommands = false;
				Rainmeter->DeactivateSkin(m_SkinWindow, -1);
			}
		}
		break;

	case IDC_MANAGESKINS_REFRESH_BUTTON:
		if (m_SkinWindow)
		{
			m_SkinWindow->Refresh(false);
		}
		break;

	case IDC_MANAGESKINS_EDIT_BUTTON:
		Rainmeter->EditSkinFile(m_SkinFolderPath, m_SkinFileName);
		break;

	case IDC_MANAGESKINS_X_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			m_IgnoreUpdate = true;
			int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
			m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());

			if (x > m_SkinWindow->GetX())
			{
				_itow_s(m_SkinWindow->GetX(), buffer, 10);
				Edit_SetText((HWND)lParam, buffer);
			}
		}
		break;

	case IDC_MANAGESKINS_Y_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			m_IgnoreUpdate = true;
			int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
			m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);

			if (y > m_SkinWindow->GetY())
			{
				_itow_s(m_SkinWindow->GetY(), buffer, 10);
				Edit_SetText((HWND)lParam, buffer);
			}
		}
		break;

	case IDC_MANAGESKINS_LOADORDER_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			if (m_IgnoreUpdate)
			{
				// To avoid infinite loop after setting value below
				m_IgnoreUpdate = false;
			}
			else
			{
				// Convert text to number and set it to get rid of extra chars
				WCHAR buffer[32];
				int len = GetWindowText((HWND)lParam, buffer, 32);
				if ((len == 0) || (len == 1 && buffer[0] == L'-'))
				{
					// Ignore if empty or if - is only char
					break;
				}

				// Get selection
				DWORD sel = Edit_GetSel((HWND)lParam);

				// Reset value (to get rid of invalid chars)
				m_IgnoreUpdate = true;
				int value = _wtoi(buffer);

				_itow_s(value, buffer, 10);
				SetWindowText((HWND)lParam, buffer);

				// Reset selection
				Edit_SetSel((HWND)lParam, LOWORD(sel), HIWORD(sel));

				WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, Rainmeter->GetIniFile().c_str());
				std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinWindow);
				if (indexes.first != -1)
				{
					Rainmeter->SetLoadOrder(indexes.first, value);

					std::multimap<int, CMeterWindow*> windows;
					Rainmeter->GetMeterWindowsByLoadOrder(windows);

					CSystem::PrepareHelperWindow();

					// Reorder window z-position to reflect load order
					std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin();
					for ( ; iter != windows.end(); ++iter)
					{
						CMeterWindow* mw = (*iter).second;
						mw->ChangeZPos(mw->GetWindowZPosition(), true);
					}
				}
			}
		}
		break;

	case IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON:
		{
			HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_SKIN_MENU));
			if (menu)
			{
				HMENU subMenu = GetSubMenu(menu, 0);	// Skin menu
				subMenu = GetSubMenu(subMenu, 4); // Settings menu
				subMenu = GetSubMenu(subMenu, 0); // Position menu
				subMenu = GetSubMenu(subMenu, 0); // Display monitor menu
				Rainmeter->CreateMonitorMenu(subMenu, m_SkinWindow);

				RECT r;
				GetWindowRect((HWND)lParam, &r);

				// Show context menu
				TrackPopupMenu(
					subMenu,
					TPM_RIGHTBUTTON | TPM_LEFTALIGN,
					(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
					--r.bottom,
					0,
					m_Window,
					NULL
				);

				DestroyMenu(menu);
			}
		}
		break;

	case IDC_MANAGESKINS_DRAGGABLE_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetWindowDraggable(!m_SkinWindow->GetWindowDraggable());
		break;

	case IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetClickThrough(!m_SkinWindow->GetClickThrough());
		break;

	case IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetKeepOnScreen(!m_SkinWindow->GetKeepOnScreen());
		break;

	case IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetSavePosition(!m_SkinWindow->GetSavePosition());
		break;

	case IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetSnapEdges(!m_SkinWindow->GetSnapEdges());
		break;

	case IDC_MANAGESKINS_ZPOSITION_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			ZPOSITION zpos = (ZPOSITION)(ComboBox_GetCurSel((HWND)lParam) - 2);
			m_SkinWindow->SetWindowZPosition(zpos);
		}
		break;

	case IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			int sel = ComboBox_GetCurSel((HWND)lParam) + IDM_SKIN_TRANSPARENCY_0;
			SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, sel, 0);
		}
		break;

	case IDC_MANAGESKINS_ONHOVER_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			HIDEMODE hide = (HIDEMODE)ComboBox_GetCurSel((HWND)lParam);
			m_SkinWindow->SetWindowHide(hide);
		}
		break;

	case IDM_MANAGESKINSMENU_EXPAND:
		{
			HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
			HTREEITEM item = TreeView_GetSelection(tree);
			TreeView_Expand(tree, item, TVE_TOGGLE);
		}
		break;

	case IDM_MANAGESKINSMENU_OPENFOLDER:
		{
			HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
			Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree));
		}
		break;

	default:
		if (wParam >= ID_CONFIG_FIRST && wParam <= ID_CONFIG_LAST)
		{
			std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
			int index = (int)wParam - ID_CONFIG_FIRST;
			int i = 0;
			for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
			{
				if (i == index)
				{
					std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
					name += ((*iter).second)->GetFileName();

					HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
					SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
					break;
				}

				++i;
			}
		}
		else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT ||
			wParam == IDM_SKIN_MONITOR_PRIMARY ||
			wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
		{
			if (m_SkinWindow)
			{
				SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, wParam, 0);
			}
			break;
		}

		return 1;
	}

	return 0;
}
Ejemplo n.º 13
0
static LRESULT TreeViewNotify(HWND hWnd, LPARAM lParam,INT iLVIndex,LPNMHDR pnmh)
{
	LPNMLVKEYDOWN pnkd;

	struct OBJ *poj;
	CHAR szServ[20];
	LPNMHDR lpnmh;
	HTREEITEM hItem;
	LPNMTREEVIEW lpnmtv;
	TVITEM item;
	BOOL fReturn;
	LRESULT lRes;

	if (iLVIndex>100||iLVIndex<0) return 0;

	poj=TVList[iLVIndex].lpObj;
	if (pnmh->code==0) efx2();
	lpnmh = (LPNMHDR) lParam; 

 // Lancio se connessa la procedura di controllo esterna
	if (TVList[iLVIndex].subPostNotify)
	{
		fReturn=FALSE;
		lRes=(*TVList[iLVIndex].subPostNotify)(poj,&fReturn, EXT_PREV,hWnd,0,0,lParam);
		if (fReturn) return lRes;
	}

	switch(pnmh->code)
	{
		case TVN_SELCHANGING:
			 lpnmtv = (LPNMTREEVIEW) lParam;
			 TreeView_SelectDropTarget(lpnmh->hwndFrom,lpnmtv->itemNew.hItem); 

			 ZeroFill(item);
			 hItem=TreeView_GetSelection(lpnmh->hwndFrom);
			 item.mask=TVIF_PARAM; 
			 item.hItem=hItem;
			 item.pszText=szServ;
			 item.cchTextMax=sizeof(szServ);
			 TreeView_GetItem(lpnmh->hwndFrom,&item);
			 OBJ_key=item.lParam;

			 sprintf(szServ,"%sSEL",poj->nome);
			 obj_addevent(szServ);
			 break;
		
		case NM_DBLCLK :
			 ZeroFill(item);
			 hItem=TreeView_GetSelection(lpnmh->hwndFrom);
			 item.mask=TVIF_PARAM; 
			 item.hItem=hItem;
			 item.pszText=szServ;
			 item.cchTextMax=sizeof(szServ);
			 TreeView_GetItem(lpnmh->hwndFrom,&item);
			 OBJ_key=item.lParam;

			 sprintf(szServ,"%sDCLK",poj->nome);
			 obj_addevent(szServ);
			 break;


		case NM_RCLICK:
			 hItem=TreeView_GetSelection(lpnmh->hwndFrom);
			 if (hItem==NULL) break;
			 //memset(&item,0,sizeof(item));
			 ZeroFill(item);
			 item.mask=TVIF_TEXT|TVIF_PARAM; 
			 item.hItem=hItem;
			 item.pszText=szServ;
			 item.cchTextMax=sizeof(szServ);

			 TreeView_GetItem(lpnmh->hwndFrom,&item);
			 //_d_("[%s]      ",szServ);
			 
			 
			 OBJ_key=item.lParam;
			 sprintf(szServ,"%sRC",poj->nome);
			 obj_addevent(szServ);
			 break;

		 case TVN_BEGINDRAG:
		 //case TVN_BEGINRDRAG:
			 Main_OnBeginDrag(lpnmh->hwndFrom, (LPNMTREEVIEW) lParam); 
			 break; 

		//efx1();
		//break;

		case TVN_KEYDOWN:
			pnkd = (LPNMLVKEYDOWN) lParam;   
			if (pnkd->wVKey==ESC) winSetFocus(WindowNow());
			if ((pnkd->wVKey>=' ')&&(pnkd->wVKey<='<')) 
			{
				//efx1();		
			}
			break;
	}

	// Lancio se connessa la procedura di controllo esterna
	if (TVList[iLVIndex].subPostNotify)
	{
		fReturn=FALSE;
		lRes=(*TVList[iLVIndex].subPostNotify)(poj,&fReturn, EXT_AFTER,hWnd,0,0,lParam);
//			(TVSUB_POST,poj,hWnd,lParam,pnmh,&fReturn);
		if (fReturn) return lRes;
	}

	return 0;
}
Ejemplo n.º 14
0
BOOL Explorerplusplus::OnTreeViewItemExpanding(LPARAM lParam)
{
	NMTREEVIEW *pnmtv;
	TVITEM *tvItem;
	HTREEITEM *pItem;
	NMHDR *nmhdr;

	nmhdr = (NMHDR *)lParam;

	pnmtv = (LPNMTREEVIEW)lParam;

	tvItem = &pnmtv->itemNew;

	pItem = &tvItem->hItem;

	if(TreeView_GetParent(nmhdr->hwndFrom,*pItem) == NULL)
	{
		return FALSE;
	}

	if(pnmtv->action == TVE_EXPAND)
	{
		LPITEMIDLIST pidl	= NULL;

		pidl = m_pMyTreeView->BuildPath(tvItem->hItem);
		m_pMyTreeView->AddDirectory(tvItem->hItem,pidl);

		CoTaskMemFree(pidl);
	}
	else
	{
		HTREEITEM hSelection = TreeView_GetSelection(m_hTreeView);

		if(hSelection != NULL)
		{
			/* We may collapse multiple levels (not just the parent folder), so we need 
			to search up the tree for the parent item. */
			HTREEITEM hItem = hSelection;

			do 
			{
				hItem = TreeView_GetParent(m_hTreeView,hItem);
			} while (hItem != tvItem->hItem && hItem != NULL);

			if(hItem == tvItem->hItem)
			{
				LPITEMIDLIST pidl	= NULL;

				pidl = m_pMyTreeView->BuildPath(tvItem->hItem);
				BrowseFolder(pidl,SBSP_SAMEBROWSER);

				CoTaskMemFree(pidl);
			}
		}

		m_pMyTreeView->EraseItems(tvItem->hItem);

		SendMessage(nmhdr->hwndFrom,TVM_EXPAND,
		(WPARAM)TVE_COLLAPSE|TVE_COLLAPSERESET,
		(LPARAM)tvItem->hItem);
	}

	return FALSE;
}
Ejemplo n.º 15
0
void rowOptShowSettings(HWND hwnd)
{
	TVITEM tvi;
	pROWCELL cell;
	HTREEITEM node = TreeView_GetSelection(GetDlgItem(hwnd, IDC_ROWTREE));
	int param;

	tvi.hItem = node;
	tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;

	TreeView_GetItem(GetDlgItem(hwnd, IDC_ROWTREE), &tvi);
	cell = (pROWCELL)tvi.lParam;

	if (!tvi.hItem)  {
		EnableWindow(GetDlgItem(hwnd, IDC_CONTTYPE), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_VALIGN), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_HALIGN), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_CONTWIDTH), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_CONTHEIGHT), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTWIDTH), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTHEIGHT), 0);
		SendDlgItemMessage(hwnd, IDC_SPINCONTWIDTH, UDM_SETPOS, 0, 0);
		SendDlgItemMessage(hwnd, IDC_SPINCONTHEIGHT, UDM_SETPOS, 0, 0);
		EnableWindow(GetDlgItem(hwnd, IDC_CONTLAYER), 0);
		return;
	}

	EnableWindow(GetDlgItem(hwnd, IDC_CONTTYPE), 1);
	EnableWindow(GetDlgItem(hwnd, IDC_VALIGN), 1);
	EnableWindow(GetDlgItem(hwnd, IDC_HALIGN), 1);
	EnableWindow(GetDlgItem(hwnd, IDC_CONTLAYER), 1);

	if (cell->type != TC_SPACE && cell->type != TC_FIXED) {
		EnableWindow(GetDlgItem(hwnd, IDC_CONTWIDTH), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_CONTHEIGHT), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTWIDTH), 0);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTHEIGHT), 0);
		SendDlgItemMessage(hwnd, IDC_SPINCONTWIDTH, UDM_SETPOS, 0, 0);
		SendDlgItemMessage(hwnd, IDC_SPINCONTHEIGHT, UDM_SETPOS, 0, 0);
	}
	else {
		EnableWindow(GetDlgItem(hwnd, IDC_CONTWIDTH), 1);
		EnableWindow(GetDlgItem(hwnd, IDC_CONTHEIGHT), 1);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTWIDTH), 1);
		EnableWindow(GetDlgItem(hwnd, IDC_SPINCONTHEIGHT), 1);
		SendDlgItemMessage(hwnd, IDC_SPINCONTWIDTH, UDM_SETPOS, 0, MAKELONG(cell->w, 0));
		SendDlgItemMessage(hwnd, IDC_SPINCONTHEIGHT, UDM_SETPOS, 0, MAKELONG(cell->h, 0));
	}

	SendDlgItemMessage(hwnd, IDC_CONTTYPE, CB_SETCURSEL, cell->type, 0);

	switch (cell->valign) {
	case TC_VCENTER:
		param = 1;
		break;
	case TC_BOTTOM:
		param = 2;
		break;
	default:
		param = 0;
	}
	SendDlgItemMessage(hwnd, IDC_VALIGN, CB_SETCURSEL, param, 0);

	switch (cell->halign) {
	case TC_HCENTER:
		param = 1;
		break;
	case TC_RIGHT:
		param = 2;
		break;
	default:
		param = 0;
	}
	SendDlgItemMessage(hwnd, IDC_HALIGN, CB_SETCURSEL, param, 0);

	CheckDlgButton(hwnd, IDC_CONTLAYER, cell->layer ? BST_CHECKED : BST_UNCHECKED);
}
Ejemplo n.º 16
0
BOOL
DrivesTabProc(
    IN HWND hWnd,
    IN UINT message,
    IN WPARAM wParam,
    IN LPARAM lParam
    )

/*++

Routine Description:

    DrivesTabProc processes messages when the Drives Tab is currently selected.

Arguments:

    Standard WINPROC entry.

Return Value:

    BOOL - Depending on input message and processing options.

--*/

{
    BOOL    Success;
    HWND    hTreeView;

    switch( message ) {


    case WM_INITDIALOG:
         InitializeDrivesTab(hWnd);
         break;

    case WM_DESTROY:
         FreeDriveInfoStructures( hWnd );
         break;

    case WM_NOTIFY:
        {

        switch( ((LPNMHDR)lParam)->code ){

        case TVN_GETDISPINFO:
              {
                 // TVN_GETDISPINFO is sent my I_IMAGECALLBACK to determine
                 // folder state


                 if ((((TV_DISPINFO *)lParam)->item.state) & TVIS_EXPANDED)
                 {
                    ((TV_DISPINFO *)lParam)->item.iImage =
                    ((TV_DISPINFO *)lParam)->item.iSelectedImage = IMAGE_FOLDER_OPEN;
                 }
                 else
                 {
                    ((TV_DISPINFO *)lParam)->item.iImage =
                    ((TV_DISPINFO *)lParam)->item.iSelectedImage = IMAGE_FOLDER_CLOSED;
                 }
                 break;
              }

        case TVN_SELCHANGED:
             {
               //
               // Enable or disable the Properties button, depending on whether
               // this item has any children--only allow properties for items
               // with no children
               //
               TV_ITEM tvi;
               tvi = ((LPNM_TREEVIEW)lParam)->itemNew;
               tvi.mask = TVIF_CHILDREN;
               TreeView_GetItem (GetDlgItem(hWnd, IDC_TV_DRIVE_LIST), &tvi);

               Success = EnableControl(
                            GetParent(hWnd),
                            IDC_PUSH_PROPERTIES,
                            (tvi.cChildren == 0)  ? TRUE : FALSE
                            );

               break;
              }

        case NM_DBLCLK:
              {

              // pretend we have clicked the Property button

              PostMessage(
                    GetParent(hWnd),
                    WM_COMMAND,
                    MAKEWPARAM( IDC_PUSH_PROPERTIES, BN_CLICKED ),
                    0
                    );

              break;

              }
        }
        }
    case WM_COMMAND:
        {

        LPDRIVE_INFO    DriveInfo;

        switch( LOWORD( wParam )) {

        case IDC_PUSH_DRIVE_TYPE:
        case IDC_PUSH_DRIVE_LETTER:
        case IDC_PUSH_REFRESH:

           FreeDriveInfoStructures( hWnd );

           FillTreeViewWithDrives( hWnd,
                        GetDlgItem(hWnd, IDC_TV_DRIVE_LIST),
                        LOWORD( wParam ) );

           EnableControl( GetParent(hWnd),
                  IDC_PUSH_PROPERTIES,
                  FALSE);

           break;

        case IDC_PUSH_SCSI_CHAIN:
           DisplaySCSIDevices(  hWnd, GetDlgItem(hWnd, IDC_TV_DRIVE_LIST) );
           break;

        case IDC_PUSH_PHYSICAL_DISKS:
            //WORKITEM
            break;

        case IDC_PUSH_PROPERTIES:
           if (HIWORD( wParam) == BN_CLICKED) {
              TV_ITEM tvi;
              TCHAR szBuffer[512];

              tvi.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM;
              tvi.hItem = TreeView_GetSelection( GetDlgItem(hWnd, IDC_TV_DRIVE_LIST) );
              tvi.pszText = szBuffer;
              tvi.cchTextMax = sizeof(szBuffer);

              TreeView_GetItem (GetDlgItem(hWnd, IDC_TV_DRIVE_LIST), &tvi);

              if ( !tvi.cChildren )
              {
                  if ( GetDriveInfo( (LPDRIVE_INFO) tvi.lParam ) )
                  {
                    DisplayDrivePropertySheet( hWnd, (LPDRIVE_INFO) tvi.lParam);
                  }
                  else
                  {
                  TCHAR Buffer[256];

                  wsprintf( Buffer, (LPCTSTR) GetString( IDS_APPLICATION_FULLNAME ));

                  MessageBox ( hWnd,
                           (LPCTSTR) GetString( IDS_DRIVE_PROPERTY_NOT_AVAILABLE ),
                           Buffer,
                           MB_ICONSTOP | MB_OK );

                  }
              }


              break;
           }

        }
        break;
        }
    }

    return(FALSE);

}
Ejemplo n.º 17
0
static LRESULT OnTocTreeNotify(WindowInfo *win, LPNMTREEVIEW pnmtv)
{
    switch (pnmtv->hdr.code)
    {
        case TVN_SELCHANGED:
            // When the focus is set to the toc window the first item in the treeview is automatically
            // selected and a TVN_SELCHANGEDW notification message is sent with the special code pnmtv->action == 0x00001000.
            // We have to ignore this message to prevent the current page to be changed.
            if (TVC_BYKEYBOARD == pnmtv->action || TVC_BYMOUSE == pnmtv->action)
                GoToTocLinkForTVItem(win, pnmtv->hdr.hwndFrom, pnmtv->itemNew.hItem, TVC_BYMOUSE == pnmtv->action);
            // The case pnmtv->action==TVC_UNKNOWN is ignored because
            // it corresponds to a notification sent by
            // the function TreeView_DeleteAllItems after deletion of the item.
            break;

        case TVN_KEYDOWN: {
            TV_KEYDOWN *ptvkd = (TV_KEYDOWN *)pnmtv;
            if (VK_TAB == ptvkd->wVKey) {
                if (win->tabsVisible && IsCtrlPressed())
                    TabsOnCtrlTab(win, IsShiftPressed());
                else
                    AdvanceFocus(win);
                return 1;
            }
            break;
        }
        case NM_CLICK: {
            // Determine which item has been clicked (if any)
            TVHITTESTINFO ht = { 0 };
            DWORD pos = GetMessagePos();
            ht.pt.x = GET_X_LPARAM(pos);
            ht.pt.y = GET_Y_LPARAM(pos);
            MapWindowPoints(HWND_DESKTOP, pnmtv->hdr.hwndFrom, &ht.pt, 1);
            TreeView_HitTest(pnmtv->hdr.hwndFrom, &ht);

            // let TVN_SELCHANGED handle the click, if it isn't on the already selected item
            if ((ht.flags & TVHT_ONITEM) && TreeView_GetSelection(pnmtv->hdr.hwndFrom) == ht.hItem)
                GoToTocLinkForTVItem(win, pnmtv->hdr.hwndFrom, ht.hItem);
            break;
        }
        case NM_RETURN:
            GoToTocLinkForTVItem(win, pnmtv->hdr.hwndFrom);
            break;

        case NM_CUSTOMDRAW:
#ifdef DISPLAY_TOC_PAGE_NUMBERS
            if (win->AsEbook())
                return CDRF_DODEFAULT;
            switch (((LPNMCUSTOMDRAW)pnmtv)->dwDrawStage) {
            case CDDS_PREPAINT:
                return CDRF_NOTIFYITEMDRAW;
            case CDDS_ITEMPREPAINT:
                return CDRF_DODEFAULT | CDRF_NOTIFYPOSTPAINT;
            case CDDS_ITEMPOSTPAINT:
                RelayoutTocItem((LPNMTVCUSTOMDRAW)pnmtv);
                // fall through
            default:
                return CDRF_DODEFAULT;
            }
            break;
#else
            return CDRF_DODEFAULT;
#endif

        case TVN_GETINFOTIP:
            CustomizeTocInfoTip((LPNMTVGETINFOTIP)pnmtv);
            break;
    }
    return -1;
}
Ejemplo n.º 18
0
static LRESULT CALLBACK WndProc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
	static bool bDragging = FALSE;

	switch (uMessage)
	{
	case WM_SETFOCUS:
	case WM_KILLFOCUS:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if ( window )
		{
			mxEvent event;
			event.event = mxEvent::Focus;
			event.widget = NULL;
			event.action = (uMessage == WM_SETFOCUS);
			RecursiveHandleEvent( window, &event );
			return 0;
		}
	}
	break;

	case WM_ACTIVATE:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if ( window )
		{
			mxEvent event;
			event.event = mxEvent::Activate;
			event.widget = NULL;
			event.action = (LOWORD( wParam ) != WA_INACTIVE);
			RecursiveHandleEvent( window, &event );
			return 0;
		}
	}
	break;

	case WM_COMMAND:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (LOWORD (wParam) > 0 && window)
		{
			WORD wNotifyCode = (WORD) HIWORD (wParam);
			HWND hwndCtrl = (HWND) lParam;
			mxEvent event;

			CHAR className[128];
			GetClassName (hwndCtrl, className, 128);
			if (!strcmpi (className, "edit"))
			{
				if (wNotifyCode != EN_CHANGE)
					break;
			}
			else if (!strcmpi (className, "combobox"))
			{
				if (wNotifyCode != CBN_SELCHANGE)
					break;
			}
			else if (!strcmpi (className, "listbox"))
			{
				if (wNotifyCode != LBN_SELCHANGE)
					break;
			}

			event.event = mxEvent::Action;
			event.widget = (mxWidget *) GetWindowLong ((HWND) lParam, GWL_USERDATA);
			event.action = (int) LOWORD (wParam);
			RecursiveHandleEvent( window, &event );
		}
	}
	break;

	case WM_NOTIFY:
	{
		if (isClosing)
			break;

		NMHDR *nmhdr = (NMHDR *) lParam;
		mxEvent event;

#if 0
		//if ( nmhdr->idFrom > 0 ) 
		{
			mxWidget *temp = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
			if ( temp && temp->getType() == MX_TREEVIEW )
			{
				NMTREEVIEW *nmt = ( NMTREEVIEW * )nmhdr;

				HTREEITEM hItem = TreeView_GetSelection (nmhdr->hwndFrom);

				char sz[ 256 ];
				sprintf( sz, "tree view receiving notify %i : %s action %i old %p new %p selection %p\n", nmhdr->code, translatecode( nmhdr->code ),
					nmt->action, nmt->itemOld, nmt->itemNew, hItem );
				
				OutputDebugString( sz );
			}
		}
#endif

		if (nmhdr->code == TVN_SELCHANGED)
		{
			if (nmhdr->idFrom > 0)
			{
				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				event.event = mxEvent::Action;
				event.widget = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
				event.action = (int) nmhdr->idFrom;

				RECT rc;
				HTREEITEM hItem = TreeView_GetSelection (nmhdr->hwndFrom);
				TreeView_GetItemRect (nmhdr->hwndFrom, hItem, &rc, TRUE);
				event.x = (int) rc.left;
				event.y = (int) rc.bottom;
				RecursiveHandleEvent( window, &event );

			}
		}
		else if (nmhdr->code == LVN_ITEMCHANGED)
		{
			if (nmhdr->idFrom > 0)
			{
				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				event.event = mxEvent::Action;
				event.widget = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
				event.action = (int) nmhdr->idFrom;

				RecursiveHandleEvent( window, &event );
			}
		}
		else if (nmhdr->code == NM_RCLICK)
		{
			if (nmhdr->idFrom > 0)
			{
				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				event.event = mxEvent::Action;
				event.widget = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
				event.action = (int) nmhdr->idFrom;
				event.flags = mxEvent::RightClicked;

				if ( event.widget )
				{
					if ( event.widget->getType () == MX_TREEVIEW )
					{
						RECT rc;
						HTREEITEM hItem = TreeView_GetSelection (nmhdr->hwndFrom);
						TreeView_GetItemRect (nmhdr->hwndFrom, hItem, &rc, TRUE);
						event.x = (int) rc.left;
						event.y = (int) rc.bottom;
					}
				}
				RecursiveHandleEvent( window, &event );
			}
		}
		else if (nmhdr->code == NM_DBLCLK)
		{
			if (nmhdr->idFrom > 0)
			{
				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				event.event = mxEvent::Action;
				event.widget = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
				event.action = (int) nmhdr->idFrom;
				event.flags = mxEvent::DoubleClicked;

				if (event.widget )
				{
					if ( event.widget->getType () == MX_TREEVIEW )
					{
						RECT rc;
						HTREEITEM hItem = TreeView_GetSelection (nmhdr->hwndFrom);
						TreeView_GetItemRect (nmhdr->hwndFrom, hItem, &rc, TRUE);
						event.x = (int) rc.left;
						event.y = (int) rc.bottom;
					}
				}

				RecursiveHandleEvent( window, &event );
				return TRUE;
			}
		}
		else if (nmhdr->code == TCN_SELCHANGING)
		{
			TC_ITEM ti;

			int index = TabCtrl_GetCurSel (nmhdr->hwndFrom);
			if (index >= 0)
			{
				ti.mask = TCIF_PARAM;
				TabCtrl_GetItem (nmhdr->hwndFrom, index, &ti);
				mxWindow *window = (mxWindow *) ti.lParam;
				if (window)
					window->setVisible (false);
			}
		}
		else if (nmhdr->code == TCN_SELCHANGE)
		{
			mxTab_resizeChild (nmhdr->hwndFrom);
			if (nmhdr->idFrom > 0)
			{
				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				event.event = mxEvent::Action;
				event.widget = (mxWidget *) GetWindowLong (nmhdr->hwndFrom, GWL_USERDATA);
				event.action = (int) nmhdr->idFrom;
				RecursiveHandleEvent( window, &event );
			}
		}
	}
	break;

	case WM_SIZE:
	{
		mxEvent event;

		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			event.event = mxEvent::Size;
			event.width = (int) LOWORD (lParam);
			event.height = (int) HIWORD (lParam);
			window->handleEvent (&event);
		}
	}
	break;
	case WM_WINDOWPOSCHANGED:
	{
		mxEvent event;

		
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			event.event = mxEvent::PosChanged;

			WINDOWPOS *wp = ( WINDOWPOS * )lParam;

			event.x			= wp->x;
			event.y			= wp->y;
			event.width		= wp->cx;
			event.height	= wp->cy;

			window->handleEvent (&event);
		}
	}
	break;

	case WM_ERASEBKGND:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			if (window->getType () == MX_GLWINDOW)
				return 0;
			if (window->getType () == MX_MATSYSWINDOW)
				return 0;

			if ( !isClosing && !window->PaintBackground() )
			{
				return 0;
			}
		}
	}
	break;

	case WM_HSCROLL:
	case WM_VSCROLL:
	{
		mxWidget *widget = (mxWidget *) GetWindowLong ((HWND) lParam, GWL_USERDATA);
		if (!widget)
		{
			break;
		}

		if (widget->getType() != MX_SCROLLBAR && widget->getType() != MX_SLIDER)
		{
			break;
		}


		switch (LOWORD (wParam))
		{
		case TB_LINEUP: // 	SB_LINEUP SB_LINELEFT
			break;
		case TB_LINEDOWN: // SB_LINEDOWN SB_LINERIGHT
			break;
		case TB_PAGEUP: // SB_PAGEUP SB_PAGELEFT
			break;
		case TB_PAGEDOWN: // SB_PAGEDOWN SB_PAGERIGHT
			break;
		case TB_THUMBPOSITION:  // SB_THUMBPOSITION
			break;
		case TB_THUMBTRACK: // SB_THUMBTRACK
			break;
		case TB_TOP: // SB_TOP SB_LEFT
			break;
		case TB_BOTTOM: // SB_BOTTOM SB_RIGHT
			break;
		case TB_ENDTRACK: // SB_ENDSCROLL
			break;
		default:
			break;
		}

		switch (LOWORD (wParam))
		{
		case TB_LINEUP: // 	SB_LINEUP SB_LINELEFT
		case TB_LINEDOWN: // SB_LINEDOWN SB_LINERIGHT
		case TB_PAGEUP: // SB_PAGEUP SB_PAGELEFT
		case TB_PAGEDOWN: // SB_PAGEDOWN SB_PAGERIGHT
		case TB_THUMBPOSITION:  // SB_THUMBPOSITION
		case TB_THUMBTRACK: // SB_THUMBTRACK
		case TB_TOP: // SB_TOP SB_LEFT
		case TB_BOTTOM: // SB_BOTTOM SB_RIGHT
		case TB_ENDTRACK: // SB_ENDSCROLL
		{
			mxEvent event;

			event.event = mxEvent::Action;
			event.widget = widget;
			event.action = widget->getId ();
			event.modifiers = LOWORD (wParam);
			event.height = HIWORD( wParam );
			mxWindow *window = widget->getParent ();

			if ( event.action > 0 )
			{
				RecursiveHandleEvent( window, &event );
			}
		}
		break;
		}
	}
	break;

	case WM_PAINT:
	{
		if ( !isClosing )
		{
			mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
			if (window)
			{
				window->redraw ();
			}
		}
	}
	break;

	case WM_PARENTNOTIFY:
		{
			mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
			if (window)
			{
				if ( wParam == WM_LBUTTONDOWN ||
					 wParam == WM_MBUTTONDOWN ||
					 wParam == WM_RBUTTONDOWN /*||
					 wParam & WM_XBUTTONDOWN*/ )
				{
					mxEvent event;
					event.event = mxEvent::ParentNotify;
					event.x = (short)LOWORD (lParam);
					event.y = (short)HIWORD (lParam);
					event.buttons = 0;
					event.modifiers = 0;

					if ( wParam == WM_LBUTTONDOWN )
						event.buttons |= mxEvent::MouseLeftButton;

					if ( wParam == WM_RBUTTONDOWN )
						event.buttons |= mxEvent::MouseRightButton;

					if ( wParam == WM_MBUTTONDOWN )
						event.buttons |= mxEvent::MouseMiddleButton;

					window->handleEvent (&event);
					RecursiveHandleEvent( window, &event );
					return 0;
				}
			}
		}
		break;

	case WM_LBUTTONDOWN:
	case WM_MBUTTONDOWN:
	case WM_RBUTTONDOWN:
	{
		bDragging = TRUE;
		SetCapture (hwnd);
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);

		if (window)
		{
			mxEvent event;
			event.event = mxEvent::MouseDown;
			event.x = (short)LOWORD (lParam);
			event.y = (short)HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			if (uMessage == WM_MBUTTONDOWN)
				event.buttons |= mxEvent::MouseMiddleButton;
			else if (uMessage == WM_RBUTTONDOWN)
				event.buttons |= mxEvent::MouseRightButton;
			else
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_LBUTTON)
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_RBUTTON)
				event.buttons |= mxEvent::MouseRightButton;

			if (wParam & MK_MBUTTON)
				event.buttons |= mxEvent::MouseMiddleButton;

			if (wParam & MK_CONTROL)
				event.modifiers |= mxEvent::KeyCtrl;

			if (wParam & MK_SHIFT)
				event.modifiers |= mxEvent::KeyShift;

			window->handleEvent (&event);
		}
	}
	break;

	case WM_LBUTTONUP:
	case WM_MBUTTONUP:
	case WM_RBUTTONUP:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::MouseUp;
			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			if (uMessage == WM_MBUTTONUP)
				event.buttons |= mxEvent::MouseMiddleButton;
			else if (uMessage == WM_RBUTTONUP)
				event.buttons |= mxEvent::MouseRightButton;
			else
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_LBUTTON)
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_RBUTTON)
				event.buttons |= mxEvent::MouseRightButton;

			if (wParam & MK_MBUTTON)
				event.buttons |= mxEvent::MouseMiddleButton;

			if (wParam & MK_CONTROL)
				event.modifiers |= mxEvent::KeyCtrl;

			if (wParam & MK_SHIFT)
				event.modifiers |= mxEvent::KeyShift;

			window->handleEvent (&event);
		}
		bDragging = FALSE;
		ReleaseCapture ();
	}
	break;

	case WM_MOUSEMOVE:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;

			if (bDragging)
				event.event = mxEvent::MouseDrag;
			else
				event.event = mxEvent::MouseMove;

			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			if (wParam & MK_LBUTTON)
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_RBUTTON)
				event.buttons |= mxEvent::MouseRightButton;

			if (wParam & MK_MBUTTON)
				event.buttons |= mxEvent::MouseMiddleButton;

			if (wParam & MK_CONTROL)
				event.modifiers |= mxEvent::KeyCtrl;

			if (wParam & MK_SHIFT)
				event.modifiers |= mxEvent::KeyShift;

			window->handleEvent (&event);
		}
	}
	break;
	case WM_NCLBUTTONDOWN:
	case WM_NCMBUTTONDOWN:
	case WM_NCRBUTTONDOWN:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);

		if (window)
		{
			mxEvent event;
			event.event = mxEvent::NCMouseDown;
			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			if (uMessage == WM_NCMBUTTONDOWN)
				event.buttons |= mxEvent::MouseMiddleButton;
			else if (uMessage == WM_NCRBUTTONDOWN)
				event.buttons |= mxEvent::MouseRightButton;
			else
				event.buttons |= mxEvent::MouseLeftButton;

			window->handleEvent (&event);
		}
	}
	break;

	case WM_NCLBUTTONUP:
	case WM_NCMBUTTONUP:
	case WM_NCRBUTTONUP:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::NCMouseUp;
			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			if (uMessage == WM_NCMBUTTONUP)
				event.buttons |= mxEvent::MouseMiddleButton;
			else if (uMessage == WM_NCRBUTTONUP)
				event.buttons |= mxEvent::MouseRightButton;
			else
				event.buttons |= mxEvent::MouseLeftButton;

			window->handleEvent (&event);
		}
	}
	break;

	case WM_NCMOUSEMOVE:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;

			event.event = mxEvent::NCMouseMove;

			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);
			event.buttons = 0;
			event.modifiers = 0;

			window->handleEvent (&event);
		}
	}
	break;

	case WM_KEYDOWN:
	case WM_SYSKEYDOWN:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::KeyDown;
			event.key = (int) wParam;
			if ( window->handleEvent (&event) )
				return 0;
		}
	}
	break;

	case WM_CHAR:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::Char;
			event.key = (int) wParam;
			if ( window->handleEvent (&event) )
				return 0;
		}
	}
	break;

	case WM_SYSCHAR:
		return 0;
		break;

	case WM_KEYUP:
	case WM_SYSKEYUP:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::KeyUp;
			event.key = (int) wParam;
			if ( window->handleEvent (&event) )
				return 0;
		}
	}
	break;

	case WM_MOUSEWHEEL:
	{
		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			memset( &event, 0, sizeof( event ) );
			event.event = mxEvent::MouseWheeled;
			event.x = (short) LOWORD (lParam);
			event.y = (short) HIWORD (lParam);

			if (wParam & MK_LBUTTON)
				event.buttons |= mxEvent::MouseLeftButton;

			if (wParam & MK_RBUTTON)
				event.buttons |= mxEvent::MouseRightButton;

			if (wParam & MK_MBUTTON)
				event.buttons |= mxEvent::MouseMiddleButton;

			if (wParam & MK_CONTROL)
				event.modifiers |= mxEvent::KeyCtrl;

			if (wParam & MK_SHIFT)
				event.modifiers |= mxEvent::KeyShift;

			event.height = (short)HIWORD( wParam );;
			RecursiveHandleEvent( window, &event );
		}
	}
	break;
	case WM_TIMER:
	{
		if (isClosing)
			break;

		mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
		if (window)
		{
			mxEvent event;
			event.event = mxEvent::Timer;
			window->handleEvent (&event);
		}
	}
	break;

	case WM_CLOSE:
		if (g_mainWindow)
		{
			if ((void *) hwnd == g_mainWindow->getHandle ())
			{
				mx::quit ();
			}
			else
			{
				ShowWindow (hwnd, SW_HIDE);

				mxWindow *window = (mxWindow *) GetWindowLong (hwnd, GWL_USERDATA);
				if (window)
				{
					mxEvent event;
					event.event = mxEvent::Close;
					window->handleEvent( &event );
				}
			}
		}
		//else // shouldn't happen
			//DestroyWindow (hwnd);
		return 0;
/*
	case WM_DESTROY:
		if (g_mainWindow)
		{
			if ((void *) hwnd == g_mainWindow->getHandle ())
				mx::quit ();
		}
		break;
*/
	}

	return DefWindowProc (hwnd, uMessage, wParam, lParam);
}
Ejemplo n.º 19
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);
			}
Ejemplo n.º 20
0
/*******************************************************************************
 *
 *  FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
 *
 *  PURPOSE:  Processes messages for the child windows.
 *
 *  WM_COMMAND  - process the application menu
 *  WM_PAINT    - Paint the main window
 *  WM_DESTROY  - post a quit message and return
 *
 */
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    BOOL Result;

    switch (message)
    {
    case WM_CREATE:
    {
        WNDPROC oldproc;
        HFONT hFont;
        WCHAR buffer[MAX_PATH];

        /* Load "My Computer" string */
        LoadStringW(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));

        g_pChildWnd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ChildWnd));
        if (!g_pChildWnd) return 0;

        wcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
        g_pChildWnd->nSplitPos = 250;
        g_pChildWnd->hWnd = hWnd;
        g_pChildWnd->hAddressBarWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
                                                      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                                                      hWnd, (HMENU)0, hInst, 0);
        g_pChildWnd->hAddressBtnWnd = CreateWindowExW(0, L"Button", L"»", WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_TEXT | BS_CENTER | BS_VCENTER | BS_FLAT | BS_DEFPUSHBUTTON,
                                                      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                                                      hWnd, (HMENU)0, hInst, 0);
        g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
        g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, g_pChildWnd->szPath*/);
        SetFocus(g_pChildWnd->hTreeWnd);

        /* set the address bar and button font */
        if ((g_pChildWnd->hAddressBarWnd) && (g_pChildWnd->hAddressBtnWnd))
        {
            hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessageW(g_pChildWnd->hAddressBarWnd,
                         WM_SETFONT,
                         (WPARAM)hFont,
                         0);
            SendMessageW(g_pChildWnd->hAddressBtnWnd,
                         WM_SETFONT,
                         (WPARAM)hFont,
                         0);
        }
        /* Subclass the AddressBar */
        oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_WNDPROC);
        SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_USERDATA, (DWORD_PTR)oldproc);
        SetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWLP_WNDPROC, (DWORD_PTR)AddressBarProc);
        break;
    }
    case WM_COMMAND:
        if(HIWORD(wParam) == BN_CLICKED)
        {
            PostMessageW(g_pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
        }

        if (!_CmdWndProc(hWnd, message, wParam, lParam))
        {
            goto def;
        }
        break;
    case WM_PAINT:
        OnPaint(hWnd);
        return 0;
    case WM_SETCURSOR:
        if (LOWORD(lParam) == HTCLIENT)
        {
            POINT pt;
            GetCursorPos(&pt);
            ScreenToClient(hWnd, &pt);
            if (pt.x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
            {
                SetCursor(LoadCursorW(0, IDC_SIZEWE));
                return TRUE;
            }
        }
        goto def;
    case WM_DESTROY:
        DestroyTreeView();
        DestroyListView(g_pChildWnd->hListWnd);
        DestroyMainMenu();
        HeapFree(GetProcessHeap(), 0, g_pChildWnd);
        g_pChildWnd = NULL;
        PostQuitMessage(0);
        break;
    case WM_LBUTTONDOWN:
    {
        RECT rt;
        int x = (short)LOWORD(lParam);
        GetClientRect(hWnd, &rt);
        if (x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
        {
            last_split = g_pChildWnd->nSplitPos;
            draw_splitbar(hWnd, last_split);
            SetCapture(hWnd);
        }
        break;
    }

    case WM_LBUTTONUP:
    case WM_RBUTTONDOWN:
        if (GetCapture() == hWnd)
        {
            finish_splitbar(hWnd, LOWORD(lParam));
        }
        break;

    case WM_CAPTURECHANGED:
        if (GetCapture()==hWnd && last_split>=0)
            draw_splitbar(hWnd, last_split);
        break;

    case WM_KEYDOWN:
        if (wParam == VK_ESCAPE)
            if (GetCapture() == hWnd)
            {
                RECT rt;
                draw_splitbar(hWnd, last_split);
                GetClientRect(hWnd, &rt);
                ResizeWnd(rt.right, rt.bottom);
                last_split = -1;
                ReleaseCapture();
                SetCursor(LoadCursorW(0, IDC_ARROW));
            }
        break;

    case WM_MOUSEMOVE:
        if (GetCapture() == hWnd)
        {
            HDC hdc;
            RECT rt;
            HGDIOBJ OldObj;
            int x = LOWORD(lParam);
            if(!SizingPattern)
            {
                const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
                SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
            }
            if(!SizingBrush)
            {
                SizingBrush = CreatePatternBrush(SizingPattern);
            }

            GetClientRect(hWnd, &rt);
            x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN);
            if(last_split != x)
            {
                rt.left = last_split-SPLIT_WIDTH/2;
                rt.right = last_split+SPLIT_WIDTH/2+1;
                hdc = GetDC(hWnd);
                OldObj = SelectObject(hdc, SizingBrush);
                PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
                last_split = x;
                rt.left = x-SPLIT_WIDTH/2;
                rt.right = x+SPLIT_WIDTH/2+1;
                PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
                SelectObject(hdc, OldObj);
                ReleaseDC(hWnd, hdc);
            }
        }
        break;

    case WM_SETFOCUS:
        if (g_pChildWnd != NULL)
        {
            SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
        }
        break;

    case WM_TIMER:
        break;

    case WM_NOTIFY:
        if ((int)wParam == TREE_WINDOW && g_pChildWnd != NULL)
        {
            switch (((LPNMHDR)lParam)->code)
            {
            case TVN_ITEMEXPANDING:
                return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
            case TVN_SELCHANGED:
                UpdateAddress(((NMTREEVIEW*)lParam)->itemNew.hItem, NULL, NULL);
                break;
            case NM_SETFOCUS:
                g_pChildWnd->nFocusPanel = 0;
                break;
            case TVN_BEGINLABELEDIT:
            {
                LPNMTVDISPINFO ptvdi;
                /* cancel label edit for rootkeys  */
                ptvdi = (LPNMTVDISPINFO) lParam;
                if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
                    !TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem)))
                    return TRUE;
                break;
            }
            case TVN_ENDLABELEDIT:
            {
                LPCWSTR keyPath;
                HKEY hRootKey;
                HKEY hKey = NULL;
                LPNMTVDISPINFO ptvdi;
                LONG lResult = TRUE;
                WCHAR szBuffer[MAX_PATH];

                ptvdi = (LPNMTVDISPINFO) lParam;
                if (ptvdi->item.pszText)
                {
                    keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
                    _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText);
                    keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
                    if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
                    {
                        lResult = FALSE;
                        RegCloseKey(hKey);
                        (void)TreeView_EditLabel(g_pChildWnd->hTreeWnd, ptvdi->item.hItem);
                    }
                    else
                    {
                        if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
                            lResult = FALSE;
                        else
                            UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer);
                    }
                    return lResult;
                }
            }
            default:
                return 0;
            }
        }
        else
        {
            if ((int)wParam == LIST_WINDOW && g_pChildWnd != NULL)
            {
                switch (((LPNMHDR)lParam)->code)
                {
                case NM_SETFOCUS:
                    g_pChildWnd->nFocusPanel = 1;
                    break;
                default:
                    if(!ListWndNotifyProc(g_pChildWnd->hListWnd, wParam, lParam, &Result))
                    {
                        goto def;
                    }
                    return Result;
                    break;
                }
            }
        }
        break;

    case WM_CONTEXTMENU:
    {
        POINT pt;
        if((HWND)wParam == g_pChildWnd->hListWnd)
        {
            int i, cnt;
            BOOL IsDefault;
            pt.x = (short) LOWORD(lParam);
            pt.y = (short) HIWORD(lParam);
            cnt = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
            i = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
            if (pt.x == -1 && pt.y == -1)
            {
                RECT rc;
                if (i != -1)
                {
                    rc.left = LVIR_BOUNDS;
                    SendMessageW(g_pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
                    pt.x = rc.left + 8;
                    pt.y = rc.top + 8;
                }
                else
                    pt.x = pt.y = 0;
                ClientToScreen(g_pChildWnd->hListWnd, &pt);
            }
            if(i == -1)
            {
                TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
            }
            else
            {
                HMENU mnu = GetSubMenu(hPopupMenus, PM_MODIFYVALUE);
                SetMenuDefaultItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND);
                IsDefault = IsDefaultValue(g_pChildWnd->hListWnd, i);
                if(cnt == 1)
                    EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | (IsDefault ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
                else
                    EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
                EnableMenuItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));
                EnableMenuItem(mnu, ID_EDIT_MODIFY_BIN, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));

                TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
            }
        }
        else if ((HWND)wParam == g_pChildWnd->hTreeWnd)
        {
            TVHITTESTINFO hti;
            HMENU hContextMenu;
            TVITEMW item;
            MENUITEMINFOW mii;
            WCHAR resource[256];
            WCHAR buffer[256];
            LPWSTR s;
            LPCWSTR keyPath;
            HKEY hRootKey;
            int iLastPos;
            WORD wID;

            pt.x = (short) LOWORD(lParam);
            pt.y = (short) HIWORD(lParam);

            if (pt.x == -1 && pt.y == -1)
            {
                RECT rc;
                hti.hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
                if (hti.hItem != NULL)
                {
                    TreeView_GetItemRect(g_pChildWnd->hTreeWnd, hti.hItem, &rc, TRUE);
                    pt.x = rc.left + 8;
                    pt.y = rc.top + 8;
                    ClientToScreen(g_pChildWnd->hTreeWnd, &pt);
                    hti.flags = TVHT_ONITEM;
                }
                else
                    hti.flags = 0;
            }
            else
            {
                hti.pt.x = pt.x;
                hti.pt.y = pt.y;
                ScreenToClient(g_pChildWnd->hTreeWnd, &hti.pt);
                (void)TreeView_HitTest(g_pChildWnd->hTreeWnd, &hti);
            }

            if (hti.flags & TVHT_ONITEM)
            {
                hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT);
                (void)TreeView_SelectItem(g_pChildWnd->hTreeWnd, hti.hItem);

                memset(&item, 0, sizeof(item));
                item.mask = TVIF_STATE | TVIF_CHILDREN;
                item.hItem = hti.hItem;
                (void)TreeView_GetItem(g_pChildWnd->hTreeWnd, &item);

                /* Set the Expand/Collapse menu item appropriately */
                LoadStringW(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
                memset(&mii, 0, sizeof(mii));
                mii.cbSize = sizeof(mii);
                mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
                mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
                mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
                mii.dwTypeData = (LPWSTR) buffer;
                SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);

                /* Remove any existing suggestions */
                memset(&mii, 0, sizeof(mii));
                mii.cbSize = sizeof(mii);
                mii.fMask = MIIM_ID;
                GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii);
                if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX))
                {
                    do
                    {
                        iLastPos = GetMenuItemCount(hContextMenu) - 1;
                        GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii);
                        RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION);
                    }
                    while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX));
                }

                /* Come up with suggestions */
                keyPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hRootKey);
                SuggestKeys(hRootKey, keyPath, Suggestions, COUNT_OF(Suggestions));
                if (Suggestions[0])
                {
                    AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);

                    LoadStringW(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));

                    s = Suggestions;
                    wID = ID_TREE_SUGGESTION_MIN;
                    while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
                    {
                        _snwprintf(buffer, COUNT_OF(buffer), resource, s);

                        memset(&mii, 0, sizeof(mii));
                        mii.cbSize = sizeof(mii);
                        mii.fMask = MIIM_STRING | MIIM_ID;
                        mii.wID = wID++;
                        mii.dwTypeData = buffer;
                        InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);

                        s += wcslen(s) + 1;
                    }
                }
                TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_pChildWnd->hWnd, NULL);
            }
        }
        break;
    }

    case WM_SIZE:
        if (wParam != SIZE_MINIMIZED && g_pChildWnd != NULL)
        {
            ResizeWnd(LOWORD(lParam), HIWORD(lParam));
        }
        /* fall through */
    default:
def:
        return DefWindowProcW(hWnd, message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 21
0
INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
	{
		int hbuf = 0, seq = 0;
		HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);

		TranslateDialogDefault(hwndDlg);
		rowOptTmplStr = db_get_sa(NULL, "ModernData", "RowTemplate");
		if (!rowOptTmplStr)
			rowOptTmplStr = mir_strdup("<TR />");

		SendDlgItemMessage(hwndDlg, IDC_SPINCONTWIDTH, UDM_SETRANGE, 0, MAKELONG(999, 0));
		SendDlgItemMessage(hwndDlg, IDC_SPINCONTHEIGHT, UDM_SETRANGE, 0, MAKELONG(999, 0));

		int i, item;

		for (i = 0; i < _countof(types); i++) {
			item = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(types[i]));
			SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETITEMDATA, item, 0);
		}
		SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETCURSEL, 0, 0);

		TCHAR *h_alignment[] = { _T("left"), _T("hCenter"), _T("right") };
		for (i = 0; i < _countof(h_alignment); i++) {
			item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(h_alignment[i]));
			SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETITEMDATA, item, 0);
		}
		SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETCURSEL, 0, 0);

		TCHAR *v_alignment[] = { _T("top"), _T("vCenter"), _T("bottom") };
		for (i = 0; i < _countof(v_alignment); i++) {
			item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(v_alignment[i]));
			SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETITEMDATA, item, 0);
		}
		SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETCURSEL, 0, 0);

		rowDeleteTree(rowOptTmplRoot);
		rowOptTmplRoot = NULL;
		rowParse(rowOptTmplRoot, rowOptTmplRoot, rowOptTmplStr, hbuf, seq, rowOptTA);
		seq = 0;
		memset(rowOptTA, 0, sizeof(rowOptTA));
		rowOptBuildTA(rowOptTmplRoot, (pROWCELL*)&rowOptTA, &seq);

		rowOptFillRowTree(htree);
		RefreshTree(hwndDlg, NULL);
		TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_ROWTREE), TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_ROWTREE)));
		rowOptShowSettings(hwndDlg);
	}
	return TRUE;

	case WM_COMMAND:
	{
		HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);
		pROWCELL  cell;
		TVITEM    tvi = { 0 };
		HTREEITEM hti = TreeView_GetSelection(htree);


		tvi.hItem = hti;
		tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		TreeView_GetItem(htree, &tvi);
		cell = (pROWCELL)tvi.lParam;

		switch (LOWORD(wParam)) {
		case IDC_CONTTYPE:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				int index = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_GETCURSEL, 0, 0);
				cell->type = index;
				RefreshTree(hwndDlg, NULL);
			}

		case IDC_VALIGN:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				switch (SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_GETCURSEL, 0, 0)) {
				case 0:
					cell->valign = TC_TOP;
					break;
				case 1:
					cell->valign = TC_VCENTER;
					break;
				case 2:
					cell->valign = TC_BOTTOM;
					break;
				}
				RefreshTree(hwndDlg, NULL);
			}

		case IDC_HALIGN:
			if (HIWORD(wParam) == CBN_SELENDOK) {
				switch (SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_GETCURSEL, 0, 0)) {
				case 0:
					cell->halign = TC_LEFT;
					break;
				case 1:
					cell->halign = TC_HCENTER;
					break;
				case 2:
					cell->halign = TC_RIGHT;
					break;
				}
				RefreshTree(hwndDlg, NULL);
			}
		}

		if (HIWORD(wParam) == BN_CLICKED) {
			if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_ADDCONTAINER))
				// Adding new container
			{
				rowOptAddContainer(htree, hti);
			}
			else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_DELCONTAINER))
				// Deleting container
			{
				rowOptDelContainer(htree, hti);
			}
			else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_CONTUP))
				// Moving container to up
			{
				RedrawWindow(htree, &da, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
			}
			RefreshTree(hwndDlg, NULL);
			RedrawWindow(GetParent(hwndDlg), NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
		}
		return TRUE;
	}

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case IDC_ROWTREE:
			if (((LPNMHDR)lParam)->code == NM_SETCURSOR)
				rowOptShowSettings(hwndDlg);
			if (((LPNMHDR)lParam)->code == NM_CLICK)
				RedrawWindow(hwndDlg, &da, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
			break;

		case 0: // Apply or Ok button is pressed
			return FALSE; // Temporary
			break;
		}
		return TRUE;

	case WM_PAINT:
		if (rowOptTmplRoot) {
			int i = 0;

			// Drawning row template at properties page
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(hwndDlg, &ps);

			TVITEM curItem;
			curItem.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_ROWTREE));
			curItem.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
			TreeView_GetItem(GetDlgItem(hwndDlg, IDC_ROWTREE), &curItem);

			while (rowOptTA[i]) {
				switch (rowOptTA[i]->type) {
				case TC_AVATAR:
					rowOptTA[i]->w = 25;
					rowOptTA[i]->h = 30;
					break;

				case TC_STATUS:
				case TC_EXTRA1:
				case TC_EXTRA2:
				case TC_EXTRA3:
				case TC_EXTRA4:
				case TC_EXTRA5:
				case TC_EXTRA6:
				case TC_EXTRA7:
				case TC_EXTRA8:
				case TC_EXTRA9:
					rowOptTA[i]->w = 16;
					rowOptTA[i]->h = 16;
					break;

				case TC_EXTRA:
					rowOptTA[i]->w = 112;
					rowOptTA[i]->h = 16;
					break;

				case TC_TEXT1:
				case TC_TEXT2:
				case TC_TEXT3:
					rowOptTA[i]->w = 200;
					rowOptTA[i]->h = 16;
					break;

				case TC_TIME:
					rowOptTA[i]->w = 30;
					rowOptTA[i]->h = 10;
				default:
					rowOptTA[i]->w = 0;
					rowOptTA[i]->h = 0;
				}
				i++;
			}

			rowSizeWithReposition(rowOptTmplRoot, da.right - da.left);

			i = -1;
			while (rowOptTA[++i]) {

				switch (rowOptTA[i]->type) {
				case TC_SPACE:
				case TC_FIXED:
				case 0:
					//if (rowOptTA[i] != (pROWCELL)curItem.lParam)
					continue;
				}
				Rectangle(hdc,
					rowOptTA[i]->r.left + da.left,
					rowOptTA[i]->r.top + da.top,
					rowOptTA[i]->r.right + da.left,
					rowOptTA[i]->r.bottom + da.top);
			}

			EndPaint(hwndDlg, &ps);
			return FALSE;
		}

	}
	return FALSE;
}
Ejemplo n.º 22
0
/*******************************************************************************
 *
 *  FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
 *
 *  PURPOSE:  Processes WM_COMMAND messages for the main frame window.
 *
 */
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HKEY hKeyRoot = 0, hKey = 0;
    LPCTSTR keyPath;
    LPCTSTR valueName;
    BOOL result = TRUE;
    REGSAM regsam = KEY_READ;
    LONG lRet;
    int item;

    UNREFERENCED_PARAMETER(lParam);
    UNREFERENCED_PARAMETER(message);

    switch (LOWORD(wParam))
    {
    case ID_REGISTRY_LOADHIVE:
        LoadHive(hWnd);
        return TRUE;
    case ID_REGISTRY_UNLOADHIVE:
        UnloadHive(hWnd);
        return TRUE;
    case ID_REGISTRY_IMPORTREGISTRYFILE:
        ImportRegistryFile(hWnd);
        return TRUE;
    case ID_REGISTRY_EXPORTREGISTRYFILE:
        ExportRegistryFile(hWnd);
        return TRUE;
    case ID_REGISTRY_CONNECTNETWORKREGISTRY:
    {
        IDsObjectPicker *ObjectPicker;
        TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
        HRESULT hRet;

        hRet = CoInitialize(NULL);
        if (SUCCEEDED(hRet))
        {
            hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
            if (SUCCEEDED(hRet))
            {
                hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
                                                        hWnd,
                                                        szComputerName,
                                                        sizeof(szComputerName) / sizeof(szComputerName[0]));
                if (hRet == S_OK)
                {
                    /* FIXME - connect to the registry */
                }

                FreeObjectPicker(ObjectPicker);
            }

            CoUninitialize();
        }

        return TRUE;
    }
    case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
        return TRUE;
    case ID_REGISTRY_PRINT:
        PrintRegistryHive(hWnd, _T(""));
        return TRUE;
    case ID_REGISTRY_EXIT:
        DestroyWindow(hWnd);
        return TRUE;
    case ID_VIEW_STATUSBAR:
        toggle_child(hWnd, LOWORD(wParam), hStatusBar);
        return TRUE;
    case ID_HELP_HELPTOPICS:
        WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
        return TRUE;
    case ID_HELP_ABOUT:
        ShowAboutBox(hWnd);
        return TRUE;
    case ID_VIEW_SPLIT:
    {
        RECT rt;
        POINT pt, pts;
        GetClientRect(g_pChildWnd->hWnd, &rt);
        pt.x = rt.left + g_pChildWnd->nSplitPos;
        pt.y = (rt.bottom / 2);
        pts = pt;
        if(ClientToScreen(g_pChildWnd->hWnd, &pts))
        {
            SetCursorPos(pts.x, pts.y);
            SetCursor(LoadCursor(0, IDC_SIZEWE));
            SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
        }
        return TRUE;
    }
    case ID_EDIT_RENAME:
    case ID_EDIT_MODIFY:
    case ID_EDIT_MODIFY_BIN:
    case ID_EDIT_DELETE:
        regsam |= KEY_WRITE;
        break;
    }

    keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
    valueName = GetValueName(g_pChildWnd->hListWnd, -1);
    if (keyPath)
    {
        lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
        if (lRet != ERROR_SUCCESS) hKey = 0;
    }

    switch (LOWORD(wParam))
    {
    case ID_EDIT_MODIFY:
        if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
            RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
        break;
    case ID_EDIT_MODIFY_BIN:
        if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
            RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
        break;
    case ID_EDIT_RENAME:
        if (GetFocus() == g_pChildWnd->hListWnd)
        {
            if(ListView_GetSelectedCount(g_pChildWnd->hListWnd) == 1)
            {
                item = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_SELECTED);
                if(item > -1)
                {
                    (void)ListView_EditLabel(g_pChildWnd->hListWnd, item);
                }
            }
        }
        else if (GetFocus() == g_pChildWnd->hTreeWnd)
        {
            /* Get focused entry of treeview (if any) */
            HTREEITEM hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
            if (hItem != NULL)
                (void)TreeView_EditLabel(g_pChildWnd->hTreeWnd, hItem);
        }
        break;
    case ID_EDIT_DELETE:
    {
        if (GetFocus() == g_pChildWnd->hListWnd)
        {
            UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
            if(nSelected >= 1)
            {
                TCHAR msg[128], caption[128];
                LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
                LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR));
                if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
                {
                    int ni, errs;

                    item = -1;
                    errs = 0;
                    while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
                    {
                        valueName = GetValueName(g_pChildWnd->hListWnd, item);
                        if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
                        {
                            errs++;
                        }
                        item = ni;
                    }

                    RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
                    if(errs > 0)
                    {
                        LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
                        LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR));
                        MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
                    }
                }
            }
        }
        else if (GetFocus() == g_pChildWnd->hTreeWnd)
        {
            if (keyPath == 0 || *keyPath == 0)
            {
                MessageBeep(MB_ICONHAND);
            }
            else if (DeleteKey(hWnd, hKeyRoot, keyPath))
            {
                DeleteNode(g_pChildWnd->hTreeWnd, 0);
                RefreshTreeView(g_pChildWnd->hTreeWnd);
            }
        }
        break;
    }
    case ID_EDIT_NEW_STRINGVALUE:
        CreateNewValue(hKeyRoot, keyPath, REG_SZ);
        break;
    case ID_EDIT_NEW_BINARYVALUE:
        CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
        break;
    case ID_EDIT_NEW_DWORDVALUE:
        CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
        break;
    case ID_EDIT_NEW_MULTISTRINGVALUE:
        CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
        break;
    case ID_EDIT_NEW_EXPANDABLESTRINGVALUE:
        CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
        break;
    case ID_EDIT_FIND:
        FindDialog(hWnd);
        break;
    case ID_EDIT_FINDNEXT:
        FindNext(hWnd);
        break;
    case ID_EDIT_COPYKEYNAME:
        CopyKeyName(hWnd, hKeyRoot, keyPath);
        break;
    case ID_EDIT_PERMISSIONS:
        RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
        break;
    case ID_REGISTRY_PRINTERSETUP:
        /*PRINTDLG pd;*/
        /*PrintDlg(&pd);*/
        /*PAGESETUPDLG psd;*/
        /*PageSetupDlg(&psd);*/
        break;
    case ID_REGISTRY_OPENLOCAL:
        break;

    case ID_VIEW_REFRESH:
        RefreshTreeView(g_pChildWnd->hTreeWnd);
        /*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
        break;
        /*case ID_OPTIONS_TOOLBAR:*/
        /*	toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
        /*    break;*/
    case ID_EDIT_NEW_KEY:
        CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
        break;
    default:
        if ((LOWORD(wParam) >= ID_FAVORITES_MIN) && (LOWORD(wParam) <= ID_FAVORITES_MAX))
        {
            HMENU hMenu;
            MENUITEMINFO mii;
            TCHAR szFavorite[512];

            hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION);

            memset(&mii, 0, sizeof(mii));
            mii.cbSize = sizeof(mii);
            mii.fMask = MIIM_TYPE;
            mii.fType = MFT_STRING;
            mii.dwTypeData = szFavorite;
            mii.cch = sizeof(szFavorite) / sizeof(szFavorite[0]);

            if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
            {
                ChooseFavorite(szFavorite);
            }
        }
        else
        {
            result = FALSE;
        }
        break;
    }

    if(hKey)
        RegCloseKey(hKey);
    return result;
}
Ejemplo n.º 23
0
void Explorerplusplus::OnTreeViewRightClick(WPARAM wParam,LPARAM lParam)
{
	LPITEMIDLIST pidl = NULL;
	POINT *ppt = NULL;
	HTREEITEM hItem;
	HTREEITEM hPrevItem;
	IShellFolder *pShellParentFolder = NULL;
	LPITEMIDLIST pidlRelative = NULL;
	HRESULT hr;

	hItem	= (HTREEITEM)wParam;
	ppt		= (POINT *)lParam;

	m_bTreeViewRightClick = TRUE;

	hPrevItem = TreeView_GetSelection(m_hTreeView);
	TreeView_SelectItem(m_hTreeView,hItem);
	pidl = m_pMyTreeView->BuildPath(hItem);

	hr = SHBindToParent(pidl, IID_PPV_ARGS(&pShellParentFolder),
	(LPCITEMIDLIST *)&pidlRelative);

	if(SUCCEEDED(hr))
	{
		HTREEITEM hParent;
		LPITEMIDLIST pidlParent	= NULL;

		hParent = TreeView_GetParent(m_hTreeView,hItem);

		/* If we right-click on the "Desktop" item in the treeview, there is no parent.
		   In such case, use "Desktop" as parent item as well, to allow the context menu
		   to be shown. */
		if(hParent == NULL)
		{
			hParent = hItem;
		}

		if(hParent != NULL)
		{
			pidlParent = m_pMyTreeView->BuildPath(hParent);

			if(pidlParent != NULL)
			{
				m_bTreeViewOpenInNewTab = FALSE;

				std::list<LPITEMIDLIST> pidlList;

				pidlList.push_back(pidlRelative);

				CFileContextMenuManager fcmm(m_hContainer,pidlParent,
					pidlList);

				FileContextMenuInfo_t fcmi;
				fcmi.uFrom = FROM_TREEVIEW;

				CStatusBar StatusBar(m_hStatusBar);

				fcmm.ShowMenu(this,MIN_SHELL_MENU_ID,MAX_SHELL_MENU_ID,ppt,&StatusBar,
					reinterpret_cast<DWORD_PTR>(&fcmi),TRUE,GetKeyState(VK_SHIFT) & 0x80);

				CoTaskMemFree(pidlParent);
			}
		}

		pShellParentFolder->Release();
	}

	/* Don't switch back to the previous folder if
	the folder that was right-clicked was opened in
	a new tab (i.e. can just keep the selection the
	same). */
	if(!m_bTreeViewOpenInNewTab)
		TreeView_SelectItem(m_hTreeView,hPrevItem);

	m_bTreeViewRightClick = FALSE;

	CoTaskMemFree(pidl);
}
Ejemplo n.º 24
0
INT CALLBACK ShareDialog::dialogProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch ( msg )
	{
		case WM_COMMAND:
		{
			switch ( wParam )
			{
				case IDCANCEL:
				{
					EndDialog(hWnd,0);
				}
				break;

				case IDOK:
				{
					std::string name = WinUtil::WindowUtil::getWindowText(GetDlgItem(m_setupPage.getHwnd(),IDC_EDIT_VIRTUALNAME));
					std::string path = WinUtil::WindowUtil::getWindowText(GetDlgItem(m_setupPage.getHwnd(),IDC_EDIT_PATH));
					std::string oldPath = m_pShare->getPath();

					if ( name.empty() ) {
						MessageBox(hWnd,WinUtil::ResourceUtil::loadString(IDS_INVALIDVIRTUALNAME).c_str(),APP_NAME,MB_ICONEXCLAMATION);
						break;
					}

					if ( path.empty() ) {
						MessageBox(hWnd,WinUtil::ResourceUtil::loadString(IDS_INVALIDPATH).c_str(),APP_NAME,MB_ICONEXCLAMATION);
						break;
					}

					// make sure a share with this name doesn't already exist
					if ( !boost::iequals(m_pShare->getName(),name)
						&& ShareManager::getInstance()->findShareByName(name,NULL) ) {
						MessageBox(hWnd,WinUtil::ResourceUtil::loadString(IDS_SHAREEXISTS).c_str(),APP_NAME,MB_ICONEXCLAMATION);
						break;
					}

					m_setupPage.savePage(m_pShare);
					m_permissionsPage.savePage(m_pShare);

					// check if path was changed
					if ( !m_pShare->getGuid().empty() && m_pShare->getPath()!=oldPath ) {
						if ( MessageBox(this->getHwnd(),"Share path has been changed. Do you want to re-index this share?",
							TEXT(APP_NAME),MB_ICONQUESTION | MB_YESNO)==IDYES ) {
							Indexer::getInstance()->queue(IndexerJob(m_pShare->getDbId(),false));
						}
					}

					// check if no permissions was set
					if ( m_pShare->getPermissions().empty() )
					{
						if ( MessageBox(this->getHwnd(),"Should all authenticated users be able to access this share?",
							TEXT(APP_NAME),MB_ICONQUESTION | MB_YESNO)==IDYES ) 
						{
							// add permission for everyone
							m_pShare->addPermission(Permission("","","",true));
						}
					}

					EndDialog(hWnd,1);
				}
				break;
			}
		}
		break;

		case WM_NOTIFY: 
		{
			LPNMHDR pNmhdr = (LPNMHDR)lParam;
			if ( pNmhdr->hwndFrom==m_hTreeView && pNmhdr->code==TVN_SELCHANGING )
			{
				HTREEITEM selectedItem = TreeView_GetSelection(m_hTreeView);
				DialogWindow *pSelectedDialog = (DialogWindow*)WinUtil::TreeViewUtil::getItemParam(m_hTreeView,selectedItem);
				if ( pSelectedDialog!=NULL ) {
					ShowWindow(pSelectedDialog->getHwnd(),SW_HIDE);
				}
			}
			else if ( pNmhdr->hwndFrom==m_hTreeView && pNmhdr->code==TVN_SELCHANGED )
			{
				HTREEITEM selectedItem = TreeView_GetSelection(m_hTreeView);
				DialogWindow *pSelectedDialog = (DialogWindow*)WinUtil::TreeViewUtil::getItemParam(m_hTreeView,selectedItem);
				if ( pSelectedDialog!=NULL ) {
					ShowWindow(pSelectedDialog->getHwnd(),SW_SHOW);
				}
			}
		}
		break;

	}

	return 0;
}
Ejemplo n.º 25
0
LRESULT CALLBACK ProjectProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)
{
    int i;
    RECT rs;
    NM_TREEVIEW *nm;
    DWINFO info;
    LPNMTVKEYDOWN key;
    PROJECTITEM *data;
    TVHITTESTINFO hittest;
    HWND win;
    HTREEITEM oldSel;
    static HCURSOR origCurs;
    static BOOL dragging;
    static BOOL inView;
    static HTREEITEM srcItem, dstItem;
    switch (iMessage)
    {
        LOGFONT lf;
        case WM_SYSCOMMAND:
            if (wParam == SC_CLOSE)
                SendMessage(hwnd, WM_CLOSE, 0, 0);
            break;
//        case WM_SETTEXT:
//            return SendMessage(hwndTab, iMessage, wParam, lParam);
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            SetFocus(hwnd);
            break;
        case WM_NOTIFY:
            nm = (NM_TREEVIEW*)lParam;
            switch (nm->hdr.code)
            {
            case NM_CUSTOMDRAW:
                return CustomDraw(hwnd, (LPNMTVCUSTOMDRAW)nm);
            case N_EDITDONE:
                DoneRenaming();
                break;
            case TVN_BEGINDRAG:
                GetCursorPos(&hittest.pt);
                ScreenToClient(prjTreeWindow, &hittest.pt);
                srcItem = TreeView_HitTest(prjTreeWindow, &hittest);
                data = GetItemInfo(srcItem);
                if (data && (data->type == PJ_FILE || data->type == PJ_FOLDER))
                {
                    dragging = TRUE;
                    SetCapture(hwnd);
                    origCurs = SetCursor(dragCur);
                    inView = TRUE;
                }
                break;
            case TVN_KEYDOWN:
                key = (LPNMTVKEYDOWN)lParam;
                switch (key->wVKey)
                {
                    case VK_INSERT:
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            data = GetItemInfo(prjSelectedItem);
                            if (data)
                            {
                                int msg = -1;
                                switch (data->type)
                                {
                                    case PJ_WS:
                                        msg = IDM_EXISTINGPROJECT;
                                        break;
                                    case PJ_PROJ:
                                        msg = IDM_NEWFOLDER;
                                        break;
                                    case PJ_FOLDER:
                                        msg = IDM_EXISTINGFILE;
                                        break;
                                }
                                if (msg != -1)
                                    PostMessage(hwnd, WM_COMMAND, msg, 0);
                            }
                        }
                        else if (GetKeyState(VK_SHIFT) &0x80000000)
                        {
                            data = GetItemInfo(prjSelectedItem);
                            if (data)
                            {
                                int msg = -1;
                                switch (data->type)
                                {
                                    case PJ_WS:
                                        msg = IDM_NEWPROJECT;
                                        break;
                                    case PJ_PROJ:
                                        msg = IDM_NEWFOLDER;
                                        break;
                                    case PJ_FOLDER:
                                        msg = IDM_NEWFILE_P;
                                        break;
                                }
                                if (msg != -1)
                                    PostMessage(hwnd, WM_COMMAND, msg, 0);
                            }
                        }
                        else 
                        {
                            data = GetItemInfo(prjSelectedItem);
                            if (data && (data->type != PJ_WS))
                                PostMessage(hwnd, WM_COMMAND, IDM_RENAME, 0);
                        }
                        break;
                    case VK_DELETE:
                        if (!(GetKeyState(VK_CONTROL) &0x80000000) && !(GetKeyState(VK_SHIFT) &0x8000000))
                        {
                            data = GetItemInfo(prjSelectedItem);
                            if (data && (data->type == PJ_FOLDER || data->type == PJ_FILE))
                                PostMessage(hwnd, WM_COMMAND, IDM_REMOVE, 0);
                        }
                        break;
                    case VK_RETURN:
                        SendMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0);
                        break;
                    }
                    break;
                case NM_DBLCLK:
                    oldSel = prjSelectedItem;
                    GetCursorPos(&hittest.pt);
                    ScreenToClient(prjTreeWindow, &hittest.pt);
                    prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest);
                    if (prjSelectedItem)
                        PostMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0);
                    prjSelectedItem = oldSel;
                    return 0;
                case NM_RCLICK:
                    GetCursorPos(&hittest.pt);
                    ScreenToClient(prjTreeWindow, &hittest.pt);
                    prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest);
                    if (prjSelectedItem)
                    {
                        TreeView_SelectItem(prjTreeWindow, prjSelectedItem);
                    }
                    CreateProjectMenu();
                    break;
                case TVN_SELCHANGED:
                    nm = (NM_TREEVIEW*)lParam;
                    prjSelectedItem = nm->itemNew.hItem;
                    if (prjSelectedItem == 0)
                        prjSelectedItem = workArea->hTreeItem;
                    break;
                case TVN_ITEMEXPANDED:
                    nm = (NM_TREEVIEW *)lParam;
                    data = GetItemInfo(nm->itemNew.hItem);
                    if (data)
                    {
                        if (data->type == PJ_FOLDER)
                        {
                            TV_ITEM setitem;
                            memset(&setitem, 0, sizeof(setitem));
                            setitem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
                            setitem.iImage = setitem.iSelectedImage = 
                                nm->action == TVE_EXPAND ? ilfolderOpen : ilfolderClose;
                            setitem.hItem = nm->itemNew.hItem;
                            TreeView_SetItem(prjTreeWindow, &setitem);
                        }
                        if (nm->action == TVE_EXPAND)
                        {
                            data->expanded = TRUE;
                        }
                        else
                            data->expanded = FALSE;
                        return 0;
                    }
                    break;
                case TVN_DELETEITEM:
                    nm = (NM_TREEVIEW *)lParam;
                    if (nm->itemOld.hItem == prjSelectedItem)
                        prjSelectedItem = TreeView_GetSelection(prjTreeWindow);
                    break;
            }
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case ID_TBPROFILE:
                    if (HIWORD(wParam) == CBN_SELENDOK)
                    {
                        int i = SendMessage(hwndTbProfile, CB_GETCURSEL, 0 , 0);
                        if (i != CB_ERR)
                        {
                            if (i == 0)
                            {
                                strcpy(currentProfileName, sysProfileName);
                            }
                            else
                            {
                                PROFILENAMELIST *pf = profileNames;
                                while (pf && --i)
                                    pf = pf->next;
                                if (pf)
                                {
                                    strcpy(currentProfileName, pf->name);
                                }
                            }
                            MarkChanged(workArea, TRUE);
                        }
                    }
                    break;
                case ID_TBBUILDTYPE:
                    if (HIWORD(wParam) == CBN_SELENDOK)
                    {
                        int i = SendMessage(hwndTbBuildType, CB_GETCURSEL, 0 , 0);
                        if (i != CB_ERR)
                        {
                            profileDebugMode = i == 0 ? 1 : 0;
                            MarkChanged(workArea, TRUE);
                        }
                    }
                    break;
                case IDM_RESETPROFILECOMBOS:
                {
                    HWND htemp;
                    PROFILENAMELIST *pf;
                    int selected,n;
                    int count;
                    POINT pt;
                    pf = profileNames;
                    selected = 0;
                    count = 0;
                    SendMessage(hwndTbProfile, CB_RESETCONTENT, 0, 0);
                    SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)sysProfileName);
                    while (pf)
                    {
                        count++;
                        if (!strcmp(pf->name,currentProfileName))
                            selected = count;
                        SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)pf->name);
                            
                        pf = pf->next;
                            
                    }
                    SendMessage(hwndTbProfile, CB_SETCURSEL, selected, 0);
                    SendMessage(hwndTbBuildType, CB_RESETCONTENT, 0, 0);
                    SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Debug");
                    SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Release");
                    SendMessage(hwndTbBuildType, CB_SETCURSEL, profileDebugMode ? 0 : 1, 0);
                    
                    pt.x = 5;
                    pt.y = 5;
                    htemp = ChildWindowFromPoint(hwndTbProfile, pt);
                    SendMessage(htemp, EM_SETREADONLY, 1, 0);
                    htemp = ChildWindowFromPoint(hwndTbBuildType, pt);
                    SendMessage(htemp, EM_SETREADONLY, 1, 0);
                    EnableWindow(hwndTbProfile, TRUE);
                    EnableWindow(hwndTbBuildType, TRUE);
                    break;
                }
            case IDM_IMPORT_CWS:
                ImportProject(FALSE);
                break;
            case IDM_IMPORT_CTG:
                ImportProject(TRUE);
                break;
            case IDM_DOSWINDOW:
            {
                DosWindow(activeProject ? activeProject->realName : NULL, NULL, NULL, NULL, NULL);
            }
                break;
            case IDM_MAKEWINDOW:
            {
                char exec[MAX_PATH];
                sprintf(exec, "%s\\bin\\imake.exe", szInstallPath);
                DosWindow(activeProject ? activeProject->realName : NULL, exec, "", "Custom Make", "Make Is Complete.");
            }
                break;
            case IDM_RUN:
                SaveWorkArea(workArea);
                dbgRebuildMain(wParam);
                break;
            case IDM_SETACTIVEPROJECT:
                ProjectSetActive();
                break;
            case IDM_NEWFILE_P:
                ProjectNewFile();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break;
            case IDM_EXISTINGFILE:
                ProjectExistingFile();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break;
            case IDM_NEWPROJECT:
                ProjectNewProject();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break;
            case IDM_EXISTINGPROJECT:
                ProjectExistingProject();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break ;
            case IDM_REMOVE:
                ProjectRemove();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break;
            case IDM_RENAME:
                ProjectRename();
                break;
            case IDM_NEWFOLDER:
                ProjectNewFolder();
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                break;
            case IDM_NEWWS:
                if (uState != notDebugging)
                {
                    if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, 
                        "This action requires the debugger to be stopped.") != IDOK)
                    {
                        break;
                    }
                    abortDebug();
                }
                SelectWindow(DID_PROJWND);
                ProjectNewWorkArea();
                break;
            case IDM_OPENWS:
                if (uState != notDebugging)
                {
                    if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, 
                        "This action requires the debugger to be stopped.") != IDOK)
                    {
                        break;
                    }
                    abortDebug();
                }
                SelectWindow(DID_PROJWND);
                ProjectExistingWorkArea();
                break;
            case IDM_CLOSEWS:
                if (making)
                    break;
                if (uState != notDebugging)
                {
                    if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, 
                        "This action requires the debugger to be stopped.") != IDOK)
                    {
                        break;
                    }
                    abortDebug();
                }
                CloseWorkArea();
                break;
            case IDM_SAVEWS:
                SaveAllProjects(workArea, TRUE);
                break;
            case IDM_COMPILEFILEFROMTREE:
            {
                PROJECTITEM *data = GetItemInfo(prjSelectedItem);
                if (data && data->type == PJ_FILE) 
                {
                    unlink(data->outputName);
                    Maker(data, TRUE);
                }        
            }
                break;
            case IDM_COMPILEFILE:
                win = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0);
                if (IsWindow(win) && IsEditWindow(win))
                {
                    HTREEITEM item = FindItemByWind(win);
                    PROJECTITEM *data = GetItemInfo(item);
                    if (data) {
                        unlink(data->outputName);
                        Maker(data, TRUE);
                    }
                }
                break;
            case IDM_GENMAKE:
                if (workArea && workArea->children)
                {
                    genMakeFile(workArea);
                }
                else
                {
                    ExtendedMessageBox("Makefile Generation", MB_SETFOREGROUND |
                        MB_SYSTEMMODAL, 
                        "You need at least one project to generate a make file");
                }
                break;
            case IDM_MAKE:
                if (HIWORD(wParam))
                    if (GetKeyState(VK_CONTROL) &0x80000000)
                        SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0);
                    else if (GetKeyState(VK_SHIFT) &0x80000000)
                        Maker(activeProject, FALSE);
                    else
                        Maker(workArea, FALSE);
                else
                    Maker(workArea, FALSE);
                break;                
            case IDM_MAKE_RIGHTCLICK:
                if (HIWORD(wParam))
                    if (GetKeyState(VK_CONTROL) &0x80000000)
                        SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0);
                    else if (GetKeyState(VK_SHIFT) &0x80000000)
                        Maker(activeProject, FALSE);
                    else
                        Maker(workArea, FALSE);
                else
                {
                    if (prjSelectedItem)
                    {
                        PROJECTITEM *data = GetItemInfo(prjSelectedItem);
                        if (data)
                        {
                            Maker(data, FALSE);
                            break;
                        }
                    }
            
                    Maker(workArea, FALSE);
                }
                break;
            case IDM_BUILDALL:
                Maker(workArea, TRUE);
                break;                
            case IDM_BUILDALL_RIGHTCLICK:
                if (prjSelectedItem)
                {
                    PROJECTITEM *data = GetItemInfo(prjSelectedItem);
                    if (data)
                    {
                        Maker(data, TRUE);
                        break;
                    }
                }
                Maker(workArea, TRUE);
                break;
            case IDM_BUILDSELECTED:
                Maker(activeProject, FALSE);
                break;
            case IDM_STOPBUILD:
                StopBuild();
                break;
            case IDM_CALCULATEDEPENDS:
                CalculateProjectDepends(GetItemInfo(prjSelectedItem));
                break;
            case IDM_RUNNODEBUG:
            {
                SaveWorkArea(workArea);
                RunProgram(activeProject);
                break;
            }
            case IDM_SELECTPROFILE:
                SelectProfileDialog();
                break;
            case IDM_ACTIVEPROJECTPROPERTIES:
                if (activeProject)
                    prjSelectedItem = activeProject->hTreeItem;
                // fall through
            case IDM_PROJECTPROPERTIES:
                data = GetItemInfo(prjSelectedItem);
                ShowBuildProperties(data);
                break;
            case IDM_PROJECTDEPENDS:
                data = GetItemInfo(prjSelectedItem);
                EditProjectDependencies(data);
                break;
            case IDM_OPENFILES:
                data = GetItemInfo(prjSelectedItem);
                if (data)
                    if (data->type == PJ_FILE)
                    {
                        if (strlen(data->realName) >= 3 && !stricmp(data->realName + strlen(data->realName) -3, ".rc"))
                        {
                            NavigateToResource(data);
                        }
                        else
                        {
                            strcpy(info.dwName, data->realName);
                            strcpy(info.dwTitle, data->displayName);
                            info.dwLineNo =  - 1;
                            info.logMRU = FALSE;
                            info.newFile = FALSE;
                            CreateDrawWindow(&info, TRUE);
                        }
                    }
                break;
            case IDM_CLOSE:
                SendMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            default:
                return DefWindowProc(hwnd, iMessage, wParam, lParam);
            }
            break;
        case WM_LBUTTONUP:
            if (dragging)
            {
                SetCursor(origCurs);
                ReleaseCapture();
                dragging = FALSE;
                TreeView_SelectDropTarget(prjTreeWindow, NULL);
                if (inView && dstItem != srcItem && srcItem && dstItem)
                {
                    DragTo(dstItem, srcItem);
                }
            }
            break;
        case WM_MOUSEMOVE:
            if (dragging)
            {
                hittest.pt.x = (long)(short)LOWORD(lParam);
                hittest.pt.y = (long)(short)HIWORD(lParam);
                
                dstItem = TreeView_HitTest(prjTreeWindow, &hittest);
                if (dstItem && dstItem != srcItem)
                {
                    PROJECTITEM *srcData = GetItemInfo(srcItem);
                    data = GetItemInfo(dstItem);
                    if (srcData && data)
                    {
                        PROJECTITEM *p = data->parent;
                        while (p)
                            if (p == srcData)
                                break;
                            else
                                p = p->parent;
                        if (p)
                        {
                            if (inView)
                            {
                                inView = FALSE;
                                SetCursor(noCur);
                                TreeView_SelectDropTarget(prjTreeWindow, NULL);
                            }
                            break;
                        }
                    }
                    if (data && (data->type == PJ_PROJ || data->type == PJ_FOLDER))
                    {
                        if (!inView)
                        {
                            inView = TRUE;
                            SetCursor(dragCur);
                        }
                        TreeView_SelectDropTarget(prjTreeWindow, dstItem);
                    }
                    else
                    {
                        if (inView)
                        {
                            inView = FALSE;
                            SetCursor(noCur);
                            TreeView_SelectDropTarget(prjTreeWindow, NULL);
                        }
                    }
                }
                else
                {
                    if (inView)
                    {
                        inView = FALSE;
                        SetCursor(noCur);
                        TreeView_SelectDropTarget(prjTreeWindow, NULL);
                    }
                }
            }
            break;
        case WM_SETFOCUS:
            PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
            SetFocus(prjTreeWindow);
            break;
        case WM_CREATE:
            hwndProject = hwnd;
            GetClientRect(hwnd, &rs);

            treeViewSelected = 0;
            dragCur = LoadCursor(hInstance, "ID_DRAGCUR");
            noCur = LoadCursor(hInstance, "ID_NODRAGCUR");
            folderClose = LoadBitmap(hInstance, "ID_FOLDERCLOSE");
            folderOpen = LoadBitmap(hInstance, "ID_FOLDEROPEN");
            treeIml = ImageList_Create(16, 16, ILC_COLOR24, IL_IMAGECOUNT+2, 0);
            
            mainIml = LoadBitmap(hInstance, "ID_FILES");
            ChangeBitmapColor(mainIml, 0xffffff, RetrieveSysColor(COLOR_WINDOW));
            ImageList_Add(treeIml, mainIml, NULL);
            ilfolderClose = ImageList_Add(treeIml, folderClose, 0);
            ilfolderOpen = ImageList_Add(treeIml, folderOpen, 0);
            DeleteObject(folderClose);
            DeleteObject(folderOpen);
            DeleteObject(mainIml);
            prjTreeWindow = CreateWindowEx(0, sztreeDoubleBufferName, "", WS_VISIBLE |
                WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_TRACKSELECT,
                0, 0, rs.right, rs.bottom, hwnd, (HMENU)ID_TREEVIEW,
                hInstance, NULL);
            TreeView_SetImageList(prjTreeWindow, treeIml, TVSIL_NORMAL);
            lf = systemDialogFont;
            projFont = CreateFontIndirect(&lf);
            lf.lfItalic = TRUE;
            italicProjFont = CreateFontIndirect(&lf);
            lf.lfItalic = FALSE;
            lf.lfWeight = FW_BOLD;
            boldProjFont = CreateFontIndirect(&lf);
            SendMessage(prjTreeWindow, WM_SETFONT, (WPARAM)boldProjFont, 0);
            return 0;
        case WM_CLOSE:
            SaveAllProjects(workArea, FALSE);
            break;
        case WM_DESTROY:
            FreeSubTree(workArea, FALSE);
            DestroyWindow(prjTreeWindow);
            DeleteObject(projFont);
            DeleteObject(boldProjFont);
            DeleteObject(italicProjFont);
            DestroyCursor(dragCur);
            DestroyCursor(noCur);
            hwndProject = 0;
            break;
        case WM_SIZE:
            MoveWindow(prjTreeWindow, 0, 0, LOWORD(lParam), HIWORD(lParam), 0);
            break;
        default:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
Ejemplo n.º 26
0
LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	TVITEM tvi;
	CCList *dat = CWndUserData(GetParent(hWnd)).GetCList();

	switch (Msg) {
	case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact
		{
			HTREEITEM hItem = dat->FindContact(wParam);
			if (hItem)
				TreeView_DeleteItem(hWnd, hItem);
		}
		break;

	case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID
		tvi.hItem = dat->FindContact(wParam);
		if (tvi.hItem) {
			tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
			tvi.iImage = tvi.iSelectedImage = lParam;
			TreeView_SetItem(hWnd, &tvi);
			dat->SortContacts();
			InvalidateRect(hWnd, nullptr, false);
		}
		break;

	case INTM_INVALIDATE:
		InvalidateRect(hWnd, nullptr, true);
		break;

	case WM_RBUTTONDOWN:
		SetFocus(hWnd);
		{
			TVHITTESTINFO hitTest;
			hitTest.pt.x = (short)LOWORD(lParam);
			hitTest.pt.y = (short)HIWORD(lParam);
			TreeView_HitTest(hWnd, &hitTest);
			if (hitTest.hItem && hitTest.flags & TVHT_ONITEM)
				TreeView_SelectItem(hWnd, hitTest.hItem);
		}
		return DefWindowProc(hWnd, Msg, wParam, lParam);

	case WM_LBUTTONDOWN:
		{
			POINT pt = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			DWORD hitFlags;
			HTREEITEM hItem = dat->HitTest(&pt, &hitFlags);
			if (!hItem)
				break;

			if (hitFlags & MCLCHT_ONITEMICON) {
				if (TreeView_GetChild(hWnd, hItem)) { // if it's a group, then toggle its state
					NMTREEVIEW nmtv;
					nmtv.hdr.hwndFrom = hWnd;
					nmtv.hdr.idFrom = GetDlgCtrlID(hWnd);
					nmtv.hdr.code = TVN_ITEMEXPANDING;
					nmtv.action = TVE_TOGGLE;
					nmtv.itemNew.hItem = hItem;
					nmtv.itemNew.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
					TreeView_GetItem(hWnd, &nmtv.itemNew);
					nmtv.ptDrag = pt;
					if (SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmtv))
						return 0;

					HTREEITEM hOldSelItem = TreeView_GetSelection(hWnd);
					TreeView_Expand(hWnd, hItem, TVE_TOGGLE);
					HTREEITEM hNewSelItem = TreeView_GetSelection(hWnd);
					if (hNewSelItem != hOldSelItem) {
						TreeView_SetItemState(hWnd, hOldSelItem, (dat->SelectedItems.Find(hOldSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED);
						TreeView_SetItemState(hWnd, hNewSelItem, (dat->SelectedItems.Find(hNewSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED);
					}
					nmtv.hdr.code = TVN_ITEMEXPANDED;
					TreeView_GetItem(hWnd, &nmtv.itemNew);
					SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmtv);
					return 0;
				}
			}
			if (hitFlags & MCLCHT_ONITEM) {
				if (wParam & MK_CONTROL) {
					SetFocus(hWnd);
					TREEITEMARRAY OldSelection = dat->SelectedItems;
					int nIndex = dat->SelectedItems.Find(hItem);
					if (nIndex == -1) {
						TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED);
						dat->SelectedItems.AddElem(hItem);
					}
					else {
						TreeView_SetItemState(hWnd, hItem, 0, TVIS_SELECTED);
						dat->SelectedItems.RemoveElem(nIndex);
					}
					dat->SelectGroups(hItem, nIndex == -1);
					NMCLIST nm;
					nm.hdr.code = MCLN_SELCHANGED;
					nm.hdr.hwndFrom = hWnd;
					nm.hdr.idFrom = GetDlgCtrlID(hWnd);
					nm.OldSelection = &OldSelection;
					nm.NewSelection = &dat->SelectedItems;
					SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
					return 0;
				}
				// if it was a click on the selected item and there's need to do something in this case, then send SELCHANGED notification by ourselves, as the tree control doesn't do anything
				if (hItem == TreeView_GetSelection(hWnd) && (dat->SelectedItems.GetSize() != 1 || (dat->SelectedItems.GetSize() == 1 && dat->SelectedItems[0] != hItem))) {
					TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED);
					NMTREEVIEW nm = {};
					nm.hdr.code = TVN_SELCHANGED;
					nm.hdr.hwndFrom = hWnd;
					nm.hdr.idFrom = GetDlgCtrlID(hWnd);
					nm.itemOld.hItem = TreeView_GetSelection(hWnd);
					nm.itemOld.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
					TreeView_GetItem(hWnd, &nm.itemOld);
					nm.itemNew = nm.itemOld;
					SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
				}
			}
		}
		break;

	case WM_SETFOCUS:
	case WM_KILLFOCUS:
		for (int i = 0; i < dat->SelectedItems.GetSize(); i++) {
			RECT rc;
			if (TreeView_GetItemRect(hWnd, dat->SelectedItems[i], &rc, false))
				InvalidateRect(hWnd, &rc, false);
		}
		break;

	case WM_SIZE:
	case WM_HSCROLL:
		InvalidateRect(hWnd, nullptr, false);
		break;

	case WM_MEASUREITEM:
		if (!wParam) // if the message was sent by a menu
			return Menu_MeasureItem(lParam);
		break;

	case WM_DRAWITEM:
		if (!wParam) // if the message was sent by a menu
			return Menu_DrawItem(lParam);
		break;

	case WM_CONTEXTMENU:
		{
			POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
			HTREEITEM hItem = nullptr;
			if (pt.x == -1 && pt.y == -1) {
				if (dat->SelectedItems.GetSize() == 1) {
					hItem = dat->SelectedItems[0];
					TreeView_EnsureVisible(hWnd, hItem);
					RECT rc;
					TreeView_GetItemRect(hWnd, hItem, &rc, true);
					pt.x = rc.left;
					pt.y = rc.bottom;
				}
			}
			else {
				DWORD hitFlags;
				ScreenToClient(hWnd, &pt);
				hItem = dat->HitTest(&pt, &hitFlags);
				if (!(hitFlags & MCLCHT_ONITEM))
					hItem = nullptr;
			}
			if (hItem) {
				MCONTACT hContact = dat->GetItemData(hItem).hContact;
				if (IsHContactContact(hContact)) {
					HMENU hMenu = Menu_BuildContactMenu(hContact);
					if (hMenu) {
						ClientToScreen(hWnd, &pt);
						Clist_MenuProcessCommand(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, nullptr), MPCF_CONTACTMENU, hContact);
						DestroyMenu(hMenu);
						return 0;
					}
				}
			}
		}
		break;

	case WM_DESTROY:
		if (dat->ExtraImageList)
			ImageList_Destroy(dat->ExtraImageList);
		dat->SelectedItems.RemoveAll();
		dat->Items.RemoveAll();
		break;
	}
	return CallWindowProc(dat->OrigTreeViewProc, hWnd, Msg, wParam, lParam);
}
Ejemplo n.º 27
0
INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
{
	LPNMHDR nm = (LPNMHDR)lParam;
	switch (nm->code)
	{
	case NM_CLICK:
		if (nm->idFrom == IDC_MANAGESKINS_ADDMETADATA_LINK)
		{
			std::wstring file = Rainmeter->GetSkinPath() + m_SkinFolderPath;
			file += L'\\';
			file += m_SkinFileName;
			WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nName=\r\nInformation=\r\nLicense=\r\nVersion", L"", file.c_str());
			SendMessage(m_Window, WM_COMMAND, MAKEWPARAM(IDC_MANAGESKINS_EDIT_BUTTON, 0), 0);
			ShowWindow(nm->hwndFrom, SW_HIDE);
		}
		break;

	case NM_DBLCLK:
		if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW && !m_SkinFileName.empty())
		{
			OnCommand(MAKEWPARAM(IDC_MANAGESKINS_LOAD_BUTTON, 0), 0);
		}
		break;

	case NM_RCLICK:
		if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW)
		{
			POINT pt;
			GetCursorPos(&pt);

			TVHITTESTINFO ht;
			ht.pt = pt;
			ScreenToClient(nm->hwndFrom, &ht.pt);

			if (TreeView_HitTest(nm->hwndFrom, &ht) && !(ht.flags & TVHT_NOWHERE))
			{
				TreeView_SelectItem(nm->hwndFrom, ht.hItem);

				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(nm->hwndFrom);
				tvi.mask = TVIF_STATE;

				HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_MANAGESKINS_MENU));
				if (menu && TreeView_GetItem(nm->hwndFrom, &tvi))
				{
					HMENU subMenu;
					MENUITEMINFO mii = {0};
					mii.cbSize = sizeof(MENUITEMINFO);
					mii.fMask = MIIM_STRING;

					if (m_SkinFileName.empty())
					{
						// It's a folder
						subMenu = GetSubMenu(menu, 0);
						SetMenuDefaultItem(subMenu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND);

						if (tvi.state & TVIS_EXPANDED)
						{
							mii.dwTypeData = GetString(ID_STR_COLLAPSE);
							SetMenuItemInfo(subMenu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND, &mii);
						}
					}
					else
					{
						// It's a skin
						subMenu = GetSubMenu(menu, 1);
						SetMenuDefaultItem(subMenu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND);

						if (m_SkinWindow)
						{
							mii.dwTypeData = GetString(ID_STR_UNLOAD);
							SetMenuItemInfo(subMenu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND, &mii);
						}
						else
						{
							EnableMenuItem(subMenu, IDM_MANAGESKINSMENU_REFRESH, MF_BYCOMMAND | MF_GRAYED);
						}
					}

					// Show context menu
					TrackPopupMenu(
						subMenu,
						TPM_RIGHTBUTTON | TPM_LEFTALIGN,
						pt.x,
						pt.y,
						0,
						m_Window,
						NULL
					);

					DestroyMenu(menu);
				}
			}
		}
		break;

	case TVN_SELCHANGED:
		if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW)
		{
			m_SkinWindow = NULL;
			m_SkinFileName.clear();
			m_SkinFolderPath.clear();

			// Temporarily disable handling commands
			m_HandleCommands = false;

			WCHAR buffer[MAX_PATH];

			// Get current selection name
			TVITEM tvi = {0};
			tvi.hItem = TreeView_GetSelection(nm->hwndFrom);
			tvi.mask = TVIF_TEXT | TVIF_CHILDREN;
			tvi.pszText = buffer;
			tvi.cchTextMax = MAX_PATH;
			TreeView_GetItem(nm->hwndFrom, &tvi);

			if (tvi.cChildren == 0)
			{
				// Current selection is file
				m_SkinFileName = buffer;
				tvi.mask = TVIF_TEXT;
			
				// Loop through parents to get skin folder
				m_SkinFolderPath.clear();
				while ((tvi.hItem = TreeView_GetParent(nm->hwndFrom, tvi.hItem)) != NULL)
				{
					TreeView_GetItem(nm->hwndFrom, &tvi);
					m_SkinFolderPath.insert(0, 1, L'\\');
					m_SkinFolderPath.insert(0, buffer);
				}

				m_SkinFolderPath.resize(m_SkinFolderPath.length() - 1);  // Get rid of trailing slash

				ReadSkin();
			}
			else
			{
				DisableControls(true);
			}

			m_HandleCommands = true;
		}
		break;

	default:
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 28
0
static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
	OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		dat = (OrderData*)malloc( sizeof(OrderData));
		SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG_PTR)dat);
		dat->dragging = 0;

		SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL);

		SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0));

		SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0));

		SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0));

		CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine ? BST_CHECKED : BST_UNCHECKED);

		BuildTree(hwndDlg);
		EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
		EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
		EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE);

		OptionshWnd = hwndDlg;
		return TRUE;

	case WM_COMMAND:
		if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) {
			switch(LOWORD(wParam)) {
			case IDC_ENAME: case IDC_EPATH:
				break;
			default:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
			break;
		}

		if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) {
			int ctrlid = LOWORD(wParam);

			//----- Launch buttons -----

			if (ctrlid == IDC_BROWSE) {
				TCHAR str[MAX_PATH];
				OPENFILENAME ofn = {0};

				GetDlgItemText(hwndDlg, IDC_EPATH, str, _countof(str));
				ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
				ofn.hwndOwner = hwndDlg;
				ofn.hInstance = NULL;
				ofn.lpstrFilter = NULL;
				ofn.lpstrFile = str;
				ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
				ofn.nMaxFile = _countof(str);
				ofn.nMaxFileTitle = MAX_PATH;
				ofn.lpstrDefExt = _T("exe");
				if (!GetOpenFileName(&ofn))
					break;

				SetDlgItemText(hwndDlg, IDC_EPATH, str);

				break;
			}

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

			if (ctrlid == IDC_LBUTTONSET) {
				TVITEM tvi ={0};
				tvi.hItem = TreeView_GetSelection(hTree);
				if (tvi.hItem == NULL)
					break;

				tvi.mask = TVIF_PARAM;
				TreeView_GetItem(hTree, &tvi);

				TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
				TCHAR buf [256];
				// probably, condition not needs
				if (btn->dwFlags & TTBBF_ISLBUTTON) {
					if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
						// create button
						TTBButton ttb = { 0 };
						ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
						ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
						ttb.name = NULL;
						ttb.program = NULL;
						int id = btn->id;
						btn = CreateButton(&ttb);
						btn->id = id;

						tvi.lParam = (LPARAM)btn;
						TreeView_SetItem(hTree, &tvi);
					}

					GetDlgItemText(hwndDlg, IDC_ENAME, buf, _countof(buf));
					replaceStr(btn->pszName, _T2A(buf));

					tvi.mask = TVIF_TEXT;
					tvi.pszText = buf;
					TreeView_SetItem(hTree, &tvi);

					GetDlgItemText(hwndDlg, IDC_EPATH, buf, _countof(buf));
					replaceStrT(btn->ptszProgram, buf);
				}
				break;
			}

			if (ctrlid == IDC_ADDLBUTTON) {
				// create button
				TTBButton ttb = { 0 };
				ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
				ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
				ttb.name = LPGEN("Default");
				ttb.program = _T("Execute Path");
				TopButtonInt* b = CreateButton(&ttb);

				// get selection for insert
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);

				// insert item
				AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}

			//----- Separators -----

			if (ctrlid == IDC_ADDSEP) {
				// create button
				TTBButton ttb = { 0 };
				ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL;
				TopButtonInt* b = CreateButton(&ttb);

				// get selection for insert
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);

				// insert item
				AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}

			if (ctrlid == IDC_REMOVEBUTTON) {
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);
				if (tvi.hItem == NULL)
					break;

				tvi.mask = TVIF_PARAM;
				TreeView_GetItem(hTree, &tvi);

				TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
				// if button enabled for separator and launch only, no need condition
				// except possible service button introducing
				if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) {
					// delete if was added in options
					if (btn->dwFlags & TTBBF_OPTIONAL)
						delete btn;

					TreeView_DeleteItem(hTree,tvi.hItem);

					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
				break;
			}
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY:
				g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE);
				g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE);
				g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE);
				
				g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT);
				g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE);
				g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE);

				db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight);
				db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth);
				db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace);

				db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons);
				db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine);
				db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize);

				SaveTree(hwndDlg);
				RecreateWindows();
				ArrangeButtons();
			}
			break;

		case IDC_BUTTONORDERTREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_BEGINDRAG:
				SetCapture(hwndDlg);
				dat->dragging = 1;
				dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
				TreeView_SelectItem(hTree, dat->hDragItem);
				break;

			case NM_CLICK:
				{
					TVHITTESTINFO hti;
					hti.pt.x = (short)LOWORD(GetMessagePos());
					hti.pt.y = (short)HIWORD(GetMessagePos());
					ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
					if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
						if (hti.flags & TVHT_ONITEMSTATEICON) {
							SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
							TreeView_SelectItem(hTree, hti.hItem);
						}
				}
				break;

			case TVN_SELCHANGED:
				{
					HTREEITEM hti = TreeView_GetSelection(hTree);
					if (hti == NULL)
						break;

					TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam;

					mir_cslock lck(csButtonsHook);

					if (btn->dwFlags & TTBBF_ISLBUTTON) {
						bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0;
						EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable);
						if (btn->pszName != NULL)
							SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName);
						else
							SetDlgItemTextA(hwndDlg, IDC_ENAME, "");

						if (btn->ptszProgram != NULL)
							SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram);
						else
							SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
					}
					else {
						EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON),
								(btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE);

						EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
						EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
						EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE);
						SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
						SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
					}
				}
			}
			break;
		}
		break;

	case WM_MOUSEMOVE:
		if (dat->dragging) {
			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hTree, &hti.pt);
			TreeView_HitTest(hTree, &hti);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
				HTREEITEM it=hti.hItem;
				hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
				TreeView_HitTest(hTree, &hti);
				if (!(hti.flags&TVHT_ABOVE))
					TreeView_SetInsertMark(hTree,hti.hItem,1);
				else 
					TreeView_SetInsertMark(hTree,it,0);
			}
			else {
				if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
				if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
				TreeView_SetInsertMark(hTree, NULL, 0);
			}
		}
		break;

	case WM_LBUTTONUP:
		if (dat->dragging) {
			TreeView_SetInsertMark(hTree, NULL, 0);
			dat->dragging = 0;
			ReleaseCapture();

			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hTree, &hti.pt);
			hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
			TreeView_HitTest(hTree, &hti);
			if (dat->hDragItem == hti.hItem)
				break;
			if (hti.flags&TVHT_ABOVE)
				hti.hItem=TVI_FIRST;

			TVITEM tvi;
			tvi.mask = TVIF_HANDLE|TVIF_PARAM;
			tvi.hItem = (HTREEITEM) dat->hDragItem;
			TreeView_GetItem(hTree, &tvi);
			if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) {
				TVINSERTSTRUCT tvis;
				TCHAR name[128];
				tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
				tvis.item.stateMask = 0xFFFFFFFF;
				tvis.item.pszText = name;
				tvis.item.cchTextMax = _countof(name);
				tvis.item.hItem = dat->hDragItem;
				TreeView_GetItem(hTree, &tvis.item);

				TreeView_DeleteItem(hTree, dat->hDragItem);
				tvis.hParent = NULL;
				tvis.hInsertAfter = hti.hItem;
				TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis));

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_DESTROY:
		if (dat) {
			ImageList_Destroy(dat->himlButtonIcons);
			free(dat);
		}
		OptionshWnd = NULL;
		break;
	}
	return FALSE;
}
Ejemplo n.º 29
0
static BOOL CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_DESTROY: 
		{
			if (hPreviewBitmap) DeleteObject(hPreviewBitmap);
			break;
		}

	case WM_INITDIALOG:
		{ 
			int it;
			TranslateDialogDefault(hwndDlg);
			it=FillAvailableSkinList(hwndDlg);
			{
				/* Text Colors */
				DWORD c1,c2,c3,c4;
				c1=DBGetContactSettingDword(NULL,"Menu", "TextColour", CLCDEFAULT_TEXTCOLOUR);
				c2=DBGetContactSettingDword(NULL,"Menu", "SelTextColour", CLCDEFAULT_SELTEXTCOLOUR);
				c3=DBGetContactSettingDword(NULL,"FrameTitleBar", "TextColour", CLCDEFAULT_TEXTCOLOUR);
				c4=DBGetContactSettingDword(NULL,"StatusBar", "TextColour", CLCDEFAULT_TEXTCOLOUR);
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUNORMAL,CPM_SETCOLOUR,0,c1);                  
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUSELECTED,CPM_SETCOLOUR,0,c2);
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_FRAMES,CPM_SETCOLOUR,0,c3);
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_STATUSBAR,CPM_SETCOLOUR,0,c4);

				SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUNORMAL,CPM_SETDEFAULTCOLOUR,0,c1);                  
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUSELECTED,CPM_SETDEFAULTCOLOUR,0,c2);
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_FRAMES,CPM_SETDEFAULTCOLOUR,0,c3);
				SendDlgItemMessage(hwndDlg,IDC_COLOUR_STATUSBAR,CPM_SETDEFAULTCOLOUR,0,c4);                              
				/* End of Text colors */
			}

			TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_TREE1),(HTREEITEM)it);						
		}
		return 0;
	case WM_COMMAND:
		{
			int isLoad=0;
			switch (LOWORD(wParam)) 
			{
			case IDC_COLOUR_MENUNORMAL:
			case IDC_COLOUR_MENUSELECTED:
			case IDC_COLOUR_FRAMES:
			case IDC_COLOUR_STATUSBAR:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;

			case IDC_BUTTON_INFO:
				{
					char Author[255];
					char URL[MAX_PATH];
					char Contact[255];
					char Description[400];
					char text[2000];
					SkinListData *sd=NULL;  
					HTREEITEM hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));				
					if (hti==0) return 0;
					{
						TVITEMA tvi={0};
						tvi.hItem=hti;
						tvi.mask=TVIF_HANDLE|TVIF_PARAM;
						TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&tvi);
						sd=(SkinListData*)(tvi.lParam);
					}
					if (!sd) return 0;
					if (sd->File && !strchr(sd->File,'%'))
					{
						GetPrivateProfileStringA("Skin_Description_Section","Author","(unknown)",Author,sizeof(Author),sd->File);
						GetPrivateProfileStringA("Skin_Description_Section","URL","",URL,sizeof(URL),sd->File);
						GetPrivateProfileStringA("Skin_Description_Section","Contact","",Contact,sizeof(Contact),sd->File);
						GetPrivateProfileStringA("Skin_Description_Section","Description","",Description,sizeof(Description),sd->File);
						_snprintf(text,sizeof(text),Translate("%s\n\n%s\n\nAuthor(s):\t %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s"),
							sd->Name,Description,Author,Contact,URL,sd->File);
					}
					else
					{
						_snprintf(text,sizeof(text),Translate("%s\n\n%s\n\nAuthor(s): %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s"),
							"Luna v0.4",Translate("This is default Modern Contact list skin based on 'Luna' theme"),"Angeli-Ka (graphics), FYR (template)","JID: [email protected]","modern.saopp.info",Translate("Inside library"));
					}
					MessageBoxA(hwndDlg,text,"Skin Information",MB_OK|MB_ICONINFORMATION);
				}
				break;
			case IDC_BUTTON_APPLY_SKIN:
				if (HIWORD(wParam)==BN_CLICKED)
				{ 		
					SkinListData *sd=NULL;  
					HTREEITEM hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));				
					if (hti==0) return 0;
					{
						TVITEM tvi={0};
						tvi.hItem=hti;
						tvi.mask=TVIF_HANDLE|TVIF_PARAM;
						TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&tvi);
						sd=(SkinListData*)(tvi.lParam);
					}
					if (!sd) return 0;
					if (glSkinWasModified>0)
					{
						int res=0;
						if (glSkinWasModified==1)
							res=MessageBoxA(hwndDlg,Translate("Skin editor contains not stored changes.\n\nAll changes will be lost.\n\n Continue to load new skin?"),Translate("Warning!"),MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2|MB_TOPMOST);
						else
							res=MessageBoxA(hwndDlg,Translate("Current skin was not saved to file.\n\nAll changes will be lost.\n\n Continue to load new skin?"),Translate("Warning!"),MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2|MB_TOPMOST);
						if (res!=IDOK) return 0;
					}
					LoadSkinFromIniFile(sd->File);
					LoadSkinFromDB();	
					glOtherSkinWasLoaded=TRUE;
					pcli->pfnClcBroadcast( INTM_RELOADOPTIONS,0,0);
					CLUIFramesOnClistResize2(0,0,0);
					RedrawCompleteWindow();        
					CLUIFramesOnClistResize2(0,0,0);
					{
						HWND hwnd=(HWND)CallService(MS_CLUI_GETHWND,0,0);
						RECT rc={0};
						GetWindowRect(hwnd, &rc);
						OnMoving(hwnd,&rc);
					}
					if (hCLUIwnd)
					{
						SendDlgItemMessage(hCLUIwnd,IDC_LEFTMARGINSPIN,UDM_SETPOS,0,DBGetContactSettingByte(NULL,"CLUI","LeftClientMargin",0));
						SendDlgItemMessage(hCLUIwnd,IDC_RIGHTMARGINSPIN,UDM_SETPOS,0,DBGetContactSettingByte(NULL,"CLUI","RightClientMargin",0));
						SendDlgItemMessage(hCLUIwnd,IDC_TOPMARGINSPIN,UDM_SETPOS,0,DBGetContactSettingByte(NULL,"CLUI","TopClientMargin",0));
						SendDlgItemMessage(hCLUIwnd,IDC_BOTTOMMARGINSPIN,UDM_SETPOS,0,DBGetContactSettingByte(NULL,"CLUI","BottomClientMargin",0));
					}
				}
				break;
			case IDC_BUTTON_LOAD:
				isLoad=1;
				if (HIWORD(wParam)==BN_CLICKED)
				{
					{   		
						char str[MAX_PATH]={0};
						OPENFILENAMEA ofn={0};
						char filter[512]={0};
						int res=0;
						ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
						ofn.hwndOwner = hwndDlg;
						ofn.hInstance = NULL;

						sprintf(filter,"%s",Translate("Miranda skin file"));
						memmove(filter+mir_strlen(filter)," (*.msf)\0*.MSF\0\0",sizeof(" (*.msf)\0*.MSF\0\0"));
						ofn.lpstrFilter = filter;
						ofn.lpstrFile = str;
						ofn.Flags = isLoad?(OFN_FILEMUSTEXIST | OFN_HIDEREADONLY) : (OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY);
						ofn.nMaxFile = sizeof(str);
						ofn.nMaxFileTitle = MAX_PATH;
						ofn.lpstrDefExt = "msf";

						{
							DWORD tick=GetTickCount();
							res=GetOpenFileNameA(&ofn);
							if(!res) 
								if (GetTickCount()-tick<100)
								{
									res=GetOpenFileNameA(&ofn);
									if(!res) break;
								}
								else break;
						}
						if (res)
						{
							int it=AddSkinToListFullName(hwndDlg,ofn.lpstrFile);
							TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_TREE1),(HTREEITEM)it);
							//SendDlgItemMessage(hwndDlg,IDC_SKINS_LIST,LB_SETCURSEL,it,0); 
							//SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_SKINS_LIST,LBN_SELCHANGE),0);
						}
					}
				}
			}
			break;
		}
	case WM_DRAWITEM:
		if (wParam==IDC_PREVIEW)
		{
			//TODO:Draw hPreviewBitmap here
			HDC memDC, imgDC;
			HBITMAP hbmp,holdbmp,imgOldbmp;
			int mWidth, mHeight;
			RECT workRect={0};
			HBRUSH hbr=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
			DRAWITEMSTRUCT *dis=(DRAWITEMSTRUCT *)lParam;
			mWidth=dis->rcItem.right-dis->rcItem.left;
			mHeight=dis->rcItem.bottom-dis->rcItem.top;
			memDC=CreateCompatibleDC(dis->hDC);
			hbmp=CreateBitmap32(mWidth,mHeight);
			holdbmp=SelectObject(memDC,hbmp);
			workRect=dis->rcItem;
			OffsetRect(&workRect,-workRect.left,-workRect.top);
			FillRect(memDC,&workRect,hbr);     
			DeleteObject(hbr);
			if (hPreviewBitmap)
			{
				//variables
				BITMAP bmp={0};
				POINT imgPos={0};
				int wWidth,wHeight;
				int dWidth,dHeight;
				float xScale=1, yScale=1;
				//GetSize
				GetObject(hPreviewBitmap,sizeof(BITMAP),&bmp);
				wWidth=workRect.right-workRect.left;
				wHeight=workRect.bottom-workRect.top;
				if (wWidth<bmp.bmWidth) xScale=(float)wWidth/bmp.bmWidth;
				if (wHeight<bmp.bmHeight) yScale=(float)wHeight/bmp.bmHeight;
				xScale=min(xScale,yScale);
				yScale=xScale;                    
				dWidth=(int)(xScale*bmp.bmWidth);
				dHeight=(int)(yScale*bmp.bmHeight);
				//CalcPosition
				imgPos.x=workRect.left+((wWidth-dWidth)>>1);
				imgPos.y=workRect.top+((wHeight-dHeight)>>1);     
				//DrawImage
				if (!gl_b_GDIPlusFail) //Use gdi+ engine
				{
					DrawAvatarImageWithGDIp(memDC,imgPos.x,imgPos.y,dWidth,dHeight,hPreviewBitmap,0,0,bmp.bmWidth,bmp.bmHeight,8,255);
				}   
				else
				{
					BLENDFUNCTION bf={AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
					imgDC=CreateCompatibleDC(dis->hDC);
					imgOldbmp=SelectObject(imgDC,hPreviewBitmap);                 
					mod_AlphaBlend(memDC,imgPos.x,imgPos.y,dWidth,dHeight,imgDC,0,0,bmp.bmWidth,bmp.bmHeight,bf);
					SelectObject(imgDC,imgOldbmp);
					mod_DeleteDC(imgDC);
				}
			}
			BitBlt(dis->hDC,dis->rcItem.left,dis->rcItem.top,mWidth,mHeight,memDC,0,0,SRCCOPY);
			SelectObject(memDC,holdbmp);
			DeleteObject(hbmp);
			mod_DeleteDC(memDC);
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) 
		{
		case IDC_TREE1:
			{		
				NMTREEVIEWA * nmtv = (NMTREEVIEWA *) lParam;
				if (!nmtv) return 0;
				if (nmtv->hdr.code==TVN_SELCHANGEDA
					|| nmtv->hdr.code==TVN_SELCHANGEDW)
				{	
					SkinListData * sd=NULL;
					if (hPreviewBitmap) 
					{
						DeleteObject(hPreviewBitmap);
						hPreviewBitmap=NULL;
					}
					if (nmtv->itemNew.lParam)
					{
						//char sdFile[MAX_PATH]={0};
						sd=(SkinListData*)nmtv->itemNew.lParam;
						//PathCompactPathExA(sdFile,sd->File,60,0);
						{
							char buf[MAX_PATH];
							CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)sd->File, (LPARAM)buf);
							SendDlgItemMessageA(hwndDlg,IDC_EDIT_SKIN_FILENAME,WM_SETTEXT,0,(LPARAM)buf); //TODO made filepath unicode
						}
						{
							char prfn[MAX_PATH]={0};
							char imfn[MAX_PATH]={0};
							char skinfolder[MAX_PATH]={0};
							GetPrivateProfileStringA("Skin_Description_Section","Preview","",imfn,sizeof(imfn),sd->File);
							GetSkinFolder(sd->File,skinfolder);
							_snprintf(prfn,sizeof(prfn),"%s\\%s",skinfolder,imfn);
							CallService(MS_UTILS_PATHTOABSOLUTE,(WPARAM)prfn,(LPARAM) imfn);
							hPreviewBitmap=skin_LoadGlyphImage(imfn);
						}
						EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_APPLY_SKIN),TRUE);
						EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_INFO),TRUE);
						if (hPreviewBitmap) 
							InvalidateRect(GetDlgItem(hwndDlg,IDC_PREVIEW),NULL,TRUE);
						else  //prepeare text
						{
							char Author[255];
							char URL[MAX_PATH];
							char Contact[255];
							char Description[400];
							char text[2000];
							SkinListData* sd=NULL;
							HTREEITEM hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));				
							if (hti==0) return 0;
							{
								TVITEM tvi={0};
								tvi.hItem=hti;
								tvi.mask=TVIF_HANDLE|TVIF_PARAM;
								TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&tvi);
								sd=(SkinListData*)(tvi.lParam);
							}
							if (!sd) return 0;

							if(sd->File && !strchr(sd->File,'%'))
							{
								GetPrivateProfileStringA("Skin_Description_Section","Author","(unknown)",Author,sizeof(Author),sd->File);
								GetPrivateProfileStringA("Skin_Description_Section","URL","",URL,sizeof(URL),sd->File);
								GetPrivateProfileStringA("Skin_Description_Section","Contact","",Contact,sizeof(Contact),sd->File);
								GetPrivateProfileStringA("Skin_Description_Section","Description","",Description,sizeof(Description),sd->File);
								_snprintf(text,sizeof(text),Translate("Preview is not available\n\n%s\n----------------------\n\n%s\n\nAUTHOR(S):\n%s\n\nCONTACT:\n%s\n\nHOMEPAGE:\n%s"),
									sd->Name,Description,Author,Contact,URL);
							}
							else
							{
								_snprintf(text,sizeof(text),Translate("%s\n\n%s\n\nAUTHORS:\n%s\n\nCONTACT:\n%s\n\nWEB:\n%s\n\n\n"),
									"Luna v0.4",
									Translate("This is default Modern Contact list skin based on 'Luna' theme"),
									"graphics by Angeli-Ka\ntemplate by FYR",
									"JID: [email protected]",
									"modern.saopp.info"
									);
							}
							ShowWindow(GetDlgItem(hwndDlg,IDC_PREVIEW),SW_HIDE);
							ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC_INFO),SW_SHOW);
							SendDlgItemMessageA(hwndDlg,IDC_STATIC_INFO,WM_SETTEXT,0,(LPARAM)text);
					}					
				}
				else
				{
					//no selected
					SendDlgItemMessage(hwndDlg,IDC_EDIT_SKIN_FILENAME,WM_SETTEXT,0,(LPARAM)TranslateT("Select skin from list"));
					EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_APPLY_SKIN),FALSE);
					EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_INFO),FALSE);
					SendDlgItemMessageA(hwndDlg,IDC_STATIC_INFO,WM_SETTEXT,0,(LPARAM)Translate("Please select skin to apply"));
					ShowWindow(GetDlgItem(hwndDlg,IDC_PREVIEW),SW_HIDE);
				}
				ShowWindow(GetDlgItem(hwndDlg,IDC_PREVIEW),hPreviewBitmap?SW_SHOW:SW_HIDE);
				return 0;
			}			
		else if (nmtv->hdr.code==TVN_SELCHANGEDA || nmtv->hdr.code==TVN_SELCHANGEDW)
		{
			if (nmtv->itemOld.lParam)
				mir_free((void*)(nmtv->itemOld.lParam));
			return 0;
		}
		break;
		}
	case 0:
		switch (((LPNMHDR)lParam)->code)
		{
		case PSN_APPLY:
			{
				{
					DWORD tick=GetTickCount();
					{
						/* Text Colors */
						DWORD c1,c2,c3,c4;
						c1=SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUNORMAL,CPM_GETCOLOUR,0,0);
						c2=SendDlgItemMessage(hwndDlg,IDC_COLOUR_MENUSELECTED,CPM_GETCOLOUR,0,0);
						c3=SendDlgItemMessage(hwndDlg,IDC_COLOUR_FRAMES,CPM_GETCOLOUR,0,0);
						c4=SendDlgItemMessage(hwndDlg,IDC_COLOUR_STATUSBAR,CPM_GETCOLOUR,0,0);
						DBWriteContactSettingDword(NULL,"Menu", "TextColour", c1);
						DBWriteContactSettingDword(NULL,"Menu", "SelTextColour", c2);
						DBWriteContactSettingDword(NULL,"FrameTitleBar", "TextColour", c3);
						DBWriteContactSettingDword(NULL,"StatusBar", "TextColour", c4);
						/* End of Text colors */
					}
					pcli->pfnClcBroadcast( INTM_RELOADOPTIONS,0,0);
					NotifyEventHooks(ME_BACKGROUNDCONFIG_CHANGED,0,0);
					pcli->pfnClcBroadcast( INTM_INVALIDATE,0,0);	
					RedrawWindow(GetParent(pcli->hwndContactTree),NULL,NULL,RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN);
				}
				return 0;
			}
			break;
		}
		break;
	}
}
void CManageBookmarksDialog::OnListViewHeaderRClick()
{
	DWORD dwCursorPos = GetMessagePos();

	POINT ptCursor;
	ptCursor.x = GET_X_LPARAM(dwCursorPos);
	ptCursor.y = GET_Y_LPARAM(dwCursorPos);

	HMENU hMenu = CreatePopupMenu();
	int iItem = 0;

	for each(auto ci in m_pmbdps->m_vectorColumnInfo)
	{
		TCHAR szColumn[128];
		GetColumnString(ci.ColumnType,szColumn,SIZEOF_ARRAY(szColumn));

		MENUITEMINFO mii;
		mii.cbSize		= sizeof(mii);
		mii.fMask		= MIIM_ID|MIIM_STRING|MIIM_STATE;
		mii.wID			= ci.ColumnType;
		mii.dwTypeData	= szColumn;
		mii.fState		= 0;

		if(ci.bActive)
		{
			mii.fState |= MFS_CHECKED;
		}

		/* The name column cannot be removed. */
		if(ci.ColumnType == CManageBookmarksDialogPersistentSettings::COLUMN_TYPE_NAME)
		{
			mii.fState |= MFS_DISABLED;
		}

		InsertMenuItem(hMenu,iItem,TRUE,&mii);

		++iItem;
	}

	int iCmd = TrackPopupMenu(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,ptCursor.x,ptCursor.y,0,m_hDlg,NULL);
	DestroyMenu(hMenu);

	int iColumn = 0;

	for(auto itr = m_pmbdps->m_vectorColumnInfo.begin();itr != m_pmbdps->m_vectorColumnInfo.end();++itr)
	{
		if(itr->ColumnType == iCmd)
		{
			HWND hListView = GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_LISTVIEW);

			if(itr->bActive)
			{
				itr->iWidth = ListView_GetColumnWidth(hListView,iColumn);
				ListView_DeleteColumn(hListView,iColumn);
			}
			else
			{
				LVCOLUMN lvCol;
				TCHAR szTemp[128];

				GetColumnString(itr->ColumnType,szTemp,SIZEOF_ARRAY(szTemp));
				lvCol.mask		= LVCF_TEXT|LVCF_WIDTH;
				lvCol.pszText	= szTemp;
				lvCol.cx		= itr->iWidth;
				ListView_InsertColumn(hListView,iColumn,&lvCol);

				HWND hTreeView = GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_TREEVIEW);
				HTREEITEM hSelected = TreeView_GetSelection(hTreeView);
				CBookmarkFolder &BookmarkFolder = m_pBookmarkTreeView->GetBookmarkFolderFromTreeView(hSelected);

				int iItem = 0;

				for(auto itrBookmarks = BookmarkFolder.begin();itrBookmarks != BookmarkFolder.end();++itrBookmarks)
				{
					TCHAR szColumn[256];
					GetBookmarkItemColumnInfo(*itrBookmarks,itr->ColumnType,szColumn,SIZEOF_ARRAY(szColumn));
					ListView_SetItemText(hListView,iItem,iColumn,szColumn);

					++iItem;
				}
			}

			itr->bActive = !itr->bActive;

			break;
		}
		else
		{
			if(itr->bActive)
			{
				++iColumn;
			}
		}
	}
}