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

Fred

Supermoderator

  • »Fred« ist der Autor dieses Themas

Beiträge: 2 121

Beruf: Softwareentwickler

  • Private Nachricht senden

51

18.07.2006, 22:19

Nur so wie es im Moment ist brigt er mir bei jedem Menüpunkt den ich anklicke eine MessageBox

koschka

Community-Fossil

Beiträge: 2 862

Wohnort: Dresden

Beruf: Student

  • Private Nachricht senden

52

18.07.2006, 22:37

poste mal bitte code, am besten mal alles

Fred

Supermoderator

  • »Fred« ist der Autor dieses Themas

Beiträge: 2 121

Beruf: Softwareentwickler

  • Private Nachricht senden

53

19.07.2006, 13:38

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#define UNICODE 
#include <windows.h>


// Namespace fix für das Menü

namespace fix
{
    const unsigned short IDM_NEW = 0; 
    const unsigned short IDM_OPEN = 0; 
    const unsigned short IDM_SAVE = 0; 
    const unsigned short IDM_SAVEAS = 0; 
    const unsigned short IDM_QUIT = 0; 
    const unsigned short IDM_UNDO = 0; 
    const unsigned short IDM_REDO = 0;
    const unsigned short IDM_CUT = 0; 
    const unsigned short IDM_COPY = 0; 
    const unsigned short IDM_PASTE = 0; 
    const unsigned short IDM_SELECTALL = 0; 
    const unsigned short IDM_DESELECTALL = 0;
    const unsigned short IDM_IMPORT = 0;
} 

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

// Globale Variablen

    WPARAM                      wParam;
    ::HWND                      hWnd;
    ::WNDCLASS                  wndcls; 
    ::MSG                       msg; 
    HMENU                       hMenu_          = CreateMenu(); 
    HMENU                       hMenuTemp       = CreateMenu(); 
    HMENU                       hMenuObject     = CreateMenu();
    HMENU                       hMenuTemp2      = CreateMenu();
    HMENU                       hMenuCharakter  = CreateMenu();
    HMENU                       hMenuLevel      = CreateMenu();
    const unsigned short        ID_NEWFILE      = fix::IDM_NEW; 

int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) 
{  
 // -- Obermenü -- 

    // Das Dateinemü 

    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_NEW, L"&Neu\tStrg + N"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_OPEN, L"&Öffnen ...\tStrg + 0"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SAVE, L"&Speichern\tStrg + S"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SAVEAS, L"&Speichern unter ..."); 
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_QUIT, L"&Beenden\tStrg + Q"); 
    AppendMenu(hMenu_, MF_POPUP, (UINT_PTR)hMenuTemp, L"&Datei"); 
    hMenuTemp = CreateMenu();

    // Das Bearbeitenmenü

    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_UNDO, L"&Rückgängig\tStr + Z");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_REDO, L"&Wiederherstellen\tStr + Y");
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_CUT, L"&Ausschneiden\tStr + X");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_COPY, L"&Kopieren\tStr + C");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_PASTE, L"&Einfügen\tStr + V");
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SELECTALL, L"&Alles auswählen\tStr + A");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_DESELECTALL, L"&Alles auswählen\tStr + Shift + A");
    AppendMenu(hMenu_, MF_POPUP, (UINT_PTR)hMenuTemp, L"&Bearbeiten");
    hMenuTemp = CreateMenu();
    
    // Informationen für das Fenster

    wndcls.cbClsExtra = 0; 
    wndcls.cbWndExtra = 0; 
    wndcls.hbrBackground = static_cast<HBRUSH>(::GetStockObject((int)WHITE_BRUSH)); 
    wndcls.hCursor = NULL; 
    wndcls.hIcon = NULL; 
    wndcls.hInstance = hInstance; 
    wndcls.lpfnWndProc = WindowProc; 
    wndcls.lpszClassName = L"app"; 
    wndcls.lpszMenuName = NULL;  // <= Menu rein 

    wndcls.style = CS_HREDRAW | CS_VREDRAW; 

    if(!::RegisterClassW(&wndcls)) 
        return -1; 

    // Fenster erstellen

    hWnd = ::CreateWindowW( L"app", L"Test" , WS_OVERLAPPEDWINDOW, 0, 0, 1280, 782, ::GetDesktopWindow(), hMenu_, hInstance, NULL); 
    
    if(!hWnd) // Fehler beim erstellen des Fensters

        return -1; 

    ::ShowWindow(hWnd, nCmdShow); 
    ::UpdateWindow(hWnd); 

    while(::GetMessageW(&msg, NULL, NULL, NULL)) 
    { 
        ::TranslateMessage(&msg); 
        ::DispatchMessageW(&msg); 
    } 
    return 0; 
} 

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{ 
    switch(uMsg) 
    { 
    case WM_CLOSE: 
        PostQuitMessage(0); 
        return 0; 
    case WM_COMMAND: 
        if(HIWORD(wParam) == ID_NEWFILE) 
        MessageBox(hWnd, L"Sie haben auf Neu gedrückt!", L"Neu", MB_OK); 
    }; 
    return ::DefWindowProcW(hwnd, uMsg, wParam, lParam); 
}

