Skip to content

Commit

Permalink
more friendly error message and behavior
Browse files Browse the repository at this point in the history
Close #2.
  • Loading branch information
oov committed Feb 17, 2016
1 parent 4fdc923 commit c61b039
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ implementation
const
PluginName = 'ごちゃまぜドロップス';
PluginNameANSI = #$82#$b2#$82#$bf#$82#$e1#$82#$dc#$82#$ba#$83#$68#$83#$8d#$83#$62#$83#$76#$83#$58;
PluginInfoANSI = PluginNameANSI + ' v0.1.2';
PluginInfoANSI = PluginNameANSI + ' v0.1.3';
ExEditNameANSI = #$8a#$67#$92#$a3#$95#$d2#$8f#$57; // '拡張編集'

var
Expand Down Expand Up @@ -94,7 +94,7 @@ function FilterProjectSave(Filter: PFilter; Edit: Pointer; Data: Pointer;
function TPlugin.MainProc(Window: HWND; Message: UINT; WP: WPARAM;
LP: LPARAM; Edit: Pointer; Filter: PFilter): integer;
var
Handle: THandle;
Label1, Label2: THandle;
Y, Height: integer;
NCM: TNonClientMetrics;
DC: THandle;
Expand All @@ -118,10 +118,10 @@ function TPlugin.MainProc(Window: HWND; Message: UINT; WP: WPARAM;
Y := 8;

Height := FFontHeight;
Handle := CreateWindowW('STATIC', PWideChar('処理モード:'),
Label1 := CreateWindowW('STATIC', PWideChar('処理モード:'),
WS_CHILD or WS_VISIBLE or ES_LEFT, 8, Y, 400, Height,
Window, 0, Filter^.DLLHInst, nil);
SendMessageW(Handle, WM_SETFONT, WPARAM(FFont), 0);
SendMessageW(Label1, WM_SETFONT, WPARAM(FFont), 0);
Inc(Y, Height);

Height := FFontHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2;
Expand All @@ -137,10 +137,10 @@ function TPlugin.MainProc(Window: HWND; Message: UINT; WP: WPARAM;
Inc(Y, 8);

Height := FFontHeight;
Handle := CreateWindowW('STATIC', PWideChar('データ保存先:'),
Label2 := CreateWindowW('STATIC', PWideChar('データ保存先:'),
WS_CHILD or WS_VISIBLE or ES_LEFT, 8, Y, 400, Height,
Window, 2, Filter^.DLLHInst, nil);
SendMessageW(Handle, WM_SETFONT, WPARAM(FFont), 0);
SendMessageW(Label2, WM_SETFONT, WPARAM(FFont), 0);
Inc(Y, Height);

Height := FFontHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2;
Expand Down Expand Up @@ -170,8 +170,20 @@ function TPlugin.MainProc(Window: HWND; Message: UINT; WP: WPARAM;
OleCheck(RegisterDragDrop(FExEditHWND, Self));
except
on E: Exception do
MessageBoxW(FExEditHWND, PWideChar(WideString(E.Message)),
PWideChar('エラー - ' + PluginName), MB_ICONERROR);
begin
EnableWindow(Label1, False);
EnableWindow(FModeHWND, False);
EnableWindow(Label2, False);
EnableWindow(FEditHWND, False);
EnableWindow(FButtonHWND, False);
SetWindowTextW(Window,
PWideChar(WideString(PluginName + ' - 初期化に失敗したため使用できません')));
MessageBoxW(FExEditHWND,
PWideChar(WideString(E.Message) + #13#10'なお、' +
PluginName + ' は「字幕アシスト」と同時に使用することはできません。'#13#10 +
'もし同時に使用していてこのメッセージが表示されている場合は、どちらかのプラグインを読み込まないようにしてください。'),
PWideChar('初期化エラー - ' + PluginName), MB_ICONERROR);
end;
end;
end
else
Expand Down

0 comments on commit c61b039

Please sign in to comment.