Eidt Control Selection/ enter text (MFC)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Eidt Control Selection/ enter text (MFC)

  1. #1
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    198

    Eidt Control Selection/ enter text (MFC)

    hello,

    the situaton;
    My progam, call it A.exe, starts another program, call it B.exe.
    At a certain stage program A fills several edit controls with text strings.
    (Belonging to program B, B.exe)
    these are Name, Last-name, address, City.
    (Using keybd_event or Sendinput, both work fine)
    everything woks fine if the user does not interfear.
    as soon as the user set the tab-caret on let say the address line, the text
    string sending sequence is wrong, (name will be places in the address line, address in the
    city line etc. and also the Next and Back button control get input, resulting in strange
    behaviuor.

    I can find all the Control IDs using,
    pWndx->GetDlgCtrlID(); (where x is between 1 and the amount of CtrlIDs)

    I can even find and change the text of the buttons using
    pWnd->GetDlgItemText(1, text);
    pWnd->SetDlgItemText(1, text);

    I can move the TAB-caret around using;
    keybd_event
    sendinput
    pWnd->SendMessage(WM_NEXTDLGCTL,0,0);

    What I want is to set the TAB-caret at a certain place, Yes the name line.
    or
    If there is a test to check where the TAB-caret is that would be fine aswell.
    So I can move it before sending the text strings.

    So WM_NEXTDLGCTL is useless if you do not know where the caret is, I dont think
    microsoft overlooked something, so where do I go wrong...

    other options, how do I edit the edit-control class directly, using Spy++ I found out
    there is a handle to the control, so it should be possible to put the text string in the
    structure directly

    regards,

    Ger

  2. #2
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    198

    Re: Eidt Control Selection/ enter text (MFC)

    ..... anybody......

  3. #3
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Eidt Control Selection/ enter text (MFC)

    You can find out if your control has a keyboard focus by calling the GetFocus() API and compare it with the control's HWND handle. Your problem though is that you're trying to do this between two separate processes. I'm venturing to say that you're running your code on Windows XP or even earlier OS. The approach of using keybd_event() and SendInput() has been significantly redesigned in Windows Vista and Windows 7 that may make such incorrect interprocess communication obsolete. So my suggestion to you is to re-design your ways of doing this (i.e. put all your controls into the same process), or use other means of the IPC.

  4. #4
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    198

    Re: Eidt Control Selection/ enter text (MFC)

    Hello Ahmd,

    Thanks for the reply!!

    I'm working with studio 9.0 on a windows 7 OS.
    putting the processes in one is not an option.
    the getfocus and setfocus calls do not work on another process.
    Also the setwindowtext() and setdlgitemtext() do not work on another proces.
    (Funny thing, I can change the text from a control button "Next >", to for instance to" TEST".....)

    Although Accessible Explorer (MFC Application) part of the SDK 2.0 gives me all the info.

    Now the question how to access/change the data, of the edit-control.

    Regards,

    Ger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center