Das Gurke

Community-Fossil

Beiträge: 1 996

Wohnort: Pinneberg

Beruf: Schüler

  • Private Nachricht senden

54

19.07.2006, 14:52

Zitat von »"Das Gurke"«

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
Edit:
[cpp]namespace fix
{
    const unsigned short IDM_NEW = 0;
    const unsigned short IDM_OPEN = 0;
    const unsigned short IDM_SAVE = 0;
    const unsigned short IDM_SAVEAS = 0;
    const unsigned short IDM_QUIT = 0;
    const unsigned short IDM_AREAMANAGER = 0;
    const unsigned short IDM_DRAWCOORDS = 0;
} 
AUTSCH!

Fred

Supermoderator

  • »Fred« ist der Autor dieses Themas

Beiträge: 2 121

Beruf: Softwareentwickler

  • Private Nachricht senden

55

19.07.2006, 15:26

was ist denn da anders?

koschka

Community-Fossil

Beiträge: 2 862

Wohnort: Dresden

Beruf: Student

  • Private Nachricht senden

56

19.07.2006, 15:38

deine ID's sind immer 0, bei jedem Element.

Du musst natürlich eineindeutige IDs vergebene... 0, 1, 2, 3, 4, ... , n wobei n€N

Fred

Supermoderator

  • »Fred« ist der Autor dieses Themas

Beiträge: 2 121

Beruf: Softwareentwickler

  • Private Nachricht senden

57

19.07.2006, 17:57

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#define UNICODE 
#include <windows.h>


// Namespace fix für das Menü

namespace fix
{
   const unsigned short IDM_NEW = 0; 
    const unsigned short IDM_OPEN = 1; 
    const unsigned short IDM_SAVE = 2; 
    const unsigned short IDM_SAVEAS =3; 
    const unsigned short IDM_QUIT = 4; 
    const unsigned short IDM_UNDO = 5; 
    const unsigned short IDM_REDO = 6;
    const unsigned short IDM_CUT = 7; 
    const unsigned short IDM_COPY = 8; 
    const unsigned short IDM_PASTE = 9; 
    const unsigned short IDM_SELECTALL = 10; 
    const unsigned short IDM_DESELECTALL = 11;
    const unsigned short IDM_IMPORT = 12;
} 

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

// Globale Variablen

    WPARAM                      wParam;
    ::HWND                      hWnd;
    ::WNDCLASS                  wndcls; 
    ::MSG                       msg; 
    HMENU                       hMenu_          = CreateMenu(); 
    HMENU                       hMenuTemp       = CreateMenu(); 
    HMENU                       hMenuObject     = CreateMenu();
    HMENU                       hMenuTemp2      = CreateMenu();
    HMENU                       hMenuCharakter  = CreateMenu();
    HMENU                       hMenuLevel      = CreateMenu();
    const unsigned short        ID_NEWFILE      = fix::IDM_NEW; 

