Ejemplo n.º 1
0
void Container::flash()
{
#ifdef WIN32
                    if (!initFlash){
                        HINSTANCE hLib = GetModuleHandleA("user32");
                        if (hLib != NULL)
                            (DWORD&)FlashWindowEx = (DWORD)GetProcAddress(hLib,"FlashWindowEx");
                        initFlash = true;
                    }
                    if (FlashWindowEx){
                        FLASHWINFO fInfo;
                        fInfo.cbSize  = sizeof(fInfo);
                        fInfo.dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG;
                        fInfo.hwnd = winId();
                        fInfo.uCount = 0;
						fInfo.dwTimeout = 1000;
                        FlashWindowEx(&fInfo);
                    }
#else
#if defined(USE_KDE)
#if KDE_IS_VERSION(3,2,0)
                KWin::demandAttention(winId(), true);
#endif	/* KDE_IS_VERSION(3,2,0) */
#endif	/* USE_KDE */
#endif	/* ndef WIN32 */
}
Ejemplo n.º 2
0
	void SDLWindow::Alert (const char* message, const char* title) {
		
		#ifdef HX_WINDOWS
		
		int count = 0;
		int speed = 0;
		bool stopOnForeground = true;
		
		SDL_SysWMinfo info;
		SDL_VERSION (&info.version);
		SDL_GetWindowWMInfo (sdlWindow, &info);
		
		FLASHWINFO fi;
		fi.cbSize = sizeof (FLASHWINFO);
		fi.hwnd = info.info.win.window;
		fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
		fi.uCount = count;
		fi.dwTimeout = speed;
		FlashWindowEx (&fi);
		
		#endif
		
		if (message) {
			
			SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, title, message, sdlWindow);
			
		}
		
	}
Ejemplo n.º 3
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
    WPARAM wParam, LPARAM lParam) {
  
    FLASHWINFO fwi;

    switch(msg)  {
    
      case WM_CREATE:

          CreateWindowW(L"Button", L"Flash",
                  WS_CHILD | WS_VISIBLE,
                  10, 10, 80, 25, 
                  hwnd, (HMENU) 1, NULL, NULL);
          break;

      case WM_COMMAND:

          fwi.cbSize = sizeof(fwi);
          fwi.dwFlags = FLASHW_ALL;
          fwi.dwTimeout = 0;
          fwi.hwnd = hwnd;
          fwi.uCount = 4;

          FlashWindowEx(&fwi);
          break;

      case WM_DESTROY:

          PostQuitMessage(0);
          break; 
    }

    return DefWindowProcW(hwnd, msg, wParam, lParam);
}
Ejemplo n.º 4
0
//-------------------------------------------------------------------------------------------------
void D2Watcher::flashWindow(uint count) {
    FLASHWINFO flash;
    flash.cbSize = sizeof(FLASHWINFO);
    flash.hwnd = mD2Hwnd;
    flash.dwFlags = FLASHW_TRAY;
    flash.uCount = count;
    flash.dwTimeout = 0;
    FlashWindowEx(&flash);
}
void NotepadPlusWrapper::flashWindow(UINT count, DWORD milliseconds)
{
	FLASHWINFO flashinfo;
	flashinfo.cbSize = sizeof(flashinfo);
	flashinfo.hwnd = m_nppHandle;
	flashinfo.dwFlags = FLASHW_ALL;
	flashinfo.dwTimeout = milliseconds;
	flashinfo.uCount = count;

	FlashWindowEx(&flashinfo);
}
Ejemplo n.º 6
0
void WindowsTaskBar::alert(bool on)
{
	if (on) {
		FLASHWINFO fi = {0};
		fi.cbSize  = sizeof(fi);
		fi.dwFlags = FLASHW_TRAY;
		fi.hwnd    = window()->winId();
		fi.uCount  = 1;
		FlashWindowEx(&fi);
	}
}
Ejemplo n.º 7
0
void TaskBarCore::Flash()
{
	WINDOWINFO WI={sizeof(WI)};

	if (GetWindowInfo(Global->Console->GetWindow(),&WI))
	{
		if (WI.dwWindowStatus!=WS_ACTIVECAPTION)
		{
			FLASHWINFO FWI={sizeof(FWI),Global->Console->GetWindow(),FLASHW_ALL|FLASHW_TIMERNOFG,5,0};
			FlashWindowEx(&FWI);
		}
	}
}
Ejemplo n.º 8
0
void taskbar::Flash()
{
	WINDOWINFO WI={sizeof(WI)};

	if (GetWindowInfo(Console().GetWindow(),&WI))
	{
		if (WI.dwWindowStatus!=WS_ACTIVECAPTION)
		{
			FLASHWINFO FWI={sizeof(FWI),Console().GetWindow(),FLASHW_ALL|FLASHW_TIMERNOFG,5,0};
			FlashWindowEx(&FWI);
		}
	}
}
Ejemplo n.º 9
0
void taskbar::Flash()
{
	const auto ConsoleWindow = console.GetWindow();
	WINDOWINFO WindowInfo{ sizeof(WindowInfo)};

	if (!GetWindowInfo(ConsoleWindow, &WindowInfo))
		return;

	if (WindowInfo.dwWindowStatus == WS_ACTIVECAPTION)
		return;

	FLASHWINFO FlashInfo{sizeof(FlashInfo), ConsoleWindow, FLASHW_ALL | FLASHW_TIMERNOFG, 5, 0};
	FlashWindowEx(&FlashInfo);
}
Ejemplo n.º 10
0
void KviWindow::demandAttention()
{
	WId windowId = isDocked() ? g_pMainWindow->winId() : winId();

#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
	FLASHWINFO fwi;
	fwi.cbSize = sizeof(fwi);
	fwi.hwnd = (HWND)windowId;
	fwi.dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG;
	fwi.uCount = 20;
	fwi.dwTimeout = 500;
	FlashWindowEx(&fwi);
#elif defined(COMPILE_KDE_SUPPORT)
	KWindowSystem::demandAttention(windowId, true);
#endif
}
Ejemplo n.º 11
0
void WindowRequestFocus(_GLFWwindow* window)
{
    // The following can be used to flash the taskbar icon
    // if any of the focus related functions fail
    if (!WindowGrabFocus(window)) {
        // create a taskbar notification ("flash")
        FLASHWINFO info;
        info.cbSize = sizeof(FLASHWINFO);
        info.hwnd = window->win32.handle;
        info.dwFlags = FLASHW_TRAY;
        info.uCount = 3;
        info.dwTimeout = 0;

        FlashWindowEx(&info);
    }
}
Ejemplo n.º 12
0
void
WFlashWindow(HWND fWinHandle)
{
#ifdef BUILD_WIN98	// flash our window
								FLASHWINFO finf;
								finf.cbSize = sizeof(finf);
								finf.hwnd = fWinHandle;
								finf.dwFlags = FLASHW_ALL;
								finf.uCount = 3;
								finf.dwTimeout = 400;
								FlashWindowEx(&finf);
#elif (WINVER < 0x0500)
								FlashWindow(fWinHandle,true);
#else
								FlashWindow(fWinHandle,FLASHW_ALL);
#endif // BUILD_WIN98
}
Ejemplo n.º 13
0
void GCUpdateInfo::onPageLoad()
{
	ERROR_OUTPUT("Showing update form");
	
	Show(true);

#ifdef WIN32
	FLASHWINFO info;

	memset(&info, 0, sizeof(FLASHWINFO));
	info.cbSize = sizeof(FLASHWINFO);
	info.hwnd = (HWND)GetHWND();
	info.dwFlags = FLASHW_TRAY|FLASHW_TIMERNOFG;
	info.uCount = 20;

	FlashWindowEx(&info);
#endif
}
Ejemplo n.º 14
0
void
khm_activate_main_window(void) {

    if (!SetForegroundWindow(khm_hwnd_main)) {
        FLASHWINFO finfo;

        SetActiveWindow(khm_hwnd_main);

        ZeroMemory(&finfo, sizeof(finfo));
        finfo.cbSize = sizeof(finfo);
        finfo.hwnd = khm_hwnd_main;
        finfo.dwFlags = FLASHW_ALL;
        finfo.uCount = 3;
        finfo.dwTimeout = 0;

        FlashWindowEx(&finfo);
    }
}
Ejemplo n.º 15
0
void Window::requestAttention(bool continuous)
{
#if defined(LOVE_WINDOWS) && !defined(LOVE_WINDOWS_UWP)

	if (hasFocus())
		return;

	SDL_SysWMinfo wminfo = {};
	SDL_VERSION(&wminfo.version);

	if (SDL_GetWindowWMInfo(window, &wminfo))
	{
		FLASHWINFO flashinfo = {};
		flashinfo.cbSize = sizeof(FLASHWINFO);
		flashinfo.hwnd = wminfo.info.win.window;
		flashinfo.uCount = 1;
		flashinfo.dwFlags = FLASHW_ALL;

		if (continuous)
		{
			flashinfo.uCount = 0;
			flashinfo.dwFlags |= FLASHW_TIMERNOFG;
		}

		FlashWindowEx(&flashinfo);
	}

#elif defined(LOVE_MACOSX)

	love::macosx::requestAttention(continuous);

#else

	LOVE_UNUSED(continuous);
	
#endif
	
	// TODO: Linux?
}
Ejemplo n.º 16
0
	value lime_window_alert (value message, value title) {
		
		#ifdef NME_SDL2
		
		SDL_Window* sdlWindow = SDL_GL_GetCurrentWindow ();
		if (!sdlWindow) return alloc_null ();
		
		#ifdef HX_WINDOWS
		
		int count = 0;
		int speed = 0;
		bool stopOnForeground = true;
		
		SDL_SysWMinfo info;
		SDL_VERSION (&info.version);
		SDL_GetWindowWMInfo (sdlWindow, &info);
		
		FLASHWINFO fi;
		fi.cbSize = sizeof (FLASHWINFO);
		fi.hwnd = info.info.win.window;
		fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
		fi.uCount = count;
		fi.dwTimeout = speed;
		FlashWindowEx (&fi);
		
		#endif
		
		if (!val_is_null (message)) {
			
			SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, val_is_null (title) ? "" : val_string (title), val_string (message), sdlWindow);
			
		}
		
		#endif
		
		return alloc_null ();
		
	}
