Example #1
0
bool Progress::MultiCtrlHandler::OnInitDialog () 
{
	Win::Dow::Handle dlgWin (GetWindow ());
	_caption.Init (dlgWin, Progress::MultiMeterDialog::CaptionId);
	_overallActivity.Init (dlgWin, Progress::MultiMeterDialog::OverallActivityId);
	_overallBar.Init (dlgWin, Progress::MultiMeterDialog::OverallProgressBarId);
	_specificActivity.Init (dlgWin, Progress::MultiMeterDialog::SpecificActivityId);
	_specificBar.Init (dlgWin, Progress::MultiMeterDialog::SpecificProgressBarId);
	_cancel.Init (dlgWin, Out::Cancel);

	dlgWin.SetText (_dlgData.GetTitle ());
	dlgWin.CenterOverOwner ();

	if (!_overall.CanCancel ())
		_cancel.Disable ();

	_progressTimer.Attach (dlgWin);
	unsigned int initialDelay = _dlgData.GetInitialDelay ();
	if (initialDelay != 0)
	{
		// Wait initial delay milliseconds before showing progress meter
		_progressTimer.Set (initialDelay);
	}
	else
	{
		_progressTimer.Set (Progress::CtrlHandler::Tick);	// Progress tick is 0,5 second
		Show ();
	}

	return true;
}
Example #2
0
int Win::Main (Win::Instance hInst, char const * cmdParam, int cmdShow)
{
	try
	{
		TheOutput.Init ("Unit Test");
		// Create top window class
		Win::Class::TopMaker topWinClass ("UnitTestClass", hInst);
		topWinClass.Register ();

		// Create Window Controller (needs access to MessagePrepro)
		Win::MessagePrepro msgPrepro;
		TopCtrl ctrl;

		// Create top window (hidden)
		Win::TopMaker topWin ("Unit Test", "UnitTestClass", hInst);
		Win::Dow::Handle appWin = topWin.Create (&ctrl);
		appWin.Show (cmdShow);
		// The main message loop
		return msgPrepro.Pump ();
	}
	catch (Win::Exception e)
	{
		TheOutput.Display (e);
	}
	catch (...)
	{
		Win::ClearError ();
		TheOutput.Display ("Internal error: Unknown exception", Out::Error);
	}
	return 0;
}
Example #3
0
void Progress::MultiCtrlHandler::Refresh ()
{
	// Refresh caption
	_caption.SetText (_dlgData.GetCaption ());

	int min, max, step;
	// Refresh overall meter
	if (_overall.GetRange (min, max, step))
		_overallBar.SetRange (min, max, step);
	int position;
	if (_overall.GetPosition (position))
		_overallBar.StepTo (position);
	if (_overall.GetActivity (_overallActivityStr))
		_overallActivity.SetText (_overallActivityStr);

	// Refresh specific meter
	if (_specific.GetRange (min, max, step))
		_specificBar.SetRange (min, max, step);
	if (_specific.GetPosition (position))
		_specificBar.StepTo (position);
	if (_specific.GetActivity (_specificActivityStr))
		_specificActivity.SetText (_specificActivityStr);

	Win::Dow::Handle dlgWin (GetWindow ());
	dlgWin.Update ();
}
Example #4
0
int CALLBACK FolderBrowser::BrowseCallbackProc (HWND winBrowseDlg,
												UINT uMsg,
												LPARAM lParam,
												LPARAM lpData)
{
	if (uMsg == BFFM_INITIALIZED && lpData != 0)
	{
		// lpData == _browseInfo.lParam == pointer to the initialization data
		std::pair<char const *, char const *> const * initData =
			reinterpret_cast<std::pair<char const *, char const *> const *>(lpData);
		Win::Dow::Handle dlgWin (winBrowseDlg);
		if (initData->first != 0)
		{
			// Window caption specified -- display it
			dlgWin.SetText (initData->first);
		}
		if (initData->second != 0)
		{
			// Startup folder specified -- expand it
			// Convert path to UNICODE
			std::wstring wPath = ::ToWString (initData->second);
			Win::Message msg (BFFM_SETEXPANDED, TRUE, reinterpret_cast<LPARAM>(wPath.c_str ()));
			dlgWin.SendMsg (msg);
		}
	}
	return 0;
}
Example #5
0
bool TopCtrl::OnCreate (Win::CreateData const * create, bool & success) throw ()
{
	Win::Dow::Handle win = GetWindow ();
	try
	{
		win.SetText ("Unit Test");
		Win::EditMaker editMaker (_h, 1);
		editMaker.Style () 
			<< Win::Edit::Style::MultiLine 
			<< Win::Edit::Style::AutoVScroll 
			<< Win::Style::Ex::ClientEdge
			<< Win::Style::AddVScrollBar;
		_output.Reset (editMaker.Create ());
		_watch.reset (new Watch (win));
		_timer.Attach (win);

		win.PostMsg (_initMsg);
		success = true;
	}
	catch (Win::Exception e)
	{
		TheOutput.Display (e);
		success = false;
	}
	catch (...)
	{
		Win::ClearError ();
		TheOutput.Display ("Initialization -- Unknown Error", Out::Error);
		success = false;
	}
	TheOutput.SetParent (win);
	_ready = true;
	return true;
}
Example #6
0
FocusBar::Use::~Use ()
{
	while (_ctrls.size () > 0)
	{
		std::auto_ptr<FocusBar::Ctrl> ctrl (_ctrls.pop_back ());
		Win::Dow::Handle win = ctrl->GetWindow ();
		win.Destroy ();
	}
}
Example #7
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 #8
0
FocusBar::Ctrl * FocusBar::Use::MakeBarWindow (Win::Dow::Handle hwndParent,
											   unsigned id,
											   unsigned associatedId,
											   Focus::Ring & focusRing)
{
	std::auto_ptr<FocusBar::Ctrl> newCtrl (new FocusBar::Ctrl (id, associatedId, focusRing));
	Win::ChildMaker focusMaker (_className, hwndParent, id);
	Win::Dow::Handle win = focusMaker.Create (newCtrl.get ());
	FocusBar::Ctrl * ctrl = newCtrl.get ();
	_ctrls.push_back (newCtrl);
	win.Show ();
	return ctrl;
}
Example #9
0
//----------
// Tool::Bar
//----------
Bar::Bar (Win::Dow::Handle winParent,
		  int toolbarId,
		  int bitmapId,
		  int buttonWidth,
		  Cmd::Vector const & cmdVector,
		  Tool::Item const * buttonItems,
		  Win::Style const & barStyle)
	: _buttonImages (winParent.GetInstance (), bitmapId, buttonWidth),
	  _cmdVector (cmdVector),
	  _buttonItems (buttonItems)
{
	Tool::Maker maker (winParent, toolbarId);
	maker.Style () << barStyle;
	Reset (maker.Create ());
	int width, height;
	_buttonImages.GetImageSize (width, height);
	SetButtonSize (width, height);
	SetImageList (_buttonImages);

	// Map button id to command id and cmd id to button item index
	for (unsigned i = 0; _buttonItems [i].buttonId != Item::idEnd; ++i)
	{
		int buttonId = _buttonItems [i].buttonId;
		if (buttonId != Item::idSeparator)
		{
			int cmdId = _cmdVector.Cmd2Id (_buttonItems [i].cmdName);
			Assert (cmdId != -1);
			_buttonId2CmdId [buttonId] = cmdId;
			_cmdId2ButtonIdx [cmdId] = i;
		}
	}
}
Example #10
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 #11
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 #12
0
void Progress::SingleCtrlHandler::Refresh ()
{
	_caption.SetText (_dlgData.GetCaption ());

	int min, max, step;
	if (_channel.GetRange (min, max, step))
		_bar.SetRange (min, max, step);
	int position;
	if (_channel.GetPosition (position))
		_bar.StepTo (position);
	if (_channel.GetActivity (_activityStr))
		_activity.SetText (_activityStr);

	Win::Dow::Handle dlgWin (GetWindow ());
	dlgWin.Update ();
}
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
0
bool TopCtrl::OnCreate (Win::CreateData const * create, bool & success) 
{
	Win::Dow::Handle win = GetWindow ();
	ResString caption (win.GetInstance (), ID_CAPTION);
	try
	{
		TheOutput.Init (caption);
		win.SetText (caption);
		_commander.reset (new Commander (win));
		_commander->SetModelessManager (&_modelessMan);
		_cmdVector.reset (new CmdVector (Cmd::Table, _commander.get ()));
		Accel::Maker accelMaker (Accel::Keys, *_cmdVector);
		_kbdAccel.reset (new Accel::Handler (win, accelMaker.Create ()));
		_msgPrepro.SetKbdAccelerator (_kbdAccel.get ());
		_menu.reset (new Menu::DropDown (Menu::barItems, *_cmdVector));
		_menu->AttachToWindow (win);
		_view.reset (new View (win));
		RegisterAsDropTarget(win);

		win.PostMsg (_initMsg);
		success = true;
	}
	catch (Win::Exception e)
	{
		TheOutput.Display (e);
		success = false;
	}
	catch (...)
	{
		Win::ClearError ();
		TheOutput.Display ("Initialization -- Unknown Error", Out::Error);
		success = false;
	}
	TheOutput.SetParent (win);
	_ready = true;
	return true;
}
Example #21
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 #22
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 #23
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 #24
0
void Tool::Rebar::BandInfo::AddChildWin (Win::Dow::Handle win)
{
	Assert (hwndChild == 0);
	fMask |= RBBIM_CHILD;
	hwndChild = win.ToNative ();
}
Example #25
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);
}