Dialog startet nicht
-
Moin,
hab folgendes Problem.- WOllte einfachen Dialog aufsetzen, doch schon beim ersten Zugriff knallts ...
hier mein code
#include <windows.h> #include "resource.h" //***********************************************************************************// LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); //***********************************************************************************// INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, reinterpret_cast<DLGPROC>(DlgProc)); return(FALSE); } //--------------------------------------------------------------------------- LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_INITDIALOG: for(unsigned int i = 1; i < 16; i ++) { SendMessage(GetDlgItem(hWnd, IDC_COMBO1), CB_ADDSTRING, 0, (LPARAM) i); SendMessage(GetDlgItem(hWnd, IDC_COMBO4), CB_ADDSTRING, 0, (LPARAM) i); } for(unsigned int i = 1; i < 12; i ++) { SendMessage(GetDlgItem(hWnd, IDC_COMBO2), CB_ADDSTRING, 0, (LPARAM) i); SendMessage(GetDlgItem(hWnd, IDC_COMBO5), CB_ADDSTRING, 0, (LPARAM) i); } for(unsigned int i = -12; i < 12; i += 4) { SendMessage(GetDlgItem(hWnd, IDC_COMBO3), CB_ADDSTRING, 0, (LPARAM) i); SendMessage(GetDlgItem(hWnd, IDC_COMBO6), CB_ADDSTRING, 0, (LPARAM) i); } return TRUE; case WM_CLOSE: EndDialog(hWnd, 0); return TRUE; } return(FALSE); }Entdeckt da einer nen Fehler? Ich hab da echt kein Plan ... Ich sehs einfach nicht.
Danke im vorraus
-
Aso noch vergessen:
Der Fehler: Exception weil hWnd in Zeile 24 defekt zu sein scheint ....
btw das daoben was versternt ist soll v o r r a u s heißen. Warum ist das denn im bad word lexikon?
-
Weil es das Wort "Vor|raus" nicht gibt.
Ach, äh, CB_ADDSTRING mit einem Integer als lParam?
MSDN schrieb:
lParam
A pointer to the null-terminated string to be added.
-
Ich heiße "Rechtschreib0r & Check0r", Bug im Forensystem?
-
Wenn es wirklich an dem Schwänzchen dort hinten liegen würde, dann käme der Fehler doch nicht bei Zugriff auf hwnd?
-
omg CB_ADDSTRING erwartet nen NULL terminierten string, du kannst dir ja ausrechnen was passiert, wenn w1nd00f deinen integer wert da als speicheradresse auffasst und denkt da stünde ein string drin. da regnets kühe vom himmel. außerdem ist der prototyp von ner dialogproc b00l ned LRESULT auch wenn das hier ned das pr0b is.
y0 br0