Example #1
0
OveralyWindow::OveralyWindow (Win::Dow::Handle hwndTool, Win::Dow::Handle toolTipHandlerWin)
{
	memset (this, 0, sizeof (TOOLINFO));
	cbSize = sizeof (TOOLINFO);
	uFlags = TTF_IDISHWND | TTF_SUBCLASS;	// Tool id is a window handle. 
	// Subclass tool window to intercept mouse moves
	uId = reinterpret_cast<UINT_PTR>(hwndTool.ToNative ());	// Window added to the tool bar
	hwnd = toolTipHandlerWin.ToNative ();	// Window that receives tool tip notifications
	lpszText = LPSTR_TEXTCALLBACK;			// Send TTN_NEEDTEXT message to the handler window
}
Example #2
0
	// Revisit: File list should be something else than char const * -- too confusing
	// SHFileOperation requires that the file list is ended with double '\0'
	// File list can contain multiple file paths separated by '\0'
	bool DeleteFiles (Win::Dow::Handle win,
					  char const * fileList,
					  FILEOP_FLAGS flags,
					  char const * title,
					  bool quiet)
	{
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative ();
		fileInfo.wFunc = FO_DELETE; 
		fileInfo.pFrom = fileList;
		fileInfo.fFlags = flags;
		fileInfo.lpszProgressTitle = title;
		int result = ::SHFileOperation (&fileInfo);
		if (quiet)
		{
			Win::ClearError ();	// Clear any error code set by the shell
			return (result == 0) && !fileInfo.fAnyOperationsAborted;
		}
		else
		{
			if (fileInfo.fAnyOperationsAborted)
				throw Win::Exception ();
			if (result != 0)
			{
				if ((flags & FOF_NOERRORUI) != 0)	// Throw exception only if Shell was asked not to display error information
					throw Win::Exception ("Internal error: Cannot delete files");
				else
					return false;
			}
		}
		Win::ClearError ();	// Clear any error code set by the shell
		return true;
	}
Example #3
0
	void FileMove (Win::Dow::Handle win,
				   char const * oldPath,
				   char const * newPath,
				   FILEOP_FLAGS flags)
	{
		char srcPath [MAX_PATH + 2];
		char tgtPath [MAX_PATH + 2];
		memset (srcPath, 0, sizeof (srcPath));
		memset (tgtPath, 0, sizeof (tgtPath));
		strcpy (srcPath, oldPath);
		strcpy (tgtPath, newPath);
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative ();
		fileInfo.wFunc = FO_MOVE; 
		fileInfo.pFrom = srcPath;
		fileInfo.pTo = tgtPath;
		fileInfo.fFlags = flags;
		if (::SHFileOperation (&fileInfo))
		{
			if (fileInfo.fAnyOperationsAborted)
				throw Win::Exception ();
			else
				throw Win::Exception ("Internal error: Cannot move file", oldPath);
		}
		if (fileInfo.fAnyOperationsAborted)
			throw Win::Exception ();
		Win::ClearError ();	// Clear any error code set by the shell
	}
Example #4
0
	void CopyContents (Win::Dow::Handle win,
					   char const * fromPath, 
					   char const * toPath, 
					   FILEOP_FLAGS flags)
	{
		FilePath fromFolderContent (fromPath);
		// SHFileOperation requires that the from path is ended with double '\0'
		// WARNING: paths cannot be allocated on the heap -- SHFileOperation will fail
		char srcPath [MAX_PATH + 2];
		char tgtPath [MAX_PATH + 2];
		memset (srcPath, 0, sizeof (srcPath));
		memset (tgtPath, 0, sizeof (tgtPath));
		strcpy (srcPath, fromFolderContent.GetAllFilesPath ());
		strcpy (tgtPath, toPath);
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative ();
		fileInfo.wFunc = FO_COPY; 
		fileInfo.pFrom = srcPath;
		fileInfo.pTo = tgtPath;
		fileInfo.fFlags = flags;
		if (::SHFileOperation (&fileInfo))
		{
			if (fileInfo.fAnyOperationsAborted)
				throw Win::Exception ();
			else
				throw Win::Exception ("Internal error: Cannot copy folder contents", fromPath);
		}
		if (fileInfo.fAnyOperationsAborted)
			throw Win::Exception ();
		Win::ClearError ();	// Clear any error code set by the shell
	}
