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

Mischu

Frischling

  • »Mischu« ist der Autor dieses Themas

Beiträge: 21

Wohnort: Olten (Schweiz)

Beruf: Javaentwickler (swissinfo.ch)

  • Private Nachricht senden

1

23.02.2010, 21:35

Ungültige Pointerreferenz bei Combobox

Hallo zusammen

Stecke grad an nem komischen Problem.

Erst mal mein Code, dann der Fehler

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
MG_MESSAGE refreshZStencilBuffer( HWND hwnd )
{
    char* caZStencilLabel;
    D3DFORMAT* testZStencilFormat;
    
    // z stencil formate für die Auswahl

    const D3DFORMAT aFormat[] = {D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D16};
    const UINT iZStencilFormatCount = sizeof( aFormat ) / sizeof( D3DFORMAT );

    // holen des aktuellen Adapters

    const UINT iSelectedAdapterIndex = (UINT)SendDlgItemMessage( hwnd, IDC_D3DS_ADAPTERS, CB_SETCURSEL, 0, 0 );
    const UINT iSelectedAdapter = (UINT)SendDlgItemMessage( hwnd, IDC_D3DS_ADAPTERS, CB_GETITEMDATA, iSelectedAdapterIndex, 0 );

    // holen des aktuellen Video Modus

    // dieser ist bereits abgeglichen mit windowes / not windowed

    int iSelectedMode = (int)SendDlgItemMessage( hwnd, IDC_D3DS_VIDEO_MODES, CB_SETCURSEL, 0, 0 );
    D3DDISPLAYMODE* pSelectedMode = (D3DDISPLAYMODE*)SendDlgItemMessage( hwnd, IDC_D3DS_VIDEO_MODES, CB_GETITEMDATA, iSelectedMode, 0 );

    // holen des aktuell gewählten Rasterizer

    const UINT iSelectedRasterizer = (UINT)SendDlgItemMessage( hwnd, IDC_D3DS_DEVICE_TYPES, CB_GETCURSEL, 0, 0 );
    const D3DDEVTYPE* currentRasterizer = (D3DDEVTYPE*)SendDlgItemMessage( hwnd, IDC_D3DS_DEVICE_TYPES, CB_GETITEMDATA, iSelectedAdapter, 0 );

    // ist der Fenstermodus gewählt?

    BOOL bWindowed = IsDlgButtonChecked( hwnd, IDC_D3DS_WINDOWED_MODE ) == BST_CHECKED;

    D3DDISPLAYMODE adapterMode;
    if( bWindowed )
    {
        g_pD3D->GetAdapterDisplayMode( iSelectedAdapter, &adapterMode );
    }
    else
    {
        adapterMode = *pSelectedMode;
    }

    // reseten der Combobox

    clearPointerList( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS );    

    for( UINT iNextZStencilFormatIndex = 0; iNextZStencilFormatIndex < iZStencilFormatCount; iNextZStencilFormatIndex++ )
    {
        // Überprüfen ob das Z-Buffer Stencil Format verfügbar ist und wenn, dann zur Auswahl stellen

        if( SUCCEEDED( g_pD3D->CheckDepthStencilMatch( iSelectedAdapter, *currentRasterizer, adapterMode.Format, pSelectedMode->Format, aFormat[iNextZStencilFormatIndex] ) ) )
        {
            D3DFORMAT* pZStencilFormat = new D3DFORMAT;
            *pZStencilFormat = aFormat[iNextZStencilFormatIndex];

            caZStencilLabel = getLabelForZStencilFormat( aFormat[iNextZStencilFormatIndex] );
            
            SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_ADDSTRING, iNextZStencilFormatIndex, (LPARAM)caZStencilLabel );
            SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_SETITEMDATA, iNextZStencilFormatIndex, (LPARAM)pZStencilFormat );
            testZStencilFormat = (D3DFORMAT*)SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_GETITEMDATA, iNextZStencilFormatIndex, 0 );
        }
    }

    if( 0 < (UINT) SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_GETCOUNT, 0, 0 ) )
    {
        SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_SETCURSEL, 0, 0 );
    }
    return MG_DIALOG_OK;
}


Also wie man unschwer sieht geht ums abfüllen, der Auswahl für den Z-Buffer.

Das Problem wenn ich mit SendDlgItemMessage( hwnd, IDC_D3DS_Z_STENCIL_BUFFER_FORMATS, CB_SETITEMDATA, iNextZStencilFormatIndex, (LPARAM)pZStencilFormat ); das Combobox Item value setze und es gleich danach zum Test wieder auslese ich eine ungültige Pointerreferenz erhalte.

Ich hab schon alles debugt. Alle Variablen haben gültige respektive gewollte Werte.

Hat wer ne Idee?
Bin gerade ziemlich ratlos...oder zulanger Arbeitstag ;)


Merci schon mal.


Greez Mischu