Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

eugler

Frischling

  • »eugler« ist der Autor dieses Themas

Beiträge: 26

Beruf: Student

  • Private Nachricht senden

31

27.10.2007, 17:02

ich hoffe, dass das hier dich weiterbringt... ich bin recht ratlos

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
LRESULT CALLBACK WndProc(   HWND    hWnd,           // Handle For This Window

                            UINT    uMsg,           // Message For This Window

                            WPARAM  wParam,         // Additional Message Information

                            LPARAM  lParam)         // Additional Message Information

{

    HMENU hMenu;
    POINT point;



    switch (uMsg)                                   // Check For Windows Messages

    {
        case WM_CREATE :
            //PlaySound(("Data/REF/welcome1.wav"), NULL, SND_FILENAME|SND_ASYNC);

        return 0 ;

        case WM_COMMAND:
            hMenu=GetMenu(hWnd);
        
            switch (LOWORD (wParam))
            {
            case ID_SETUPS_SETUP1:
                //hier dann Anzeige der entsprechenden Anodnung der Spheres!

                DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGSETUP1), hWnd, reinterpret_cast<DLGPROC>(DlgSetup1Proc));
            break;


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
LRESULT CALLBACK DlgSetup1Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {

    case WM_INITDIALOG:
char versuch[100];
        sprintf(versuch, "%d", EditBoxSup1_1_Val);

        int len;
        len = SendMessage(hEditBoxSup1_1, WM_GETTEXTLENGTH, 0,  0);
        SendMessage(hEditBoxSup1_1, EM_SETSEL, len, len);
        SendMessage(hEditBoxSup1_1, EM_REPLACESEL, FALSE,                                                    LPARAM)versuch); 
        
    
        return TRUE;

    case WM_COMMAND:
        switch(LOWORD (wParam))
        {
        case IDC_EDIT1:

            char Text1[256];
            hEditBoxSup1_1 = (HWND)lParam;
            GetWindowText (hEditBoxSup1_1, Text1, 256);
            EditBoxSup1_1_Val = atoi(Text1);  

        return (0);


vielen dank, dass du es dir anschaust... greetz

Also wenn ich mit SetWindowText() mir boxfill in die EditBox schreiben lasse kommt "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌŽ²8ãÔ;"
bei raus... ?! irgenwas stimmt da hinten und vorne nicht...

David_pb

Community-Fossil

Beiträge: 3 886

Beruf: 3D Graphics Programmer

  • Private Nachricht senden

32

27.10.2007, 18:26

Da stimmt hinten was nicht, deine Zeichenkette ist nicht nullterminiert.
Nochmal: Wieso nimmst du die WinAPI? Wieso nichts leichteres/schöner strukturiertes/besseres?
@D13_Dreinig

eugler

Frischling

  • »eugler« ist der Autor dieses Themas

Beiträge: 26

Beruf: Student

  • Private Nachricht senden

33

27.10.2007, 18:29

da kann ich leider nix machen, da ich ein bestehendes projekt versuche zu ändern und die arbeit mit winapi ausdrücklich erwünscht ist... würde auch lieber auf qt oder mfc zurückgreifen...

habs jetzt nochmal anders probiert... leider wieder nix :cry:
Funktion:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
BOOL Edit_AddText(HWND hWnd, LPCTSTR lpText)
{
   DWORD dwStart = 0, dwEnd = 0;
   int nLen;

   nLen = GetWindowTextLength(hWnd);
   SendMessage(hWnd, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
   SendMessage(hWnd, EM_SETSEL, (WPARAM)nLen, (LPARAM)nLen);
   SendMessage(hWnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)lpText);
   SendMessage(hWnd, EM_SETSEL, (WPARAM)dwStart, (LPARAM)dwEnd);

   return(TRUE);
}

DlgProc:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
LRESULT CALLBACK DlgSetup1Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

    switch(uMsg)
    {

    case WM_INITDIALOG:

        SetWindowText(hWnd, "Preferences of Setup 1");
        
        Edit_AddText(hEditBoxSup1_1, Text1);
        
        //SetWindowText(hEditBoxSup1_1, "hallo"); //FUNKTIONIERT EBENFALLS NICHT - SOBALD MAN IN EDITBOX KLICKT WIRD SCHEIBAR ENDLOS DER  STRING INS FELD GESCHRIEBEN -> PROGRAMMABSTURZ

    
        return TRUE;

    case WM_COMMAND:
        switch(LOWORD (wParam))
        {
        case IDC_EDIT1: 

            char Text1[256];
                        hEditBoxSup1_1 = (HWND)lParam;
                        GetWindowText (hEditBoxSup1_1, Text1, 256);
            EditBoxSup1_1_Val = atoi(Text1); 

        return (0);

[...]


hat denn keiner eine idee warum des nicht geht? oder hat jemand mal eine alternative lösung zur hand? beispielcode? ;)

greetz & thnx

Werbeanzeige