Example #5
0
	// Revisit: File list should be something else than char const * -- too confusing
	// SHFileOperation requires that the file list is ended with double '\0'
	// File list and toPath can contain multiple file paths separated by '\0'
	void CopyFiles (Win::Dow::Handle win,
					char const * fileList,
					char const * toPath,
					FILEOP_FLAGS flags,
					char const * title)
	{
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative ();
		fileInfo.wFunc = FO_COPY; 
		fileInfo.pFrom = fileList;
		fileInfo.pTo = toPath;
		fileInfo.fFlags = flags;
		fileInfo.lpszProgressTitle = title;
		if (::SHFileOperation (&fileInfo))
		{
			if (fileInfo.fAnyOperationsAborted)
				throw Win::Exception ();
			else
				throw Win::Exception ("Internal error: Cannot copy files to:", toPath);
		}
		if (fileInfo.fAnyOperationsAborted)
			throw Win::Exception ();
		Win::ClearError ();	// Clear any error code set by the shell
	}
Example #6
0
	void Delete (Win::Dow::Handle win, char const * path, FILEOP_FLAGS flags)
	{
		if (!File::Exists (path))
			return;

		// SHFileOperation requires that the from path is ended with double '\0'
		// WARNING: path cannot be allocated on the heap -- SHFileOperation will fail
		char fromPath [MAX_PATH + 2];
		memset (fromPath, 0, sizeof (fromPath));
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative (); 
		fileInfo.wFunc = FO_DELETE; 
		fileInfo.pFrom = fromPath;
		fileInfo.fFlags = flags;
		strcpy (fromPath, path);
		if (::SHFileOperation (&fileInfo))
		{
			if (fileInfo.fAnyOperationsAborted)
				throw Win::Exception ();
			else
				throw Win::Exception ("Internal error: Cannot delete file or folder.", fromPath);
		}
		if (fileInfo.fAnyOperationsAborted)
			throw Win::Exception ();
		Win::ClearError ();	// Clear any error code set by the shell
	}
Example #7
0
	bool Properties (Win::Dow::Handle win, char const * path, char const * page)
    {
		std::wstring wPath = ToWString (path);
		std::wstring wPage = ToWString (page);
		BOOL result = ::SHObjectProperties (win.ToNative (),
									SHOP_FILEPATH,
									&wPath [0],
									&wPage [0]);
		return result != FALSE;
    }
Example #8
0
	// Peek at the queue and process only messages
	// to the specified window. Don't translate accellerators
	void MessagePrepro::PumpPeek (Win::Dow::Handle hwnd)
	{
		MSG  msg;
		int status;
		while ((status = ::PeekMessage (&msg, hwnd.ToNative (), 0, 0, PM_REMOVE )) != 0)
		{
			if (status == -1)
				throw Win::Exception ("Error in the Windows peek message loop");
			::TranslateMessage (&msg);
			::DispatchMessage (&msg);
		}
	}
Example #9
0
	int ModalMessagePrepro::Pump (Win::Dow::Handle hwnd)
	{
		MSG  msg;
		int status;
		while ((status = ::GetMessage (&msg, hwnd.ToNative (), 0, 0 )) != 0)
		{
			if (status == -1)
				throw Win::Exception ("Error in the Windows modal message loop");
			if (msg.message == _breakMsg)
				break;
			switch (msg.message)
			{
			// Filter out the following messages:
			// Mouse
			case WM_LBUTTONDBLCLK:
			case WM_LBUTTONDOWN:
			case WM_LBUTTONUP:
			case WM_MBUTTONDBLCLK:
			case WM_MBUTTONDOWN:
			case WM_MBUTTONUP:
			case WM_MOUSEACTIVATE:
			// Revisit: WM_MOUSEHOVER not available in NT 4.0 even the docs says otherwise ?!?
			//case WM_MOUSEHOVER:
			case WM_MOUSEMOVE:
			// Revisit: WM_MOUSEWHEEL not available in NT 4.0 even the docs says otherwise ?!?
			//case WM_MOUSEWHEEL:
			case WM_RBUTTONDBLCLK:
			case WM_RBUTTONDOWN:
			case WM_RBUTTONUP:
			// Keyboard
			case WM_CHAR:
			case WM_CHARTOITEM:
			case WM_DEADCHAR:
			case WM_GETHOTKEY:
			case WM_HOTKEY:
			case WM_KEYDOWN:
			case WM_KEYUP:
			case WM_SETHOTKEY:
			case WM_SYSKEYDOWN:
			case WM_SYSKEYUP:
			case WM_SYSCHAR:
			case WM_SYSDEADCHAR:
			case WM_VKEYTOITEM:
				break;
			default:
				// Dispatch all other messages
				::TranslateMessage (&msg);
				::DispatchMessage (&msg);
				break;
			}
		}
		return msg.wParam;
	}