Ejemplo n.º 17
0
void *Container::processEvent(Event *e)
{
    UserWnd *userWnd;
    Contact *contact;
    CommandDef *cmd;
    Message *msg;
    switch (e->type()){
    case EventMessageReceived:
        msg = (Message*)(e->param());
        if (msg->type() == MessageStatus){
            contact = getContacts()->contact(msg->contact());
            if (contact)
                contactChanged(contact);
            return NULL;
        }
        if (CorePlugin::m_plugin->getContainerMode()){
            if (isActiveWindow()){
                userWnd = m_tabBar->currentWnd();
                if (userWnd && (userWnd->id() == msg->contact()))
                    userWnd->markAsRead();
            }
#ifdef WIN32
            if (!isActiveWindow()){
                msg = (Message*)(e->param());
                userWnd = wnd(msg->contact());
                if (userWnd){
                    if (!initFlash){
                        HINSTANCE hLib = GetModuleHandleA("user32");
                        if (hLib != NULL)
                            (DWORD&)FlashWindowEx = (DWORD)GetProcAddress(hLib,"FlashWindowEx");
                        initFlash = true;
                    }
                    if (FlashWindowEx){
                        FLASHWINFO fInfo;
                        fInfo.cbSize = sizeof(fInfo);
                        fInfo.dwFlags = 0x0E;
                        fInfo.hwnd = winId();
                        fInfo.uCount = 0;
                        FlashWindowEx(&fInfo);
                    }
                }
            }
#endif
        }
    case EventMessageRead:
        msg = (Message*)(e->param());
        userWnd = wnd(msg->contact());
        if (userWnd){
            bool bBold = false;
            for (list<msg_id>::iterator it = CorePlugin::m_plugin->unread.begin(); it != CorePlugin::m_plugin->unread.end(); ++it){
                if ((*it).contact != msg->contact())
                    continue;
                bBold = true;
                break;
            }
            m_tabBar->setBold(msg->contact(), bBold);
        }
        break;
    case EventActiveContact:
        if (!isActiveWindow())
            return NULL;
        userWnd = m_tabBar->currentWnd();
        if (userWnd)
            return (void*)(userWnd->id());
        break;
    case EventContactDeleted:
        contact = (Contact*)(e->param());
        userWnd = wnd(contact->id());
        if (userWnd)
            removeUserWnd(userWnd);
        break;
    case EventContactChanged:
        contact = (Contact*)(e->param());
        userWnd = wnd(contact->id());
        if (userWnd){
            if (contact->getIgnore()){
                removeUserWnd(userWnd);
                break;
            }
            m_tabBar->changeTab(contact->id());
            contactChanged(contact);
        }
    case EventClientsChanged:
        setupAccel();
        break;
    case EventContactStatus:
        contact = (Contact*)(e->param());
        userWnd = m_tabBar->wnd(contact->id());
        if (userWnd){
            unsigned style = 0;
            string wrkIcons;
            const char *statusIcon = NULL;
            contact->contactInfo(style, statusIcon, &wrkIcons);
            bool bTyping = false;
            while (!wrkIcons.empty()){
                if (getToken(wrkIcons, ',') == "typing"){
                    bTyping = true;
                    break;
                }
            }
            if (userWnd->m_bTyping != bTyping){
                userWnd->m_bTyping = bTyping;
                if (bTyping){
                    userWnd->setStatus(i18n("Contact typed message"));
                }else{
                    userWnd->setStatus("");
                }
                userWnd = m_tabBar->currentWnd();
                if (userWnd && (contact->id() == userWnd->id()))
                    m_status->message(userWnd->status());
            }
        }
        break;
    case EventContactClient:
        contactChanged((Contact*)(e->param()));
        break;
    case EventInit:
        init();
        break;
    case EventCommandExec:
        cmd = (CommandDef*)(e->param());
        userWnd = m_tabBar->currentWnd();
        if (userWnd && ((unsigned)(cmd->param) == userWnd->id())){
            if (cmd->menu_id == MenuContainerContact){
                m_tabBar->raiseTab(cmd->id);
                return e->param();
            }
            if (cmd->id == CmdClose){
                delete userWnd;
                return e->param();
            }
            if (cmd->id == CmdInfo){
                CommandDef c = *cmd;
                c.menu_id = MenuContact;
                c.param   = (void*)userWnd->id();
                Event eExec(EventCommandExec, &c);
                eExec.process();
                return e->param();
            }
        }
        break;
    case EventCheckState:
        cmd = (CommandDef*)(e->param());
        userWnd = m_tabBar->currentWnd();
        if (userWnd && ((unsigned)(cmd->param) == userWnd->id()) &&
                (cmd->menu_id == MenuContainerContact) &&
                (cmd->id == CmdContainerContacts)){
            list<UserWnd*> userWnds = m_tabBar->windows();
            CommandDef *cmds = new CommandDef[userWnds.size() + 1];
            memset(cmds, 0, sizeof(CommandDef) * (userWnds.size() + 1));
            unsigned n = 0;
            for (list<UserWnd*>::iterator it = userWnds.begin(); it != userWnds.end(); ++it){
                cmds[n].id = (*it)->id();
                cmds[n].flags = COMMAND_DEFAULT;
                cmds[n].text_wrk = strdup((*it)->getName().utf8());
                cmds[n].icon  = (*it)->getIcon();
                cmds[n].text  = "_";
                cmds[n].menu_id = n + 1;
                if (n < sizeof(accels) / sizeof(const char*))
                    cmds[n].accel = accels[n];
                if (*it == m_tabBar->currentWnd())
                    cmds[n].flags |= COMMAND_CHECKED;
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
        break;
    }
    return NULL;
}
Ejemplo n.º 18
0
LRESULT CMainWindow::DoCommand(int id)
{
	switch (id)
	{
	case ID_FILE_OPEN:
		loadOrSaveFile(true);
		break;
	case ID_FILE_SAVEAS:
		loadOrSaveFile(false);
		break;
	case ID_FILE_SAVE:
		loadOrSaveFile(false, m_filename);
		break;
	case ID_FILE_EXIT:
		::PostQuitMessage(0);
		return 0;
	case IDM_SHOWFINDBAR:
		{
			m_bShowFindBar = true;
			::ShowWindow(m_FindBar, SW_SHOW);
			RECT rect;
			GetClientRect(*this, &rect);
			::SetWindowPos(m_hWndEdit, HWND_TOP,
				rect.left, rect.top,
				rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactorY()),
				SWP_SHOWWINDOW);
			::SetWindowPos(m_FindBar, HWND_TOP,
				rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactorY()),
				rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactorY()),
				SWP_SHOWWINDOW);
			::SetFocus(m_FindBar);
			SendEditor(SCI_SETSELECTIONSTART, 0);
			SendEditor(SCI_SETSELECTIONEND, 0);
			SendEditor(SCI_SEARCHANCHOR);
		}
		break;
	case IDM_FINDNEXT:
		SendEditor(SCI_CHARRIGHT);
		SendEditor(SCI_SEARCHANCHOR);
		if (SendEditor(SCI_SEARCHNEXT, m_bMatchCase ? SCFIND_MATCHCASE : 0, reinterpret_cast<LPARAM>(CUnicodeUtils::StdGetUTF8(m_findtext).c_str())) == -1)
		{
			FLASHWINFO fwi;
			fwi.cbSize = sizeof(FLASHWINFO);
			fwi.uCount = 3;
			fwi.dwTimeout = 100;
			fwi.dwFlags = FLASHW_ALL;
			fwi.hwnd = m_hwnd;
			FlashWindowEx(&fwi);
		}
		SendEditor(SCI_SCROLLCARET);
		break;
	case IDM_FINDPREV:
		SendEditor(SCI_SEARCHANCHOR);
		if (SendEditor(SCI_SEARCHPREV, m_bMatchCase ? SCFIND_MATCHCASE : 0, reinterpret_cast<LPARAM>(CUnicodeUtils::StdGetUTF8(m_findtext).c_str())) == -1)
		{
			FLASHWINFO fwi;
			fwi.cbSize = sizeof(FLASHWINFO);
			fwi.uCount = 3;
			fwi.dwTimeout = 100;
			fwi.dwFlags = FLASHW_ALL;
			fwi.hwnd = m_hwnd;
			FlashWindowEx(&fwi);
		}
		SendEditor(SCI_SCROLLCARET);
		break;
	case IDM_FINDEXIT:
		if (IsWindowVisible(m_FindBar))
		{
			RECT rect;
			GetClientRect(*this, &rect);
			m_bShowFindBar = false;
			::ShowWindow(m_FindBar, SW_HIDE);
			::SetWindowPos(m_hWndEdit, HWND_TOP,
				rect.left, rect.top,
				rect.right-rect.left, rect.bottom-rect.top,
				SWP_SHOWWINDOW);
		}
		else
			PostQuitMessage(0);
		break;
	case ID_FILE_SETTINGS:
		{
			tstring gitCmd = L" /command:settings /page:udiff";
			RunCommand(gitCmd);
		}
		break;
	case ID_FILE_APPLYPATCH:
		{
			std::wstring command = L" /diff:\"";
			command += m_filename;
			command += L'"';
			std::wstring tortoiseMergePath = GetAppDirectory() + L"TortoiseGitMerge.exe";
			CCreateProcessHelper::CreateProcessDetached(tortoiseMergePath.c_str(), command.c_str());
		}
		break;
	case ID_FILE_PAGESETUP:
		{
			TCHAR localeInfo[3] = { 0 };
			GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
			// Metric system. '1' is US System
			int defaultMargin = localeInfo[0] == '0' ? 2540 : 1000;

			PAGESETUPDLG pdlg = {0};
			pdlg.lStructSize = sizeof(PAGESETUPDLG);
			pdlg.hwndOwner = *this;
			pdlg.hInstance = nullptr;
			pdlg.Flags = PSD_DEFAULTMINMARGINS|PSD_MARGINS|PSD_DISABLEPAPER|PSD_DISABLEORIENTATION;
			if (localeInfo[0] == '0')
				pdlg.Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;

			CRegStdDWORD m_regMargLeft   = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginleft", defaultMargin);
			CRegStdDWORD m_regMargTop    = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmargintop", defaultMargin);
			CRegStdDWORD m_regMargRight  = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginright", defaultMargin);
			CRegStdDWORD m_regMargBottom = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginbottom", defaultMargin);

			pdlg.rtMargin.left   = static_cast<long>(m_regMargLeft);
			pdlg.rtMargin.top    = static_cast<long>(m_regMargTop);
			pdlg.rtMargin.right  = static_cast<long>(m_regMargRight);
			pdlg.rtMargin.bottom = static_cast<long>(m_regMargBottom);

			if (!PageSetupDlg(&pdlg))
				return false;

			m_regMargLeft   = pdlg.rtMargin.left;
			m_regMargTop    = pdlg.rtMargin.top;
			m_regMargRight  = pdlg.rtMargin.right;
			m_regMargBottom = pdlg.rtMargin.bottom;
		}
		break;
	case ID_FILE_PRINT:
		{
			PRINTDLGEX pdlg = {0};
			pdlg.lStructSize = sizeof(PRINTDLGEX);
			pdlg.hwndOwner = *this;
			pdlg.hInstance = nullptr;
			pdlg.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_ALLPAGES | PD_RETURNDC | PD_NOCURRENTPAGE | PD_NOPAGENUMS;
			pdlg.nMinPage = 1;
			pdlg.nMaxPage = 0xffffU; // We do not know how many pages in the document
			pdlg.nCopies = 1;
			pdlg.hDC = 0;
			pdlg.nStartPage = START_PAGE_GENERAL;

			// See if a range has been selected
			auto startPos = static_cast<Sci_Position>(SendEditor(SCI_GETSELECTIONSTART));
			auto endPos = static_cast<Sci_Position>(SendEditor(SCI_GETSELECTIONEND));

			if (startPos == endPos)
				pdlg.Flags |= PD_NOSELECTION;
			else
				pdlg.Flags |= PD_SELECTION;

			HRESULT hResult = PrintDlgEx(&pdlg);
			if ((hResult != S_OK) || (pdlg.dwResultAction != PD_RESULT_PRINT))
				return 0;

			// reset all indicators
			auto endpos = static_cast<int>(SendEditor(SCI_GETLENGTH));
			for (int i = INDIC_CONTAINER; i <= INDIC_MAX; ++i)
			{
				SendEditor(SCI_SETINDICATORCURRENT, i);
				SendEditor(SCI_INDICATORCLEARRANGE, 0, endpos);
			}
			// store and reset UI settings
			auto viewws = static_cast<int>(SendEditor(SCI_GETVIEWWS));
			SendEditor(SCI_SETVIEWWS, 0);
			auto edgemode = static_cast<int>(SendEditor(SCI_GETEDGEMODE));
			SendEditor(SCI_SETEDGEMODE, EDGE_NONE);
			SendEditor(SCI_SETWRAPVISUALFLAGS, SC_WRAPVISUALFLAG_END);

			HDC hdc = pdlg.hDC;

			RECT rectMargins, rectPhysMargins;
			POINT ptPage;
			POINT ptDpi;

			// Get printer resolution
			ptDpi.x = GetDeviceCaps(hdc, LOGPIXELSX);    // dpi in X direction
			ptDpi.y = GetDeviceCaps(hdc, LOGPIXELSY);    // dpi in Y direction

			// Start by getting the physical page size (in device units).
			ptPage.x = GetDeviceCaps(hdc, PHYSICALWIDTH);   // device units
			ptPage.y = GetDeviceCaps(hdc, PHYSICALHEIGHT);  // device units

			// Get the dimensions of the unprintable
			// part of the page (in device units).
			rectPhysMargins.left = GetDeviceCaps(hdc, PHYSICALOFFSETX);
			rectPhysMargins.top = GetDeviceCaps(hdc, PHYSICALOFFSETY);

			// To get the right and lower unprintable area,
			// we take the entire width and height of the paper and
			// subtract everything else.
			rectPhysMargins.right = ptPage.x                        // total paper width
				- GetDeviceCaps(hdc, HORZRES)                       // printable width
				- rectPhysMargins.left;                             // left unprintable margin

			rectPhysMargins.bottom = ptPage.y                       // total paper height
				- GetDeviceCaps(hdc, VERTRES)                       // printable height
				- rectPhysMargins.top;                              // right unprintable margin

			TCHAR localeInfo[3] = { 0 };
			GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
			// Metric system. '1' is US System
			int defaultMargin = localeInfo[0] == '0' ? 2540 : 1000;
			RECT pagesetupMargin;
			CRegStdDWORD m_regMargLeft   = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginleft", defaultMargin);
			CRegStdDWORD m_regMargTop    = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmargintop", defaultMargin);
			CRegStdDWORD m_regMargRight  = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginright", defaultMargin);
			CRegStdDWORD m_regMargBottom = CRegStdDWORD(L"Software\\TortoiseGit\\UDiffpagesetupmarginbottom", defaultMargin);

			pagesetupMargin.left   = static_cast<long>(m_regMargLeft);
			pagesetupMargin.top    = static_cast<long>(m_regMargTop);
			pagesetupMargin.right  = static_cast<long>(m_regMargRight);
			pagesetupMargin.bottom = static_cast<long>(m_regMargBottom);

			if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 ||
				pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0)
			{
				RECT rectSetup;

				// Convert the hundredths of millimeters (HiMetric) or
				// thousandths of inches (HiEnglish) margin values
				// from the Page Setup dialog to device units.
				// (There are 2540 hundredths of a mm in an inch.)
				if (localeInfo[0] == '0')
				{
					// Metric system. '1' is US System
					rectSetup.left      = MulDiv (pagesetupMargin.left, ptDpi.x, 2540);
					rectSetup.top       = MulDiv (pagesetupMargin.top, ptDpi.y, 2540);
					rectSetup.right     = MulDiv(pagesetupMargin.right, ptDpi.x, 2540);
					rectSetup.bottom    = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540);
				}
				else
				{
					rectSetup.left      = MulDiv(pagesetupMargin.left, ptDpi.x, 1000);
					rectSetup.top       = MulDiv(pagesetupMargin.top, ptDpi.y, 1000);
					rectSetup.right     = MulDiv(pagesetupMargin.right, ptDpi.x, 1000);
					rectSetup.bottom    = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000);
				}

				// Don't reduce margins below the minimum printable area
				rectMargins.left    = max(rectPhysMargins.left, rectSetup.left);
				rectMargins.top     = max(rectPhysMargins.top, rectSetup.top);
				rectMargins.right   = max(rectPhysMargins.right, rectSetup.right);
				rectMargins.bottom  = max(rectPhysMargins.bottom, rectSetup.bottom);
			}
			else
			{
				rectMargins.left    = rectPhysMargins.left;
				rectMargins.top     = rectPhysMargins.top;
				rectMargins.right   = rectPhysMargins.right;
				rectMargins.bottom  = rectPhysMargins.bottom;
			}

			// rectMargins now contains the values used to shrink the printable
			// area of the page.

			// Convert device coordinates into logical coordinates
			DPtoLP(hdc, reinterpret_cast<LPPOINT>(&rectMargins), 2);
			DPtoLP(hdc, reinterpret_cast<LPPOINT>(&rectPhysMargins), 2);

			// Convert page size to logical units and we're done!
			DPtoLP(hdc, reinterpret_cast<LPPOINT>(&ptPage), 1);


			DOCINFO di = {sizeof(DOCINFO), 0, 0, 0, 0};
			di.lpszDocName = m_filename.c_str();
			di.lpszOutput = 0;
			di.lpszDatatype = 0;
			di.fwType = 0;
			if (::StartDoc(hdc, &di) < 0)
			{
				::DeleteDC(hdc);
				return 0;
			}

			size_t lengthDoc = static_cast<int>(SendEditor(SCI_GETLENGTH));
			size_t lengthDocMax = lengthDoc;
			size_t lengthPrinted = 0;

			// Requested to print selection
			if (pdlg.Flags & PD_SELECTION)
			{
				if (startPos > endPos)
				{
					lengthPrinted = endPos;
					lengthDoc = startPos;
				}
				else
				{
					lengthPrinted = startPos;
					lengthDoc = endPos;
				}

				if (lengthDoc > lengthDocMax)
					lengthDoc = lengthDocMax;
			}

			// We must subtract the physical margins from the printable area
			Sci_RangeToFormat frPrint;
			frPrint.hdc             = hdc;
			frPrint.hdcTarget       = hdc;
			frPrint.rc.left         = rectMargins.left - rectPhysMargins.left;
			frPrint.rc.top          = rectMargins.top - rectPhysMargins.top;
			frPrint.rc.right        = ptPage.x - rectMargins.right - rectPhysMargins.left;
			frPrint.rc.bottom       = ptPage.y - rectMargins.bottom - rectPhysMargins.top;
			frPrint.rcPage.left     = 0;
			frPrint.rcPage.top      = 0;
			frPrint.rcPage.right    = ptPage.x - rectPhysMargins.left - rectPhysMargins.right - 1;
			frPrint.rcPage.bottom   = ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1;

			// Print each page
			while (lengthPrinted < lengthDoc)
			{
				::StartPage(hdc);

				frPrint.chrg.cpMin = static_cast<long>(lengthPrinted);
				frPrint.chrg.cpMax = static_cast<long>(lengthDoc);

				lengthPrinted = SendEditor(SCI_FORMATRANGE, true, reinterpret_cast<LPARAM>(&frPrint));

				::EndPage(hdc);
			}

			SendEditor(SCI_FORMATRANGE, FALSE, 0);

			::EndDoc(hdc);
			::DeleteDC(hdc);

			if (pdlg.hDevMode)
				GlobalFree(pdlg.hDevMode);
			if (pdlg.hDevNames)
				GlobalFree(pdlg.hDevNames);
			if (pdlg.lpPageRanges)
				GlobalFree(pdlg.lpPageRanges);

			// reset the UI
			SendEditor(SCI_SETVIEWWS, viewws);
			SendEditor(SCI_SETEDGEMODE, edgemode);
			SendEditor(SCI_SETWRAPVISUALFLAGS, SC_WRAPVISUALFLAG_NONE);
		}
		break;
	default:
		break;
	};
	return 1;
}
Ejemplo n.º 19
0
LRESULT CALLBACK CMainWindow::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == TaskBarButtonCreated)
	{
		SetUUIDOverlayIcon(hwnd);
	}
	switch (uMsg)
	{
	case WM_CREATE:
		{
			m_hwnd = hwnd;
			Initialize();
		}
		break;
	case WM_COMMAND:
		{
			return DoCommand(LOWORD(wParam));
		}
		break;
	case WM_MOUSEWHEEL:
		{
			if (GET_KEYSTATE_WPARAM(wParam) == MK_SHIFT)
			{
				// scroll sideways
				SendEditor(SCI_LINESCROLL, -GET_WHEEL_DELTA_WPARAM(wParam)/40, 0);
			}
			else
				return DefWindowProc(hwnd, uMsg, wParam, lParam);
		}
		break;
	case WM_SIZE:
		{
			RECT rect;
			GetClientRect(*this, &rect);
			if (m_bShowFindBar)
			{
				::SetWindowPos(m_hWndEdit, HWND_TOP,
					rect.left, rect.top,
					rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactorY()),
					SWP_SHOWWINDOW);
				::SetWindowPos(m_FindBar, HWND_TOP,
					rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactorY()),
					rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactorY()),
					SWP_SHOWWINDOW);
			}
			else
			{
				::SetWindowPos(m_hWndEdit, HWND_TOP,
					rect.left, rect.top,
					rect.right-rect.left, rect.bottom-rect.top,
					SWP_SHOWWINDOW);
				::ShowWindow(m_FindBar, SW_HIDE);
			}
		}
		break;
	case WM_GETMINMAXINFO:
		{
			auto mmi = reinterpret_cast<MINMAXINFO*>(lParam);
			mmi->ptMinTrackSize.x = 100;
			mmi->ptMinTrackSize.y = 100;
			return 0;
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case WM_CLOSE:
		::DestroyWindow(m_hwnd);
		break;
	case WM_SETFOCUS:
		SetFocus(m_hWndEdit);
		break;
	case WM_SYSCOLORCHANGE:
		SetupColors(true);
		break;
	case COMMITMONITOR_FINDMSGNEXT:
		{
			SendEditor(SCI_CHARRIGHT);
			SendEditor(SCI_SEARCHANCHOR);
			m_bMatchCase = !!wParam;
			m_findtext = reinterpret_cast<LPCTSTR>(lParam);
			if (SendEditor(SCI_SEARCHNEXT, m_bMatchCase ? SCFIND_MATCHCASE : 0, reinterpret_cast<LPARAM>(CUnicodeUtils::StdGetUTF8(m_findtext).c_str())) == -1)
			{
				FLASHWINFO fwi;
				fwi.cbSize = sizeof(FLASHWINFO);
				fwi.uCount = 3;
				fwi.dwTimeout = 100;
				fwi.dwFlags = FLASHW_ALL;
				fwi.hwnd = m_hwnd;
				FlashWindowEx(&fwi);
			}
			SendEditor(SCI_SCROLLCARET);
		}
		break;
	case COMMITMONITOR_FINDMSGPREV:
		{
			SendEditor(SCI_SEARCHANCHOR);
			m_bMatchCase = !!wParam;
			m_findtext = reinterpret_cast<LPCTSTR>(lParam);
			if (SendEditor(SCI_SEARCHPREV, m_bMatchCase ? SCFIND_MATCHCASE : 0, reinterpret_cast<LPARAM>(CUnicodeUtils::StdGetUTF8(m_findtext).c_str())) == -1)
			{
				FLASHWINFO fwi;
				fwi.cbSize = sizeof(FLASHWINFO);
				fwi.uCount = 3;
				fwi.dwTimeout = 100;
				fwi.dwFlags = FLASHW_ALL;
				fwi.hwnd = m_hwnd;
				FlashWindowEx(&fwi);
			}
			SendEditor(SCI_SCROLLCARET);
		}
		break;
	case COMMITMONITOR_FINDEXIT:
		{
			RECT rect;
			GetClientRect(*this, &rect);
			m_bShowFindBar = false;
			::ShowWindow(m_FindBar, SW_HIDE);
			::SetWindowPos(m_hWndEdit, HWND_TOP,
				rect.left, rect.top,
				rect.right-rect.left, rect.bottom-rect.top,
				SWP_SHOWWINDOW);
		}
		break;
	case COMMITMONITOR_FINDRESET:
		SendEditor(SCI_SETSELECTIONSTART, 0);
		SendEditor(SCI_SETSELECTIONEND, 0);
		SendEditor(SCI_SEARCHANCHOR);
		break;
	default:
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
	}

	return 0;
};
Ejemplo n.º 20
0
void TopWindow::SyncCaption()
{
	GuiLock __;
	LLOG("TopWindow::SyncCaption " << UPP::Name(this));
	if(fullscreen)
		return;
	HWND hwnd = GetHWND();
	if(hwnd) {
		style = ::GetWindowLong(hwnd, GWL_STYLE);
		exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
	}
	style &= ~(WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU|WS_POPUP|WS_DLGFRAME);
	exstyle &= ~(WS_EX_TOOLWINDOW|WS_EX_DLGMODALFRAME);
	style |= WS_CAPTION;
	if(hasdhctrl)
		style |= WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
	if(minimizebox)
		style |= WS_MINIMIZEBOX;
	if(maximizebox)
		style |= WS_MAXIMIZEBOX;
	if(sizeable)
		style |= WS_THICKFRAME;
#ifndef PLATFORM_WINCE
	if(frameless)
		style = (style & ~WS_CAPTION) | WS_POPUP;
	else
	if(IsNull(icon) && !maximizebox && !minimizebox || noclosebox) {
		style |= WS_POPUPWINDOW|WS_DLGFRAME;
		exstyle |= WS_EX_DLGMODALFRAME;
		if(noclosebox)
			style &= ~WS_SYSMENU;
	}
	else
#endif
		style |= WS_SYSMENU;
	if(tool)
		exstyle |= WS_EX_TOOLWINDOW;
	if(fullscreen)
		style = WS_POPUP;
	if(hwnd) {
		::SetWindowLong(hwnd, GWL_STYLE, style);
		::SetWindowLong(hwnd, GWL_EXSTYLE, exstyle);
		SyncTitle();
		if(urgent) {
			if(IsForeground()) urgent = false;
			FLASHWINFO fi;
			memset(&fi, 0, sizeof(fi));
			fi.cbSize = sizeof(fi);
			fi.hwnd = hwnd;
			fi.dwFlags = urgent ? FLASHW_TIMER|FLASHW_ALL : FLASHW_STOP;
			FlashWindowEx(&fi);
		}
	}
	DeleteIco();
#ifndef PLATFORM_WINCE //TODO!!!
	if(hwnd) {
		::SendMessage(hwnd, WM_SETICON, false, (LPARAM)(ico = SystemDraw::IconWin32(icon)));
		::SendMessage(hwnd, WM_SETICON, true, (LPARAM)(lico = SystemDraw::IconWin32(largeicon)));
	}
#endif
}