RichEdit mag keine Tabstopps???



  • Übler Hack...Das geht bestimmt auch vernünftig. wordpad kanns auch mit Tab. Benutzt auch das Rich Edit Control.



  • wie gesagt war auch nur ne blöde idee



  • Evtl. würde es helfen den WS_TABSTOP Flag wenn das Control den Fokus hat zu entfernen 🙄
    Für VB hab ich was gefunden ( http://support.microsoft.com/kb/q143273/ ), aber übertragen auf WinAPI konnte ich es leider nicht 😞



  • Wordpad ist Open Source, allerdings MFC und ein bisschen groß. Aber vielleicht nützt es ja trotzdem was:

    http://download.microsoft.com/download/VisualStudioNET/Sample/7.0/NT5XP/EN-US/mfc_ole_wordpad.exe



  • flenders schrieb:

    Evtl. würde es helfen den WS_TABSTOP Flag wenn das Control den Fokus hat zu entfernen 🙄
    Für VB hab ich was gefunden ( http://support.microsoft.com/kb/q143273/ ), aber übertragen auf WinAPI konnte ich es leider nicht 😞

    Hmm wieso WS_TABSTOP? Das habe ich ja für mein hEdit gar nicht gesetzt... 🙄 😕

    Es MUSS doch eine Lösung geben! Zur Not versuch ich mal die Idee von miller_m ... auch wenn's nicht grad das beste ist...

    gruss,
    code_pilot



  • Habe mir gerade nochmal das Beispiel für VB angeschaut und demnach sollte es funktionieren, indem du entweder bei keinem Control WS_TABSTOP setzt, oder eben immer wenn das Richedit den Fokus bekommt, du bei allen das Flag entfernst (im Beispiel wir dann zwischengespeichert, ob es gesetzt war) - wenn das Richedit den Fokus wieder verliert ggf. entsprechend das Flag wieder setzen.



  • Werte doch einfach EN_MSGFILTER aus... 😕



  • Hi!

    So habe jetzt ein wenig rumgetüftelt, und es bis jetzt so hingekriegt:

    case WM_NOTIFY:
    {
    		NMHDR* pnmhdr = reinterpret_cast<NMHDR*>(lParam);
    
    		switch(pnmhdr->code)
    		{
    				case EN_MSGFILTER:
    				{
    						MSGFILTER* pFilter = reinterpret_cast<MSGFILTER*>(lParam);
    
    						if(pFilter->msg == WM_KEYUP)
    						{
    								if(pFilter->wParam == VK_TAB) //&& !(pFilter->lParam & VK_CONTROL))
    								{									
    										keybd_event( VK_CONTROL, 0, 0, 0);
    										keybd_event( VK_TAB, 0, 0, 0);
    										keybd_event( VK_TAB, 0, KEYEVENTF_KEYUP, 0);
    										keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
    								}
    						}
    				}
    		}
    }
    

    Leider funktioniert das aber auch nicht so wirklich, weil sich ja die WndProc immer rekusriv aufruft, wenn ich da mit keybd_event() ein STRG+TAB synchronisiere. Ich hab dann in der MSDN gelesen das an das lParam der MSGFILTER-Struktur zusätzliche Informationen übergeben werden.

    lParam
    Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.

    0-15
    Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. The repeat count is always one for a WM_KEYUP message.
    16-23
    Specifies the scan code. The value depends on the OEM.
    24
    Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
    25-28
    Reserved; do not use.
    29
    Specifies the context code. The value is always 0 for a WM_KEYUP message.
    30
    Specifies the previous key state. The value is always 1 for a WM_KEYUP message.
    31
    Specifies the transition state. The value is always 1 for a WM_KEYUP message.

    D.h. wie man ja sieht auch ob STRG gedrückt ist. Wie aber kann ich das nun abbprüfen??? Ich habs mal mit

    if(pFilter->wParam == VK_TAB) && !(pFilter->lParam & VK_CONTROL))
    

    und

    if(pFilter->wParam == VK_TAB && !(pFilter->lParam >> 24))
    

    ausprobiert aber das ist wohl so nicht richtig... wie kriege ich denn raus ,ob Strg gedrückt wird???

    Danke & Gruss,
    ~code_pilot 🙄 :p



  • Versuch das mal mit GetAsyncKeyState (bin mir grad nicht sicher, aber in einem Keyboard-Hook hab ich das mal erfolgreich probiert)...

    Also so in etwa:

    #define KEYDOWN(vk_code)  ((GetAsyncKeyState(vk_code) & 0x80000000)? 1 : 0)
    
    // dann fragste das so ab:
    if(KEYDOWN(VK_CONTROL))
    {
    // Strg gedrückt!
    // ...
    }
    


  • Hi Hepi!

    Dein Snippet klappt leider auch nicht aber was solls 😉 hab jetzt selbst eine Lösung gefunden (ist zwar auch nicht DIE Patentlösung, aber es klappt ;)):

    if(pFilter->wParam == VK_TAB) // && !((*pFilter).lParam & (1 << 24)))
    {
    		SendMessage(hEdit, EM_REPLACESEL, (WPARAM)false, (LPARAM)"\t"); 
    }
    

    Danke für Eure Hilfe 🙂 👍

    ~code_pilot


Anmelden zum Antworten