Wie bekomme ich die die ID eines Windows?



  • Also ich will von mein Button das Label changen.

    button1 = CreateWindow(
    
        "button",	// pointer to registered class name
        "Button 1",	// pointer to window name
        WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON	,	// window style
        129,	// horizontal position of window
        230,	// vertical position of window
        100,	// window width
        20,	// window height
        hwnd,	// handle to parent or owner window
        (HMENU) 1,	// handle to menu or child-window identifier
        ((LPCREATESTRUCT) lParam)->hInstance,	// handle to application instance
        NULL 	// pointer to window-creation data
       );
    

    So hab eich den Button erstellt.

    BOOL SetDlgItemText(
    
        HWND hDlg,	// handle of dialog box
        int nIDDlgItem,	// identifier of control
        LPCTSTR lpString 	// text to set
    
    );
    

    Das habe ich aus der WinAPI Referenz.

    Durch das drücken des Buttons soll die Aufschrift geändert werden.
    In der WM_COMMAND steht denn der

    SetDlgItemText(
    
        hwnd,	// handle of dialog box
        100,
        "Button 2" 	// text to set
       );
    

    So wird es nix.
    Ich weiss nicht was diese int nIDDlgItem, // identifier of control sein soll, bzw wie ich die herraus bekomme.



  • GetDlgItem liefert dir das Handle zu dem Child-Kontrol mit der angegeben ID.



  • Wenn du dem Button die ID 1 gegeben hast, warum gibst du dann bei SetDlgItemText 100 an (und nicht 1) 😕



  • Danke an beide nun ist mir wenigstens klar was die wollten.


Anmelden zum Antworten