int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) 
{  
 // -- Obermenü -- 

    // Das Dateinemü 

    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_NEW, L"&Neu\tStrg + N"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_OPEN, L"&Öffnen ...\tStrg + 0"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SAVE, L"&Speichern\tStrg + S"); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SAVEAS, L"&Speichern unter ..."); 
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_QUIT, L"&Beenden\tStrg + Q"); 
    AppendMenu(hMenu_, MF_POPUP, (UINT_PTR)hMenuTemp, L"&Datei"); 
    hMenuTemp = CreateMenu();

    // Das Bearbeitenmenü

    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_UNDO, L"&Rückgängig\tStr + Z");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_REDO, L"&Wiederherstellen\tStr + Y");
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_CUT, L"&Ausschneiden\tStr + X");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_COPY, L"&Kopieren\tStr + C");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_PASTE, L"&Einfügen\tStr + V");
    AppendMenuW(hMenuTemp, MF_SEPARATOR, 0, NULL); 
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_SELECTALL, L"&Alles auswählen\tStr + A");
    AppendMenuW(hMenuTemp, MF_STRING, fix::IDM_DESELECTALL, L"&Alles auswählen\tStr + Shift + A");
    AppendMenu(hMenu_, MF_POPUP, (UINT_PTR)hMenuTemp, L"&Bearbeiten");
    hMenuTemp = CreateMenu();
    
    // Informationen für das Fenster

    wndcls.cbClsExtra = 0; 
    wndcls.cbWndExtra = 0; 
    wndcls.hbrBackground = static_cast<HBRUSH>(::GetStockObject((int)WHITE_BRUSH)); 
    wndcls.hCursor = NULL; 
    wndcls.hIcon = NULL; 
    wndcls.hInstance = hInstance; 
    wndcls.lpfnWndProc = WindowProc; 
    wndcls.lpszClassName = L"app"; 
    wndcls.lpszMenuName = NULL;  // <= Menu rein 

    wndcls.style = CS_HREDRAW | CS_VREDRAW; 

    if(!::RegisterClassW(&wndcls)) 
        return -1; 

    // Fenster erstellen

    hWnd = ::CreateWindowW( L"app", L"Test" , WS_OVERLAPPEDWINDOW, 0, 0, 1280, 782, ::GetDesktopWindow(), hMenu_, hInstance, NULL); 
    
    if(!hWnd) // Fehler beim erstellen des Fensters

        return -1; 

    ::ShowWindow(hWnd, nCmdShow); 
    ::UpdateWindow(hWnd); 

    while(::GetMessageW(&msg, NULL, NULL, NULL)) 
    { 
        ::TranslateMessage(&msg); 
        ::DispatchMessageW(&msg); 
    } 
    return 0; 
} 

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{ 
    switch(uMsg) 
    { 
    case WM_CLOSE: 
        PostQuitMessage(0); 
        return 0; 
    case WM_COMMAND: 
        if(HIWORD(wParam) == ID_NEWFILE) 
        MessageBox(hWnd, L"Sie haben auf Neu gedrückt!", L"Neu", MB_OK); 
    }; 
    return ::DefWindowProcW(hwnd, uMsg, wParam, lParam); 
}

Ich hab da sgeändert. Ändert aber nichts daran, dass immer wenn ich einen Menüpunkt einklicke die Message erscheint

Das Gurke

Community-Fossil

Beiträge: 1 996

Wohnort: Pinneberg

Beruf: Schüler

  • Private Nachricht senden

58

19.07.2006, 18:02

C-/C++-Quelltext

1
if(HIWORD(wParam) == IDM_NEW)

Setz dich DRINGEND mal mit Sachen wie der Winnachrichtenschleife auseinander. Und zwar GRUND auf!

Fred

Supermoderator

  • »Fred« ist der Autor dieses Themas

Beiträge: 2 121

Beruf: Softwareentwickler

  • Private Nachricht senden

59

19.07.2006, 18:14

Ups da muss natürlich LOWORD stehen. Deswegen hat es nicht geklappt.

Danke

PS: Petzold wird bald bestellt

koschka

Community-Fossil

Beiträge: 2 862

Wohnort: Dresden

Beruf: Student

  • Private Nachricht senden

60

19.07.2006, 18:41

wo hast du den jetzt bitte ID_NEWFILE definiert? Gar nicht.


Es bringt dir nichts wenn du es nicht verstehst, abkopieren kann jeder, dazu muss man nichts drauf haben. Ich würde ich mal bitten den code in Ruhe nochmal durchugehen, evtl neuzuschreiben und nur elemente zu benutzen die du auch 100%ig verstehst.

Werbeanzeige