mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Even more Word hacking... now sends SE window to back before displaying spell check dialog
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@256 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
6b0fcf3544
commit
7d95942fbb
@ -2349,7 +2349,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
double seconds = double.Parse(adjustDisplayTime.AdjustValue);
|
||||
_subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndexes);
|
||||
}
|
||||
ShowStatus(string.Format(_language.DisplayTimeAdjustedX, adjustDisplayTime.AdjustValue));
|
||||
ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue));
|
||||
SaveSubtitleListviewIndexes();
|
||||
if (IsFramesRelevant)
|
||||
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
|
||||
@ -3934,7 +3934,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
UpdateStartTimeInfo(timeUpDownStartTime.TimeCode);
|
||||
_change = true;
|
||||
MakeHistoryForUndoWhenNoMoreChanges(string.Format(_language.StartimeAdjustedX, "#" + (_subtitleListViewIndex+1).ToString() + ": " + timeUpDownStartTime.TimeCode.ToString()));
|
||||
MakeHistoryForUndoWhenNoMoreChanges(string.Format(_language.StarTimeAdjustedX, "#" + (_subtitleListViewIndex+1).ToString() + ": " + timeUpDownStartTime.TimeCode.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5193,27 +5193,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_cancelWordSpellCheck = true;
|
||||
}
|
||||
|
||||
//else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D)
|
||||
//{
|
||||
// InsertAfter();
|
||||
// e.SuppressKeyPress = true;
|
||||
//}
|
||||
|
||||
//else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.C)
|
||||
//{
|
||||
// buttonSetStartTime_Click(null, null);
|
||||
// e.SuppressKeyPress = true;
|
||||
//}
|
||||
//else if (e.Modifiers == Keys.None && e.KeyCode == Keys.B)
|
||||
//{
|
||||
// StopAutoDuration();
|
||||
// buttonSetEnd_Click(null, null);
|
||||
// e.SuppressKeyPress = true;
|
||||
//}
|
||||
else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.U) // Ctrl+Shift+U = switch original/current
|
||||
{
|
||||
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _networkSession == null)
|
||||
{
|
||||
Subtitle temp = _subtitle;
|
||||
_subtitle = _subtitleAlternate;
|
||||
|
@ -528,7 +528,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
CreateAdjustChangesApplied = "Create/adjust lines changes applied",
|
||||
SelectedLines = "selected lines",
|
||||
BeforeDisplayTimeAdjustment = "Before display time adjustment",
|
||||
DisplayTimeAdjustedX = "Display times adjusted: {0}",
|
||||
DisplayTimesAdjustedX = "Display times adjusted: {0}",
|
||||
DisplayTimeAdjustedX = "Display time adjusted: {0}",
|
||||
StarTimeAdjustedX = "Start time adjusted: {0}",
|
||||
BeforeCommonErrorFixes = "Before common error fixes",
|
||||
CommonErrorsFixedInSelectedLines = "Common errors fixed in selected lines",
|
||||
CommonErrorsFixed = "Common errors fixed",
|
||||
@ -728,6 +730,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
Title = "Video",
|
||||
OpenVideo = "Open video file...",
|
||||
CloseVideo = "Close video file",
|
||||
ShowHideVideo = "Show/hide video",
|
||||
ShowHideWaveForm = "Show/hide wave form",
|
||||
UnDockVideoControls = "Un-dock video controls",
|
||||
|
@ -460,6 +460,8 @@
|
||||
public string SelectedLines { get; set; }
|
||||
public string BeforeDisplayTimeAdjustment { get; set; }
|
||||
public string DisplayTimeAdjustedX { get; set; }
|
||||
public string DisplayTimesAdjustedX { get; set; }
|
||||
public string StarTimeAdjustedX { get; set; }
|
||||
public string BeforeCommonErrorFixes { get; set; }
|
||||
public string CommonErrorsFixedInSelectedLines { get; set; }
|
||||
public string CommonErrorsFixed { get; set; }
|
||||
@ -653,6 +655,7 @@
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string OpenVideo { get; set; }
|
||||
public string CloseVideo { get; set; }
|
||||
public string ShowHideVideo { get; set; }
|
||||
public string ShowHideWaveForm { get; set; }
|
||||
public string UnDockVideoControls { get; set; }
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
@ -12,29 +12,38 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
/// </summary>
|
||||
internal class WordSpellChecker
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
||||
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int width, int height, int wFlags);
|
||||
|
||||
private object _wordApplication;
|
||||
private object _wordDocument;
|
||||
private Type _wordApplicationType;
|
||||
private Type _wordDocumentType;
|
||||
bool _firstShow = true;
|
||||
const int HWND_BOTTOM = 1;
|
||||
|
||||
const int SWP_NOACTIVATE = 0x0010;
|
||||
const short SWP_NOMOVE = 0X2;
|
||||
const short SWP_NOSIZE = 1;
|
||||
const short SWP_NOZORDER = 0X4;
|
||||
const int SWP_SHOWWINDOW = 0x0040;
|
||||
|
||||
const int wdWindowStateNormal = 0;
|
||||
const int wdWindowStateMaximize = 1;
|
||||
const int wdWindowStateMinimize = 2;
|
||||
|
||||
private object _wordApplication;
|
||||
private object _wordDocument;
|
||||
private Type _wordApplicationType;
|
||||
private Type _wordDocumentType;
|
||||
IntPtr _mainHandle;
|
||||
|
||||
public WordSpellChecker()
|
||||
public WordSpellChecker(Main main)
|
||||
{
|
||||
_mainHandle = main.Handle;
|
||||
|
||||
_wordApplicationType = System.Type.GetTypeFromProgID("Word.Application");
|
||||
_wordApplication = Activator.CreateInstance(_wordApplicationType);
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateMinimize });
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateMinimize });
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateMinimize });
|
||||
_wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack
|
||||
_wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack
|
||||
|
||||
Application.DoEvents();
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal });
|
||||
_wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -5000 }); // hide window - it's a hack
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
public void NewDocument()
|
||||
@ -90,24 +99,15 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
errorsBefore = int.Parse(spellingErrorsCount.ToString());
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(spellingErrors);
|
||||
|
||||
|
||||
// perform spell check
|
||||
object p = Missing.Value;
|
||||
if (errorsBefore > 0)
|
||||
{
|
||||
if (_firstShow)
|
||||
{
|
||||
BackgroundWorker bw = new BackgroundWorker();
|
||||
bw.WorkerSupportsCancellation = true;
|
||||
bw.DoWork += new DoWorkEventHandler(EnsureWordIsVisible);
|
||||
bw.RunWorkerAsync();
|
||||
_firstShow = false;
|
||||
}
|
||||
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateMinimize });
|
||||
_wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal });
|
||||
_wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack
|
||||
_wordApplicationType.InvokeMember("Visible", BindingFlags.SetProperty, null, _wordApplication, new object[] { true }); // set visible to true - otherwise it will appear in the background
|
||||
SetWindowPos(_mainHandle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // make sure c# form is behind spell check dialog
|
||||
_wordDocumentType.InvokeMember("CheckSpelling", BindingFlags.InvokeMethod, null, _wordDocument, new Object[] { p, p, p, p, p, p, p, p, p, p, p, p }); // 12 parameters
|
||||
SetWindowPos(_mainHandle, 0 , 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // bring c# form to front again
|
||||
_wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack
|
||||
}
|
||||
|
||||
@ -127,18 +127,5 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return resultText.ToString().TrimEnd(); // result needs a trimming at the end
|
||||
}
|
||||
|
||||
void EnsureWordIsVisible(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
int i = 0;
|
||||
while (!e.Cancel && i <10)
|
||||
{
|
||||
Process[] processes = Process.GetProcessesByName("WINWORD");
|
||||
if (processes.Length > 0)
|
||||
SetForegroundWindow(processes[0].MainWindowHandle);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -421,6 +421,7 @@
|
||||
<Video>
|
||||
<Title>Video</Title>
|
||||
<OpenVideo>Åbn video fil...</OpenVideo>
|
||||
<CloseVideo>Luk videofil</CloseVideo>
|
||||
<ShowHideVideo>Vis/skjul video</ShowHideVideo>
|
||||
<ShowHideWaveForm>Vis/skjul lyd kurve</ShowHideWaveForm>
|
||||
<UnDockVideoControls>Pop video vinduer ud</UnDockVideoControls>
|
||||
@ -612,6 +613,8 @@ Vil du starte fra toppen af dokumentet og søge videre?</FindContinue>
|
||||
<SelectedLines>udvalgte linjer</SelectedLines>
|
||||
<BeforeDisplayTimeAdjustment>Før visningstider justering</BeforeDisplayTimeAdjustment>
|
||||
<DisplayTimeAdjustedX>Visningstider justeret: {0}</DisplayTimeAdjustedX>
|
||||
<DisplayTimesAdjustedX>Visningstid justeret: {0}</DisplayTimesAdjustedX>
|
||||
<StarTimeAdjustedX>Start tid justeret: {0}</StarTimeAdjustedX>
|
||||
<BeforeCommonErrorFixes>Før ret almindelige fejl</BeforeCommonErrorFixes>
|
||||
<CommonErrorsFixedInSelectedLines>Almindelige fejl er rettet i valgte linjer</CommonErrorsFixedInSelectedLines>
|
||||
<CommonErrorsFixed>Ret almindelige fejl udført</CommonErrorsFixed>
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user