string aus SendMessageW - Funktion erhalten

Übersicht BlitzMax, BlitzMax NG Allgemein

Neue Antwort erstellen

 

danielos

Betreff: string aus SendMessageW - Funktion erhalten

BeitragMi, Jan 21, 2009 10:34
Antworten mit Zitat
Benutzer-Profile anzeigen
Moin zusammen,

ich hab mal wieder ein kleines Problem. Ich schaffe es einfach nicht, dass die SendMessage - Windowsfunktion die Namen von bestimmten Columns einer Listbox zurückliefert.
Ich glaube nicht, dass ich viel falsch mache, aber bisher wurde immer 0 oder gar nichts zurückgeliefert.
Ich hab hier mal den Code:

Code: [AUSKLAPPEN]


Import maxgui.drivers
SuperStrict

Local window:TGadget = CreateWindow("Listbox" , 0 , 0 , 800 , 600 , Null , WINDOW_CENTER | 15)

Local listbox:TGadget = CreateListBox(10 , 10 , 500 , 500 , window)


Global listboxHwnd:Int = QueryGadget(listbox,QUERY_HWND)
Global ListBoxstyle:Int = LVS_REPORT | LVS_EDITLABELS

SetHeading(0 , "Spalte 3" , 100)
SetHeading(0 , "Spalte 2" , 100 , LVM_INSERTCOLUMNW)
SetHeading(0 , "Spalte 1" , 100 , LVM_INSERTCOLUMNW)





'Ein Integer Array mit 3 Einträgen wird erstellt und die Adresse
'an die Funktion übergeben. Die WinAPI schreibt die Information dort rein


Global buf:Int[3]




Repeat
   If WaitEvent() = EVENT_WINDOWCLOSE End
   OnEnd(PrintResults) 'Funktion, die Columnreihenfolge und Namen anzeigen soll
Forever


Function PrintResults()
   
   SendMessageW(listboxHwnd , LVM_GETCOLUMNORDERARRAY , buf.length , Int(Varptr(buf[0]) ) ) 'Reihenfolge der Columns
   For Local i:Int = 0 Until buf.length
   Local col:LVCOLUMNW = New LVCOLUMNW
   
   col.mask = LVCF_TEXT
     Print "ID: " + buf[i]
     SendMessageW(listboxHwnd , LVM_GETCOLUMNW, buf[i] , Int(Byte Ptr Col) ) 'Strings der Columns
     Print "String:" + String.fromWString(col.pszText)
   Next
EndFunction


Function SetHeading(column:Int, heading$, width:Int, action:Int = LVM_SETCOLUMNW)
   
      Local col:LVCOLUMNW = New LVCOLUMNW
      Local columnHeading:TColumnHeading[1]   
      columnHeading[column] = New TColumnHeading
      columnHeading[column].width = width
     
      If columnHeading[Column].width = 0 Then
         Col.mask = LVCF_TEXT| LVCF_FMT
      Else
         Col.mask = LVCF_TEXT| LVCF_FMT | LVCF_WIDTH
         col.cx   = columnHeading[Column].width
      End If
     
      col.pszText = heading$.ToWString()
     
      Local ListBoxstyle:Int = GetWindowLongW(ListboxHwnd , GWL_STYLE)

     
      If (ListBoxstyle &  LVS_NOCOLUMNHEADER ) Then
         ListBoxstyle  = ListBoxstyle  ~LVS_NOCOLUMNHEADER
         If ListBoxstyle & LVS_EDITLABELS = 0 Then ListBoxstyle = ListBoxstyle | LVS_REPORT
         SetWindowLongW(ListboxHwnd , GWL_STYLE , ListBoxstyle) 'Headings aktivieren
         
         SendMessageW(listboxhwnd , LVM_SETEXTENDEDLISTVIEWSTYLE , 0 , LVS_EX_HEADERDRAGDROP   )  ' Zum verschieben von Columns
         
      End If
     
      SendMessageW(ListboxHwnd, action, Column, Int(Byte Ptr Col))
     

End Function


Type TColumnHeading
   Field width:Int
   Field sortDir:Int = 1
EndType



Der entsprechende Beitrag bei MSDN ist hier:
http://msdn.microsoft.com/de-de/library/bb774911(en-us,VS.85).aspx

