Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
解决参数输入窗口会失去焦点的问题(非完美方案).
Browse files Browse the repository at this point in the history
  • Loading branch information
chenall committed Feb 14, 2015
1 parent 6d458f3 commit d3a04ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Dialog/DlgParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
BEGIN_EVENT_TABLE(DlgParam, wxDialog)
EVT_BUTTON(wxID_OK, DlgParam::OnOKClick)
EVT_SHOW(DlgParam::OnShow)
// EVT_ACTIVATE(DlgParam::OnActivate)
END_EVENT_TABLE()

#ifndef _DISABLE_DND_
Expand Down Expand Up @@ -63,6 +64,7 @@ DlgParam::DlgParam( wxWindow* parent, wxWindowID id, const wxString& title, cons
comboBox->SetSelection(0);
comboBox->Bind(wxEVT_KEY_DOWN,&DlgParam::OnKey,this);
comboBox->SetToolTip("提示: \n1.选中一个历史记录按Alt+Delete可以删除.\n2.按[Alt+F]可以插入一个文件路径.\n3.按[Alt+D]可以插入一个文件夹路径");

bSizer2->Add(comboBox, 0, wxALL, 5 );

wxButton* ButtonOk = new wxButton(this,wxID_OK,"确定(&O)",wxDefaultPosition,wxDefaultSize);
Expand Down Expand Up @@ -143,9 +145,9 @@ void DlgParam::OnShow(wxShowEvent& e)
if (e.IsShown())
{
#ifdef __WXMSW__
::SetWindowPos(this->GetHWND(),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
ActiveWindow(this->GetHWND());
#endif
this->SetFocus();
comboBox->SetFocus();
comboBox->SetFocusFromKbd();
}
e.Skip();
Expand Down
2 changes: 2 additions & 0 deletions src/Dialog/DlgParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class DlgParam : public wxDialog
void OnOKClick(wxCommandEvent& e);
//void OnCancelClick(wxCommandEvent& e);
void OnShow(wxShowEvent& e);
//void OnFocus(wxFocusEvent& e);
//void OnActivate(wxActivateEvent& e);
void SetValue(const wxString& str);
wxString getvalue();
};
Expand Down
6 changes: 6 additions & 0 deletions src/MerryCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "MerryCommand.h"
#include "MerryCommandManager.h"
#include "MerryLua.h"
#include "MerryApp.h"
#include "MerryInformationDialog.h"
#include "DlgParam.h"
#include "ALMRunConfig.h"
Expand Down Expand Up @@ -188,11 +189,13 @@ void MerryCommand::Execute(const wxString& commandArg) const
lua_State* L = g_lua->GetLua();
wxString cmdArg = commandArg;
assert(L);

#ifdef __WXMSW__
if (PID > 1)//禁止多个进程
{
if (CheckActiveProg(PID))
{//已经运行,查找前激活之前的窗口
::wxGetApp().GetFrame().Hide();
return;
}
}
Expand All @@ -209,6 +212,9 @@ void MerryCommand::Execute(const wxString& commandArg) const
return;
}

if (m_commandFunc != g_lua->get_funcref(LUA_toggleMerry))
::wxGetApp().GetFrame().Hide();

if (m_commandFunc == 0)
{
if (!g_lua->get_func(LUA_CMDRun_FUNC))
Expand Down
2 changes: 0 additions & 2 deletions src/MerryTextCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ void MerryTextCtrl::ExecuteCmd()
#endif
if (g_config->get(RememberFavouratMatch))
g_config->SetFavorite((this->EnterArgs > 0)?key.Left(this->EnterArgs - 2):key,command->GetCommandName());

::wxGetApp().GetFrame().Hide();
command->Execute(commandArg);
}

Expand Down

0 comments on commit d3a04ef

Please sign in to comment.