Problem mit ListViewControl Sortier-Anleitung aus der FAQ



  • Hallo,
    ich möchte folgendes aus der FAQ in mein Programm einbauen:
    http://www.codeguru.com/listview/sort_on_col_click.shtml

    Allerdings verstehe ich nicht, was ich hier tun soll:

    Step 3: Add entry in message map to handle HDN_ITEMCLICK
    Actually you need to add two entries. For HDN_ITEMCLICKA and HDN_ITEMCLICKW. Do not use the class wizard to add the entry. For one, you need to add two entries whereas the class wizard will allow you only one. Secondly, the class wizard uses the wrong macro in the entry. It uses ON_NOTIFY_REFLECT() instead of ON_NOTIFY(). Since the HDN_ITEMCLICK is a notification from the header control to the list view control, it is a direct notification and not a reflected one.
    ON_NOTIFY(HDN_ITEMCLICKA, 0, OnHeaderClicked)
    ON_NOTIFY(HDN_ITEMCLICKW, 0, OnHeaderClicked)
    Note that we specify the same function for both the notification. Actually the program will receive one or the other and not both. What notification it receives will depend on the OS. The list view control on Windows 95 will send the ANSI version and the control on NT will send the UNICODE version.
    Also, note that the second argument is zero. This value filters for the id of the control and we know that header control id is zero.

    Kann mir da evtl. jemand helfen??!

    Vielen Dank im Vorraus,
    Gruß Christian



  • Hapert es am Englisch oder am Quelltext?



  • eher am englisch, quelltext ist es ja net viel!



  • Muß mich korrigieren, irgendwie an beidem 😕 🙄



  • Step 3: Add entry in message map to handle HDN_ITEMCLICK

    Schritt 3: Mach einen Eintrag für HDN_ITEMCLICK in die MessageMap.

    Actually you need to add two entries. For HDN_ITEMCLICKA and HDN_ITEMCLICKW.

    Du musst allerdings 2 Einträge machen: Einen für HDN_ITEMCLICKA und einen für HDN_ITEMCLICKW.

    Do not use the class wizard to add the entry.

    Nimm aber nicht den Klassenassistenten.

    For one, you need to add two entries whereas the class wizard will allow you only one.

    Erstens: Du musst zwei Einträge machen, der Assisten würde nur einen zulassen.

    Secondly, the class wizard uses the wrong macro in the entry. It uses ON_NOTIFY_REFLECT() instead of ON_NOTIFY().

    Zweitens: Der Assistent nimmt das falsche Makro. Er nimmt ON_NOTIFY_REFLECT() statt ON_NOTIFY().

    Since the HDN_ITEMCLICK is a notification from the header control to the list view control, it is a direct notification and not a reflected one.

    Da HDN_ITEMCLICK eine Nachricht des Headercontrols an das Listcontrol ist, ist es eine direkte Nachricht und keine reflektierte. (Sorry, Fachbegriff, ich kenne es nur auf Englisch.)

    ON_NOTIFY(HDN_ITEMCLICKA, 0, OnHeaderClicked)
    ON_NOTIFY(HDN_ITEMCLICKW, 0, OnHeaderClicked)

    Das ist der Quelltext den du schreiben sollst.

    Note that we specify the same function for both the notification.

    Beachte, dass ein und dieselbe Funktion beide Nachrichten behandelt.

    Actually the program will receive one or the other and not both. What notification it receives will depend on the OS.

    Das Programm wird immer entweder die eine oder die andere Nachricht erhalten. Welche das ist, hängt vom Betriebssystem ab.

    The list view control on Windows 95 will send the ANSI version and the control on NT will send the UNICODE version.

    In Windows 95 wird es die ANSI-Version sein (A am Namensende) und bei NT die UNICODE-Version (W am Ende).

    Also, note that the second argument is zero. This value filters for the id of the control and we know that header control id is zero.

    Beachte ausserdem, dass der zweite Parameter 0 ist. Dieser Wert filtert nach der ID des Controls und wir wissen ja, dass die ID des Headercontrols 0 ist.

    Uff, ich hoffe ich habe alles richtig übersetzt. UMsetzen kann ich es, aber ÜBERsetzen ist schwieriger.



  • Vielen Dank, aber was ist denn die Message Map?? Behandlungsroutine für Windows-Nachrichten?? Dort finde ich aber kein HDN_ITEMCLICKA oder HDN_ITEMCLICKB! 😕 😕 😕



  • Eine MessageMap ist das, wo MessageMap dransteht 😃

    BEGIN_MESSAGE_MAP(CResourcenApp, CWinApp)
    	//{{AFX_MSG_MAP(CResourcenApp)
    		// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingefügt und entfernt.
    		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VERÄNDERN!
    	//}}AFX_MSG
    	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
    END_MESSAGE_MAP()
    

    Das ist aus meiner Anwendung, also können ein paar Sachen bei dir anders aussehen.

    Aber bleiben wir bei dem Beispiel:
    So soll es hinterher aussehen:

    BEGIN_MESSAGE_MAP(CResourcenApp, CWinApp)
    	//{{AFX_MSG_MAP(CResourcenApp)
    		// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingefügt und entfernt.
    		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VERÄNDERN!
    	//}}AFX_MSG
        ON_NOTIFY(HDN_ITEMCLICKA, 0, OnHeaderClicked) 
        ON_NOTIFY(HDN_ITEMCLICKW, 0, OnHeaderClicked) 
    	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
    END_MESSAGE_MAP()
    

    Vorsicht, nicht getestet. Guck also zur Not nochmal ins Beispielprojekt, wenn es nicht funktioniert. Da gab es so viel zu beachten, was ich jetzt grade nicht mehr weiß.

    Dort finde ich aber kein HDN_ITEMCLICKA oder HDN_ITEMCLICKB!

    Natürlich nicht. Du sollst das da ja hinschreiben, dann findest du es auch. 🙄
    (Ist nicht bös gemeint, fand ich blos selbstverständlich und hatte ich ja auch geschrieben. Na egal.)

    Jetzt verstanden? 🙂



  • Ach so!! Jetzt hab ichs kapiert!!!

    Viele Dank,
    Grüße Christian



  • Ich habe jetzt versucht, wie folgt einen Sortieralgorithmus zu implementieren:
    http://www.codeguru.com/listview/sort_generic_callback1.shtml

    Allerdings verstehe ich nicht, was ich anstatt

    csc.Sort(bSortAscending, (CSortClass::EDataType) 
    			m_arrColType[nSortedCol]);
    

    schreiben soll. In dem einen Comment von Maxim Poliashenko steht ja, dass man m_arrColType weglassen kann, aber dann funktoniert leider nix! hat da jemand ne Idee oder den Algo schonmal verwendet??!



  • Habs rausgefunden, einfach ne -1!


Anmelden zum Antworten