Tale
08-03-2010, 01:46 AM
I have modded IPlug so that on Windows the keyboard focus is automatically set in PromptUserInput() by sending an EM_SETSEL message to select the text, and then I call SetFocus() to set the focus. However, the selection is almost immediately cancelled again by the WM_TIMER > kUpdate routine in IGraphicsWin::WndProc(), which updates the text of the edit box. So I have changed kUpdate to only update the edit box if the text has actually changed, and now the selection remains.
This mod also fixes updating the combo box, which doesn't respond to WM_SETTEXT but needs CB_SELECTSTRING instead.
Open:
wdl/IPlug/IGraphicsWin.cpp
Find:
SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt);
Replace with:
char currentText[MAX_PARAM_LEN];
SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_PARAM_LEN, (LPARAM) currentText);
if (strcmp(txt, currentText))
{
if (pGraphics->mEdParam->GetNDisplayTexts())
SendMessage(pGraphics->mParamEditWnd, CB_SELECTSTRING, -1, (LPARAM) txt);
else
SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt);
}
Find:
mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE,
cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
}
Replace with:
mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE,
cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
SendMessage(mParamEditWnd, EM_SETSEL, 0, -1);
}
SetFocus(mParamEditWnd);
This mod also fixes updating the combo box, which doesn't respond to WM_SETTEXT but needs CB_SELECTSTRING instead.
Open:
wdl/IPlug/IGraphicsWin.cpp
Find:
SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt);
Replace with:
char currentText[MAX_PARAM_LEN];
SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_PARAM_LEN, (LPARAM) currentText);
if (strcmp(txt, currentText))
{
if (pGraphics->mEdParam->GetNDisplayTexts())
SendMessage(pGraphics->mParamEditWnd, CB_SELECTSTRING, -1, (LPARAM) txt);
else
SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt);
}
Find:
mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE,
cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
}
Replace with:
mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE,
cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
SendMessage(mParamEditWnd, EM_SETSEL, 0, -1);
}
SetFocus(mParamEditWnd);