Autor Beitrag
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Mo 08.06.09 02:06 
Hi,
da ich kaum gescheite Dokumentation finde (nur MSDN mit den reinen Befehlen/Messages und .Net/C#), versuche ichs mal hier. vielleicht kann mir auch jemand eine Doku empfehlen (außer google, da hab ich heute schon stundenlang gesucht) oder ein gut frequentiertes Form zu dem Thema.

diesmal geht es mir darum den Text des markierten Knotens in einem Treeview zu bekommen. klingt einfach, ists aber scheinbar nicht. eine funktion/message mit gettext o.ä. gibt es scheinbar nicht. und ich hab auch noch kein Beispiel gefunden, wo dieses angewandt wird (zumindest nicht mit reiner Win32Api).

ich hoffe mir kann da jemand helfen

Gruß Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 08.06.09 07:59 
Hallo,

in dem Win32API_Tutorial von user profile iconLuckie findest Du vermutlich die gewünschten Informationen(TVN_SELCHANGING, TVN_SELCHANGED, TreeView_GetItem() etc.).
Ab Seite 128 wird das TreeView behandelt.
Michael Puff - Index of /Developer/Delphi/Tutorials/

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
_frank_ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Mo 08.06.09 11:48 
Hi,
stimmt an luckies Api-Tutorial hab ich gar nicht mehr gedacht. ich hab mal versucht das damit und google zu realisieren, jedoch wird weder das NM_Click noch TVN_SELCHANGED getriggert...

ich habe mal die gesamte Nachtrichten-Weitergabe in den Codebereich kopiert. Das WM_LBUTTONDBLCLK funktioniert ohne Probleme.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
LRESULT CALLBACK TreeviewWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
  MyTreeview *TV=(MyTreeview *)GetWindowLong(hwnd,GWL_USERDATA);
  return TV->MyWndProc(hwnd, message, wparam, lparam);
}


MyTreeview::MyTreeview(HINSTANCE hInstance, HWND hwndParent)  //constructor
{
...
    SetWindowLong(this->hwnd,GWL_USERDATA,(int)this);
    wndProcOrig=(WNDPROC)SetWindowLong(this->hwnd,GWL_WNDPROC,(int)TreeviewWndProc);
}

LRESULT MyTreeview::MyWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
  // char c[10];
  // sprintf(c,"%d",message);
  // OutputDebugString(c);
  switch(message)
  {
    case WM_LBUTTONDBLCLK:{DoDblClick();};break;
    case WM_NOTIFY:
    {
    /*
      //LPNM_TREEVIEW lpn = (LPNM_TREEVIEW)lparam;   

      switch(((LPNMHDR)lparam)->code)
      {
        case NM_CLICK:
        {MessageBox(hwnd,"NM_Click","Test",0);};break;
        case NM_DBLCLK:
        {DoDblClick();};break;
        // case NM_RCLICK:
        // {};break;
      }*/
      NM_TREEVIEW *pNm;
      pNm=(NM_TREEVIEW *) lparam;
      switch (pNm->hdr.code)
      {
        case NM_CLICK:
          MessageBox(hwnd,"This is Tree control click","something",MB_OK);
        break; 
        case TVN_SELCHANGED:
          char text[128]; // this is the buffer
          pNm->itemNew.mask |= TVIF_TEXT;
          pNm->itemNew.pszText = text;
          TreeView_GetItem( pNm->hdr.hwndFrom, &pNm->itemNew );
          MessageBox(hwnd,text,NULL,MB_OK);
        break;
      }
    };break;
  }
  return CallWindowProc( wndProcOrig, hwnd, message, wparam,lparam); 
}


ich hoffe jemand findet den Fehler.

Gruß Grank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
_frank_ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Di 09.06.09 01:39 
mit Hilfe von einem bekannten habe ich die Lösung gefunden:

MSDN hat folgendes geschrieben:
WM_NOTIFY Message
Sent by a common control to its parent window when an event has occurred or the control requires some information.


ich musste WM_NOTIFY also in meiner WNDProc des Hauptfensters abfangen und an das Treeview weiterleiten:

ausblenden Quelltext
1:
2:
3:
4:
  case WM_NOTIFY:
  {
    SendMessage(((LPNMHDR)lparam)->hwndFrom,WM_NOTIFY,wparam,lparam);
  };break;


Gruß Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3