Vordefinierte Tabelle in WinApi?
-
commctrl.h als Header und dann noch comctl32.lib linken
-
steht in der commctrl.h
if(_WIN32_IE >= 0x0300)
platform sdk geloadet?
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htmps: initcommoncontrols langt auch
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/common/functions/initcommoncontrols.asp[edit]
mist das linken hab ich vergessen.
-
Seltsam commctrl.h und libcommctrl.a habe ich eigentlich mit gelinkt, nur ich verstehe nicht ganz was miller gepostet hat. Der Fehler ist immer noch das die Struktur nicht findet, das gleiche gilt für die initcommonctrlex funktion
#include <windows.h> #include <string> #include "main.h" #include "erstellen.h" #include <commctrl.h> #define BT_HINZUFUGEN 1 #define BT_ABBRECHEN 2 #define BT_SPEICHERN 3 #define LB_LIST 10 #define EDIT_ZUSATZ 20 #define EDIT_DEUTSCH 21 #define EDIT_LATEIN 22 using namespace std; LRESULT CALLBACK WndErstellenProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hinstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE); static char xy1[100], xy2[100], xy3[100]; static LVCOLUMN list; INITCOMMONCONTROLSEX icex; switch(message) { case WM_CREATE: CreateWindow("button", "Speichern", WS_VISIBLE | WS_CHILD, 270,360,100,40,hwnd,(HMENU) BT_SPEICHERN,hinstance,0); CreateWindow("button", "Abbrechen", WS_VISIBLE | WS_CHILD, 20,360,100,40,hwnd,(HMENU) BT_ABBRECHEN,hinstance,0); CreateWindow("button", "Hinzufügen", WS_VISIBLE | WS_CHILD, 280,70,100,40,hwnd,(HMENU) BT_HINZUFUGEN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,50,170,20,hwnd,(HMENU) EDIT_LATEIN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,80,170,20,hwnd,(HMENU) EDIT_DEUTSCH,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,110,170,20,hwnd,(HMENU) EDIT_ZUSATZ,hinstance,0); CreateWindow("static", "Latein:", WS_VISIBLE | WS_CHILD, 20,52,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Deutsch:", WS_VISIBLE | WS_CHILD, 20,82,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Zusatz:", WS_VISIBLE | WS_CHILD, 20,112,60,50,hwnd,0,hinstance,0); CreateWindow(WC_LISTVIEW, "", WS_VISIBLE | WS_CHILD | LVS_REPORT, 20,200,350,150,hwnd,(HMENU)LB_LIST,hinstance,0); icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&icex); list.mask = LVCF_TEXT; list.pszText = "Test"; list.cx = 100; ListView_SetColumn(GetDlgItem(hwnd,LB_LIST),1,&list); list.mask = LVCF_TEXT; list.pszText = "Test2"; list.cx = 100; ListView_SetColumn(GetDlgItem(hwnd,LB_LIST),0,&list); EnumChildWindows(hwnd, EnumChildProc, 0); strcpy(xy1, "xy"); strcpy(xy2, "xy"); strcpy(xy3, "xy"); break; case WM_COMMAND: switch(LOWORD(wParam)) { case BT_HINZUFUGEN: GetDlgItemText(hwnd, EDIT_LATEIN, xy1, 100); GetDlgItemText(hwnd, EDIT_DEUTSCH, xy2, 100); GetDlgItemText(hwnd, EDIT_ZUSATZ, xy3, 100); AddToList(GetDlgItem(hwnd, LB_LIST), xy1, xy2, xy3); break; case BT_ABBRECHEN: DestroyWindow(hwnd); break; case BT_SPEICHERN: MessageBox(0,"Speichern", "Button gedrückt", 0); break; } default: return DefWindowProc (hwnd, message, wParam, lParam); break; } }
-
Ich hatte ihn so verstanden:
#define _WIN32_IE 0x0300 #include <commctrl.h>
oder eben statt InitCommonControlsEx InitCommonControls verwenden
-
flenders schrieb:
Ich hatte ihn so verstanden:
#define _WIN32_IE 0x0300 #include <commctrl.h>
es muss grösser sein, war vielleicht unglücklich beschrieben
bsp:
#if(_WIN32_IE <= 0x0300) #define _WIN32_IE 0x0500 // IE 5.0 #endif #include <commctrl.h>
ich sehe gerade das du dev-cpp vermutlich benutzt dann vergiss das mit plaform sdk
dann würde ich am anfang die common ctrl's setzen
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES; // evtl. noch fehler abfangen InitCommonControlsEx(&icex); // ....
-
Ok, jetzt geht das kompelieren aber Spalten habe ich noch immer nicht
#include <windows.h> #include <string> #include "main.h" #include "erstellen.h" #if(_WIN32_IE <= 0x0300) #define _WIN32_IE 0x0500 // IE 5.0 #endif #include <commctrl.h> #define BT_HINZUFUGEN 1 #define BT_ABBRECHEN 2 #define BT_SPEICHERN 3 #define LB_LIST 10 #define EDIT_ZUSATZ 20 #define EDIT_DEUTSCH 21 #define EDIT_LATEIN 22 using namespace std; LRESULT CALLBACK WndErstellenProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hinstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE); static char xy1[100], xy2[100], xy3[100]; static LVCOLUMN list; INITCOMMONCONTROLSEX icex; switch(message) { case WM_CREATE: icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&icex); CreateWindow("button", "Speichern", WS_VISIBLE | WS_CHILD, 270,360,100,40,hwnd,(HMENU) BT_SPEICHERN,hinstance,0); CreateWindow("button", "Abbrechen", WS_VISIBLE | WS_CHILD, 20,360,100,40,hwnd,(HMENU) BT_ABBRECHEN,hinstance,0); CreateWindow("button", "Hinzufügen", WS_VISIBLE | WS_CHILD, 280,70,100,40,hwnd,(HMENU) BT_HINZUFUGEN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,50,170,20,hwnd,(HMENU) EDIT_LATEIN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,80,170,20,hwnd,(HMENU) EDIT_DEUTSCH,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,110,170,20,hwnd,(HMENU) EDIT_ZUSATZ,hinstance,0); CreateWindow("static", "Latein:", WS_VISIBLE | WS_CHILD, 20,52,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Deutsch:", WS_VISIBLE | WS_CHILD, 20,82,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Zusatz:", WS_VISIBLE | WS_CHILD, 20,112,60,50,hwnd,0,hinstance,0); CreateWindow(WC_LISTVIEW, "", WS_VISIBLE | WS_CHILD | LVS_REPORT, 20,200,350,150,hwnd,(HMENU)LB_LIST,hinstance,0); list.mask = LVCF_TEXT; list.pszText = "Test"; list.cx = 100; ListView_SetColumn(GetDlgItem(hwnd,LB_LIST),1,&list); list.mask = LVCF_TEXT; list.pszText = "Test2"; list.cx = 100; ListView_SetColumn(GetDlgItem(hwnd,LB_LIST),0,&list); EnumChildWindows(hwnd, EnumChildProc, 0); strcpy(xy1, "xy"); strcpy(xy2, "xy"); strcpy(xy3, "xy"); break; case WM_COMMAND: switch(LOWORD(wParam)) { case BT_HINZUFUGEN: GetDlgItemText(hwnd, EDIT_LATEIN, xy1, 100); GetDlgItemText(hwnd, EDIT_DEUTSCH, xy2, 100); GetDlgItemText(hwnd, EDIT_ZUSATZ, xy3, 100); //AddToList(GetDlgItem(hwnd, LB_LIST), xy1, xy2, xy3); break; case BT_ABBRECHEN: DestroyWindow(hwnd); break; case BT_SPEICHERN: MessageBox(0,"Speichern", "Button gedrückt", 0); break; } default: return DefWindowProc (hwnd, message, wParam, lParam); break; } }
-
insertcolumn statt setcolumn
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/macros/listview_insertcolumn.asp
-
Ok, das klapt jetzt alles mit den Spalten. Und Sorry im Voraus das ich jetzt schon wieder eine Frage stelle. Ich versuche jetzt mit:
item.mask = LVIF_TEXT | LVIF_COLUMNS; item.pszText = "Test"; item.iItem = 1; item.iSubItem = 1; item.cColumns = 1; ListView_InsertItem(GetDlgItem(hwnd,LB_LIST), &item);
Items in die Tabelle zu schreiben. Prob er findet LVIF_COLUMNS nicht, wahrscheinlich wegen der falschen Version. Wie kann man dann Text in die Tabelle aufnehmen?
-
flammenvogel schrieb:
Ok, das klapt jetzt alles mit den Spalten. Und Sorry im Voraus das ich jetzt schon wieder eine Frage stelle. Ich versuche jetzt mit:
dafür ist ein forum da
flammenvogel schrieb:
Wie kann man dann Text in die Tabelle aufnehmen?
hast du mal das bsp: aus der msdn probiert?
http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/listview_using.asp?frame=true#Adding_ListView_Items_and_Subitems
ohne LVIF_IMAGE und LVIF_STATE
-
Also irgendwie funzt das nicht, hier der Code:
#include <windows.h> #include <string> #include "main.h" #include "erstellen.h" #if(_WIN32_IE <= 0x0300) #define _WIN32_IE 0x0500 // IE 5.0 #endif #include <commctrl.h> #define BT_HINZUFUGEN 1 #define BT_ABBRECHEN 2 #define BT_SPEICHERN 3 #define LB_LIST 10 #define EDIT_ZUSATZ 20 #define EDIT_DEUTSCH 21 #define EDIT_LATEIN 22 using namespace std; struct TEST { char xy1[100]; char xy2[100]; char xy3[100]; }; LRESULT CALLBACK WndErstellenProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hinstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE); static char xy1[100], xy2[100], xy3[100]; static LVCOLUMN list; LVITEM item; INITCOMMONCONTROLSEX icex; TEST text = {"xy", "xy", "xy"}; switch(message) { case WM_CREATE: icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&icex); CreateWindow("button", "Speichern", WS_VISIBLE | WS_CHILD, 270,360,100,40,hwnd,(HMENU) BT_SPEICHERN,hinstance,0); CreateWindow("button", "Abbrechen", WS_VISIBLE | WS_CHILD, 20,360,100,40,hwnd,(HMENU) BT_ABBRECHEN,hinstance,0); CreateWindow("button", "Hinzufügen", WS_VISIBLE | WS_CHILD, 280,70,100,40,hwnd,(HMENU) BT_HINZUFUGEN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,50,170,20,hwnd,(HMENU) EDIT_LATEIN,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,80,170,20,hwnd,(HMENU) EDIT_DEUTSCH,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_VISIBLE | WS_CHILD, 80,110,170,20,hwnd,(HMENU) EDIT_ZUSATZ,hinstance,0); CreateWindow("static", "Latein:", WS_VISIBLE | WS_CHILD, 20,52,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Deutsch:", WS_VISIBLE | WS_CHILD, 20,82,60,50,hwnd,0,hinstance,0); CreateWindow("static", "Zusatz:", WS_VISIBLE | WS_CHILD, 20,112,60,50,hwnd,0,hinstance,0); CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW, "", WS_VISIBLE | WS_CHILD | LVS_REPORT, 20,200,350,150,hwnd,(HMENU)LB_LIST,hinstance,0); list.mask = LVCF_TEXT | LVCF_WIDTH; list.pszText = "Latein"; list.cx = 100; ListView_InsertColumn(GetDlgItem(hwnd,LB_LIST),1,&list); list.mask = LVCF_TEXT | LVCF_WIDTH; list.pszText = "Deutsch"; list.cx = 100; ListView_InsertColumn(GetDlgItem(hwnd,LB_LIST),0,&list); list.pszText = "Zusatz"; list.cx = 100; ListView_InsertColumn(GetDlgItem(hwnd,LB_LIST),2,&list); item.mask = LVIF_TEXT | LVIF_PARAM; item.pszText = LPSTR_TEXTCALLBACK; item.lParam = (LPARAM) &text; item.iItem = 1; item.iSubItem = 0; ListView_InsertItem(GetDlgItem(hwnd,LB_LIST), &item); EnumChildWindows(hwnd, EnumChildProc, 0); strcpy(xy1, "xy"); strcpy(xy2, "xy"); strcpy(xy3, "xy"); break; case WM_COMMAND: switch(LOWORD(wParam)) { case BT_HINZUFUGEN: GetDlgItemText(hwnd, EDIT_LATEIN, xy1, 100); GetDlgItemText(hwnd, EDIT_DEUTSCH, xy2, 100); GetDlgItemText(hwnd, EDIT_ZUSATZ, xy3, 100); //AddToList(GetDlgItem(hwnd, LB_LIST), xy1, xy2, xy3); break; case BT_ABBRECHEN: DestroyWindow(hwnd); break; case BT_SPEICHERN: MessageBox(0,"Speichern", "Button gedrückt", 0); break; } default: return DefWindowProc (hwnd, message, wParam, lParam); break; } }
-
wo ist WM_NOTIFY ?
-
Ich kann nicht ganz nachvollziehen wo bei dem Msdn Beispiel plvdi herkommt
-
weiter unten ist ne notify von einer virtual list view dort siehst du es.
-
ok ich werde das mal probieren
@miller_m: hast du das mit dem Tabellen List Window schon mal gemacht oder "rätst", du jetzt nur? (Soll keine Kritik sein, es interressiert mich nur)
-
ja schon eingie male. wenn ich rate schreib ich es dazu.
ps: hab es auch nicht als kritik aufgefasst, mich würde nur interessieren wie darauf kommst.
-
srry das ich so lange nichts mehr geschrieben habe aber ich war die letzten Tage ziemlich im Stress. Ich kriege den Kram einfach nicht hin könnte jemmand von euch meinen Code mal so verbessern das es funktioniert. In der MSDN benutzten die nämlich so ein komisches Array, dann ist mir noch aufgefallen das WM_NOTIFY scheinbar keine Funktionen aufruft und auch nichts zurückgibt, was bringt mir dann WM_NOTIFY. Das beste ist wohl wirklich, das ihr meinen Code einfach mal ergänzt.
-
na gut. so müsste es in etwa funktionieren
// würde ich, auch wenn es keiner schöner stil, global machen TEST test[5]; // bsp fünf // WM_CREATE oder sonst irgendwo im init code // TODO: füllen von test // index = index im array LV_ITEM lvI; int iSubItem; lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; lvI.state = 0; lvI.stateMask = 0; lvI.iItem = index; lvI.iSubItem = 0; lvI.pszText = LPSTR_TEXTCALLBACK; lvI.cchTextMax = MAX_PATH; lvI.lParam = (LPARAM)&test[index]; ListView_InsertItem(GetDlgItem(hwnd, LB_LIST), &lvI); for(iSubItem = 1; iSubItem < 3; iSubItem++) { ListView_SetItemText( GetDlgItem(hwnd, LB_LIST) index, iSubItem, LPSTR_TEXTCALLBACK); } // ---------------- case WM_NOTIFY: switch(wParam) { case LB_LIST: { LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam; TEST *pTest = (TEST*)(pLvdi->item.lParam); switch(pLvdi->hdr.code) { case LVN_GETDISPINFO: switch(pLvdi->item.iSubItem) { case 0: pLvdi->item.pszText = pTest->xy1; break; case 1: pLvdi->item.pszText = pTest->xy2; break; case 2: pLvdi->item.pszText = pTest->xy3; break; default: break; } break; } } break; } break;
hab ich grad noch gefunden
http://www.win-api.com/index.php?content=resources&mode=3&stat=res