tabelle???
-
gibts eine spezielle windowart das so eine art tabelle macht
|-----------------|
tabellen arte next element ----------------- sowas halt!!! ----------------- sowas mein ich
is doch toll die tabelle
-
Meinst du vielleicht ein ListView - das kann man so erstellen, dass auch Gitternetz-Linien angezeigt werden
-
nee ich mein das es einen string ausgibt und wenn ein neuer kommt untendrunter
-
Also keine Tabelle, sondern einfach Strings untereinander ausgeben
-
also schon tabelle weil ich die strings anklicken will
-
ComboBox, ListBox, ...
-
und wie kann ich listbox oder combobox benutzen
ich find in der msdn nämlich nur klassen und keinen syntax oder sowas
-
Wo hast du denn geschaut
-
hControl = CreateWindowEx( 0,szClassName, "Windows App", WS_VISIBLE|WS_CHILD| LBS_STANDARD, 0, 0, 100, 100,hwnd, (HMENU)1, (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL ); LRESULT CALLBACK Listbox( HWND hDlg, UINT message, UINT wParam, LONG lParam) { TCHAR tchBuffer[1000]; int nItem; int i; HWND hwndList; HDC hdc=GetDC(hDlg); switch (message) { case WM_INITDIALOG: { hwndList = GetDlgItem(hDlg, 0); HDC hdc=GetDC(hwndList); TextOut(hdc,20,20,"funze",6); for (i = 0; i < 10; i++) { SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM) "hallo");//hier soll die tabelle gefüllt werden SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM) i); } SetFocus(hwndList); return (1); } } }
also ich hab jetzt versucht eine tabelle zumachen die tabelle entsteht ja auch aber ich schaffe es nicht
die tabelle zufüllen vielleicht könnt ihr mir dabei helfen
-
Was soll das TextOut
und wie hast du Listbox eingebunden bzw. wie wird es aufgerufen
Wieso hast du bei GetDlgItem 0 angegeben, wenn deine ListBox doch 1 als ID hat?!Also wenn du das Ganze nicht in einem Dialog hast (du verwendest ja CreateWindowEx) brauchst du eigentlich nur die for-Schleife - das Handle der Listbox bekommst du ja schon von CreateWindowEx
-
flenders schrieb:
Also wenn du das Ganze nicht in einem Dialog hast
Dagegen spricht aber das abfangen von WM_INITDIALOG, und die gesamte CALLBACK-Funktion "Listbox"...
-
wie soll ich denn sonst machen????
-
Poste doch mal deinen kompletten Code...
-
#include <windows.h> #include <stdio.h> /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp"; HWND hControl; LRESULT CALLBACK Listbox( HWND hDlg, // window handle to dialog box UINT message, // type of message UINT wParam, // message-specific information LONG lParam) ; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, szClassName, "Windows App", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hThisInstance, NULL ); hControl = CreateWindowEx( 0,szClassName, "Windows App", WS_VISIBLE|WS_CHILD| LBS_STANDARD, 0, 0, 100, 100,hwnd, (HMENU)1, (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL ); /* Make the window visible on the screen */ ShowWindow (hwnd, nFunsterStil); ShowWindow (hControl, nFunsterStil); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { LPCTSTR prompt="INFO"; LPCTSTR title="TITTEL"; LPTSTR buffer; int buflength=200; HDC hdc=GetDC(hControl); HINSTANCE hThisInstance; HINSTANCE hPrevInstance; LPSTR lpszArgument; int nFunsterStil; LPSTR lp; int i; switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; case WM_CREATE: break; case WM_KEYUP: char buf2[200]; sprintf(buf2,"window=%d",hControl); MessageBox(NULL, buf2, "Handle", MB_ICONERROR); TextOut(hdc,0,0,"versuch",7); SendMessage(hwnd, WM_INITDIALOG, 0,0); // SendMessage(hControl, WM_INITDIALOG, 0,0); Listbox(hControl,message,wParam,lParam); return FALSE; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; } LRESULT CALLBACK Listbox( HWND hDlg, // window handle to dialog box UINT message, // type of message UINT wParam, // message-specific information LONG lParam) // message-specific information { TCHAR tchBuffer[1000]; int nItem; int i; HWND hwndList=hDlg; HDC hdc=GetDC(hDlg); switch (message) { for (i = 0; i < 10; i++) { SendMessage(hControl, LB_ADDSTRING, 0, (LPARAM) "hallo"); SendMessage(hControl,LB_SETITEMDATA, i, (LPARAM) i); } SetFocus(hwndList); return (1); } }
hab ihn halt schnell gemacht
-
Möchtest Du nicht erstmal ein Buch oder ein WinAPI-Tutorial durcharbeiten?
-
hab ich schon ich hab doch gesagt das ichs schnell gemacht habe.
kannst du mir jetzt helfen???
wenn ja tu es ansonsten poste doch einfach nicht!!!
-
Wenn du eine List-Box erzeugen willst solltest du aber schon auch LISTBOX als Fensterklasse angeben!
Und was denkst du, wer deine Listbox-Funktion aufrufen soll?!
Also packe die Schleife einfach direkt hinter den Aufruf von CreateWindow(Ex) für die List-Box. Außerdem werden die Child-Windows üblicherweise in WM_CREATE des Hauptfensters angelegt
-
gargamel schrieb:
kannst du mir jetzt helfen???
wenn ja tu es ansonsten poste doch einfach nicht!!!Ja, ich kann Dir helfen:
Arbeite ein WinAPI-Turorial durch oder lese ein WinAPI-Buch (wie z. B. den Petzold (Referenz auf dem Sektor)!Das ist die beste Hilfe, die man Dir geben kann!
-
also ich habs mal mit resourcen center probiert nur das es wieder nich schafft die zeilen einfügen und hwndList is immer NULL wieso????
case WM_INITDIALOG: hwndList = GetDlgItem(hwnd, ID_HELP_ABOUT); sprintf(buf,"window=%d",hwndList); MessageBox(NULL, buf, "Handle", MB_ICONERROR); for (i = 0; i < 10; i++) { SendMessage(hwndList,LB_ADDSTRING, 0,(LPARAM) "hallo"); SendMessage(hwndList,LB_SETITEMDATA, i, (LPARAM) i); } SetFocus(hwndList); return FALSE;
-
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); static char g_szClassName[] = "MyWindowClass"; static HINSTANCE g_hInstance = NULL; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX WndClass; HWND hwnd; MSG Msg; g_hInstance = hInstance; WndClass.cbSize = sizeof(WNDCLASSEX); WndClass.style = 0; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = g_hInstance; WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); WndClass.lpszMenuName = "ID_MENU"; WndClass.lpszClassName = g_szClassName; WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&WndClass)) { MessageBox(0, "Window Registration Failed!", "Error!", MB_ICONSTOP | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_STATICEDGE, g_szClassName, "Windows Title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, g_hInstance, NULL); if(hwnd == NULL) { MessageBox(0, "Window Creation Failed!", "Error!", MB_ICONSTOP | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_COMMAND: switch(LOWORD(wParam)) { case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case ID_HELP_\1: DialogBox(g_hInstance, "Listbox", hwnd, DlgProc); break; } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0; } BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { int i; HWND hwndList; char buf[100]; switch(Message) { case WM_INITDIALOG: hwndList = GetDlgItem(hwnd, ID_HELP_ABOUT); sprintf(buf,"window=%d",hwndList); MessageBox(NULL, buf, "Handle", MB_ICONERROR); for (i = 0; i < 1; i++) { SendMessage(hwndList,LB_ADDSTRING, 0,(LPARAM) "hallo"); SendMessage(hwndList,LB_SETITEMDATA, i, (LPARAM) i); } SetFocus(hwndList); return FALSE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: EndDialog(hwnd, IDOK); return TRUE; } break; } return FALSE; }
da is mal der ganze code bevor noch jemand meckert
-
Hast du jetzt einen Dialog als Ressource hinzugefügt, der eine List-Box mit der ID ID_HELP_ABOUT enthält?!
Wird denn der Dialog angezeigt? Falls nicht solltest du bei DialogBox für lpTemplate mal MAKEINTRESOURCE(ID_DEINES_DIALOGS) angeben