DM_SETEDITPOSITION

Far Manager

DM_SETEDITPOSITION

The DM_SETEDITPOSITION message is sent to the dialog manager to set the cursor position and state in edit controls.

Param1

Dialog item ID

Param2

Pointer to a EditorSetPosition structure.

Return

FALSE - the given dialog item ID is not an edit control.
TRUE - cursor position is set.

Controls

ControlDescription
DI_COMBOBOX combined list
DI_EDIT edit line
DI_FIXEDIT fixed size input field
DI_PSWEDIT password input field

Remarks

Example

Example of a mouse selection support function for edit controls from the "Visual renaming files" plugin
static void MouseSelect(HANDLE hDlg, DWORD idStr, DWORD dwMousePosX)
{
  SMALL_RECT dlgRect, itemRect;
  Info.SendDlgMessage(hDlg, DM_GETDLGRECT, 0, (LONG_PTR)&dlgRect);
  Info.SendDlgMessage(hDlg, DM_GETITEMPOSITION, idStr, (LONG_PTR)&itemRect);

  EditorSetPosition esp;
  Info.SendDlgMessage(hDlg, DM_GETEDITPOSITION, idStr, (LONG_PTR)&esp);

  int length=Info.SendDlgMessage(hDlg, DM_GETTEXTLENGTH, idStr, 0);
  int CurPos=dwMousePosX - ( dlgRect.Left + itemRect.Left );

  if ( dwMousePosX <= ( dlgRect.Left + itemRect.Left ) && esp.LeftPos > 0 )
    esp.LeftPos-=1;
  else if ( dwMousePosX >= ( dlgRect.Left + itemRect.Right ) && CurPos+esp.LeftPos < length )
    esp.LeftPos+=1;

  if (CurPos+esp.LeftPos < 0)
    CurPos=0;
  else if (CurPos+esp.LeftPos > length)
    CurPos=length;
  else
    CurPos+=esp.LeftPos;

  esp.CurPos=esp.CurTabPos=CurPos;

  if (bStartSelect)
  {
    StartPosX=CurPos;
    bStartSelect=false;
  }

  EditorSelect es;
  es.BlockType=BTYPE_COLUMN;
  es.BlockStartLine=es.BlockHeight=0;

  if (CurPos > StartPosX)
  {
    es.BlockStartPos=StartPosX;
    es.BlockWidth=CurPos-StartPosX;
  }
  else
  {
    es.BlockStartPos=CurPos;
    es.BlockWidth=StartPosX-CurPos;
  }

  Info.SendDlgMessage(hDlg, DM_SETSELECTION, idStr, (LONG_PTR)&es);
  Info.SendDlgMessage(hDlg, DM_SETEDITPOSITION, idStr, (LONG_PTR)&esp);
}
See also: