Den Textcursor in ein bestimmtes RichEditControl setzen.



  • hab ich mir auch schon so gedacht, aber funzt nicht. ich rufe das von nem anderen tread aus und das control ist gesubclasst. weiss nicht ob das damit zu tun hat.


  • Mod

    focus n00b schrieb:

    hab ich mir auch schon so gedacht, aber funzt nicht. ich rufe das von nem anderen tread aus und das control ist gesubclasst. weiss nicht ob das damit zu tun hat.

    Aber sicher hat das damit zu tun. Die Informationen wie aktives Fenster, Focus usw. sind threadbezogene Daten. Du kannst nicht für einen anderen Thread den Focu setzen. Dies geht nur wenn Du die Input-Queues zusammenführst über AttachThreadInput.

    http://msdn.microsoft.com/en-us/library/ms681956(VS.85).aspx

    Lesen bildet! 🕶

    By using the AttachThreadInput function, a thread can attach its input processing to another thread. This also allows threads to share their input states, so they can call the SetFocus function to set the keyboard focus to a window of a different thread. This also allows threads to get key-state information. These capabilities are not generally possible.



  • da steht aber auch:

    ...The AttachThreadInput function fails if either of the specified threads does not have a message queue.

    kann ich wohl vergessen, der hat keine eigene kju.


  • Mod

    focus n00b schrieb:

    da steht aber auch:

    ...The AttachThreadInput function fails if either of the specified threads does not have a message queue.

    kann ich wohl vergessen, der hat keine eigene kju.

    Hmmm... Dennoch ist das der einzige Weg. Versuch es doch mal.



  • Dann ruf doch einmal PeekMessage auf dann müsste eine Message-Queue erstellt werden.



  • Martin Richter schrieb:

    Aber sicher hat das damit zu tun. Die Informationen wie aktives Fenster, Focus usw. sind threadbezogene Daten. Du kannst nicht für einen anderen Thread den Focu setzen. Dies geht nur wenn Du die Input-Queues zusammenführst über AttachThreadInput.

    http://msdn.microsoft.com/en-us/library/ms681956(VS.85).aspx

    Lesen bildet! 🕶

    By using the AttachThreadInput function, a thread can attach its input processing to another thread. This also allows threads to share their input states, so they can call the SetFocus function to set the keyboard focus to a window of a different thread. This also allows threads to get key-state information. These capabilities are not generally possible.

    jetzt kapier ich auch, warum ein EM_LIMITTEXT nicht funzt, aber ein EM_STREAMOUT dagegen klappt. hmmm... da muss ich nochmal gucken, wie ich das mach, wa.
    komisch, das es da keine fehlermeldungen für gibt.



  • ok, habs jetzt auf die weichei-tour gemacht: ich sende an die zum control gehörige wndproc user-defined messages. funzt auch.
    🙂



  • Hallo,
    ich wollte das mit dem AttachThreadInput mal testen, aber ich bekomme false zurück:

    PeekMessage (&msg,hWnd,WM_KEYFIRST,WM_KEYLAST,0);
    	ret = AttachThreadInput (GetCurrentThreadId(),GetWindowThreadProcessId(hWnd,NULL),1);
    	if ( ret==false )
    		MessageBox(NULL, _T("AttachThreadInput failed."), _T(""), MB_OK );
    

    Nochmal kurz worum es geht:
    AttachThreadInput wird in einem Thread aufgerufen, der in WinMain erzeugt wurde.
    Von dem Thread aus möchte ich den auf Focus in ein RichEditControl setzen.



  • nagut,jetzt wird true zurückgegeben, das hWnd war nicht gesetzt. bloss jetzt reagiert das haupfenster nicht mehr. lässt sich nicht bewegen und nicht schließen!



  • mach dir das leben nicht so schwer, nimm SendMessage.


Anmelden zum Antworten