Example #10
0
	int MessagePrepro::PumpHidden (Win::Dow::Handle hwnd)
	{
		MSG  msg;
		int status;
		while ((status = ::GetMessage (&msg, hwnd.ToNative (), 0, 0 )) != 0)
		{
			if (status == -1)
				throw Win::Exception ("Error in the Windows message loop");
			if (msg.message == _breakMsg)
				break;
			::DispatchMessage (&msg);
		}
		return msg.wParam;
	}
Example #11
0
	// Doesn't throw when delete fails -- returns false instead
	bool QuietDelete (Win::Dow::Handle win, char const * path) 
	{
		// SHFileOperation requires that the from path is ended with double '\0'
		// WARNING: path cannot be allocated on the heap -- SHFileOperation will fail
		char fromPath [MAX_PATH + 2];
		memset (fromPath, 0, sizeof (fromPath));
		SHFILEOPSTRUCT fileInfo;
		memset (&fileInfo, 0, sizeof (fileInfo));
		fileInfo.hwnd = win.ToNative (); 
		fileInfo.wFunc = FO_DELETE; 
		fileInfo.pFrom = fromPath;
		fileInfo.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;
		strcpy (fromPath, path);
		int result = ::SHFileOperation (&fileInfo);
		Win::ClearError ();	// Clear any error code set by the shell
		return (result == 0) && !fileInfo.fAnyOperationsAborted;
	}
Example #12
0
	int MessagePrepro::Pump (Win::Dow::Handle hwnd)
	{
		MSG  msg;
		int status;
		while ((status = ::GetMessage (&msg, hwnd.ToNative (), 0, 0 )) != 0)
		{
			if (status == -1)
				throw Win::Exception ("Error in the Windows message loop");
			if (_winDlg.IsNull () || !::IsDialogMessage (_winDlg.ToNative (), &msg))
			{
				if (_accel == 0 || !_accel->Translate (msg)) 
				{
					::TranslateMessage (&msg);
					::DispatchMessage (&msg);
				}
			}
		}
		return msg.wParam;
	}
Example #13
0
FolderBrowser::FolderBrowser (Win::Dow::Handle winOwner,
							  Ptr<ITEMIDLIST> & pidlRoot,
							  char const * userInstructions,
							  char const * dlgWinCaption,
							  char const * startupFolder)
{
	std::pair<char const *, char const *> initData (dlgWinCaption, startupFolder);
    _displayName [0] = '\0';
    _fullPath [0] = '\0';
    _browseInfo.hwndOwner = winOwner.ToNative ();
	_browseInfo.pidlRoot = pidlRoot;
    _browseInfo.pszDisplayName = _displayName;
    _browseInfo.lpszTitle = userInstructions; 
    _browseInfo.ulFlags = BIF_RETURNONLYFSDIRS  | BIF_NEWDIALOGSTYLE; 
	_browseInfo.lpfn = ShellMan::FolderBrowser::BrowseCallbackProc; 
    _browseInfo.lParam = reinterpret_cast<LPARAM>(&initData);
    _browseInfo.iImage = 0;
    _p = SHBrowseForFolder (&_browseInfo);
    if (_p != 0)
        SHGetPathFromIDList (_p, _fullPath);
}
Example #14
0
// returns ShellMan::Success if success
int ShellAction (Win::Dow::Handle win, char const * action, char const * path, char const * arguments = 0)
{
	HINSTANCE hInst = ::ShellExecute (win.ToNative (), action, path, arguments, 0, SW_SHOWNORMAL);
	return ErrCode (hInst);
}
Example #15
0
void Tool::Rebar::BandInfo::AddChildWin (Win::Dow::Handle win)
{
	Assert (hwndChild == 0);
	fMask |= RBBIM_CHILD;
	hwndChild = win.ToNative ();
}