Ich bitte um Hilfe, das wäre großartig Wink

MfG

Danielos

Suco-X

Betreff: .....

BeitragMi, Jan 21, 2009 12:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo danielos.
Da du schon so lange dran rumtestest will ich mal nicht so sein.

Code: [AUSKLAPPEN]

Import maxgui.drivers
SuperStrict

Local window:TGadget = CreateWindow("Listbox" , 0 , 0 , 800 , 600 , Null , WINDOW_CENTER | 15)

Local listbox:TGadget = CreateListBox(10 , 10 , 500 , 500 , window)


Global listboxHwnd:Int = QueryGadget(listbox,QUERY_HWND)
Global ListBoxstyle:Int = LVS_REPORT | LVS_EDITLABELS

SetHeading(0 , "Spalte 3" , 100)
SetHeading(0 , "Spalte 2" , 100 , LVM_INSERTCOLUMNW)
SetHeading(0 , "Spalte 1" , 100 , LVM_INSERTCOLUMNW)



'Ein Integer Array mit 3 Einträgen wird erstellt und die Adresse
'an die Funktion übergeben. Die WinAPI schreibt die Information dort rein


Global buf:Int[3]

PrintResults()


Repeat
   If WaitEvent() = EVENT_WINDOWCLOSE End
   OnEnd(PrintResults) 'Funktion, die Columnreihenfolge und Namen anzeigen soll
Forever


Function PrintResults()
   
   SendMessageW(listboxHwnd , LVM_GETCOLUMNORDERARRAY , buf.length , Int(Varptr(buf[0]) ) ) 'Reihenfolge der Columns
   For Local i:Int = 0 Until buf.length
   Local col:LVCOLUMNW = New LVCOLUMNW
   
     col.mask = LVCF_TEXT
   col.pszText    = New Short[1024]
   col.cchTextMax = 1024
     Print "ID: " + buf[i]
     SendMessageW(listboxHwnd , LVM_GETCOLUMNW, buf[i] , Int(Byte Ptr Col) ) 'Strings der Columns
     Print "String:" + String.fromWString(col.pszText)
   Next
EndFunction


Function SetHeading(column:Int, heading$, width:Int, action:Int = LVM_SETCOLUMNW)
   
      Local col:LVCOLUMNW = New LVCOLUMNW
      Local columnHeading:TColumnHeading[1]   
      columnHeading[column] = New TColumnHeading
      columnHeading[column].width = width
     
      If columnHeading[Column].width = 0 Then
         Col.mask = LVCF_TEXT| LVCF_FMT
      Else
         Col.mask = LVCF_TEXT| LVCF_FMT | LVCF_WIDTH
         col.cx   = columnHeading[Column].width
      End If
     
      col.pszText = heading$.ToWString()
     
      Local ListBoxstyle:Int = GetWindowLongW(ListboxHwnd , GWL_STYLE)

     
      If (ListBoxstyle &  LVS_NOCOLUMNHEADER ) Then
         ListBoxstyle  = ListBoxstyle  ~LVS_NOCOLUMNHEADER
         If ListBoxstyle & LVS_EDITLABELS = 0 Then ListBoxstyle = ListBoxstyle | LVS_REPORT
         SetWindowLongW(ListboxHwnd , GWL_STYLE , ListBoxstyle) 'Headings aktivieren
         
         SendMessageW(listboxhwnd , LVM_SETEXTENDEDLISTVIEWSTYLE , 0 , LVS_EX_HEADERDRAGDROP   )  ' Zum verschieben von Columns
         
      End If
     
      SendMessageW(ListboxHwnd, action, Column, Int(Byte Ptr Col))
     

End Function


Type TColumnHeading
   Field width:Int
   Field sortDir:Int = 1
EndType





Mfg Suco
Intel Core 2 Quad Q8300, 4× 2500 MHz, 4096 MB DDR2-Ram, GeForce 9600GT 512 MB
 

danielos

BeitragMi, Jan 21, 2009 15:56
Antworten mit Zitat
Benutzer-Profile anzeigen
ach verdammt... da war ich schon mal nahe dran Rolling Eyes

vielen dank! Smile

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group