I was programming C++ and came across an error that said "Jump to case label" that i could not fix.I searched the internet and found no solution that worked. How do i fix this error?
#include<iostream>
#include<windows.h>
using namespace std;
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam);
INT WINAPI WinMain(HINSTANCE currentInstance, HINSTANCE previousInstance, PSTR cmdLine, INT cmdCount){
const char *CLASS_NAME = "myWin32WindowClass";
WNDCLASS wc{};
wc.hInstance = currentInstance;
wc.lpszClassName = CLASS_NAME;
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpfnWndProc = WindowProcessMessages;
RegisterClass(&wc);
CreateWindow(CLASS_NAME, "Operating System", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, nullptr, nullptr, nullptr, nullptr);
MSG msg{};
while(GetMessage(&msg, nullptr, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
#define ID_BUTTON 1
#define ID_BUTTON2 2
#define TEXTBOX 3
#define FILE_MENU_NEW 4
#define FILE_MENU_OPEN 5
#define FILE_MENU_EXIT 6 //<-"Jump to case label" error is right here
static HWND hwndTextbox;
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam){
switch(msg){
case WM_CREATE:{
CreateWindow(TEXT("STATIC"), TEXT("value"), WS_VISIBLE | WS_CHILD, 10, 10, 100, 25, hwnd, (HMENU) NULL, NULL, NULL);
CreateWindow(TEXT("BUTTON"), TEXT("testButton"), WS_CHILD | WS_VISIBLE, 10, 30, 80, 20, hwnd, (HMENU) ID_BUTTON, NULL, NULL);
CreateWindow(TEXT("EDIT"), TEXT("VALUE"), WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 70, 200, 20, hwnd, (HMENU) NULL, NULL, NULL );
CreateWindow(TEXT("BUTTON"), TEXT("Title change"), WS_CHILD | WS_VISIBLE, 10, 130, 80, 20, hwnd, (HMENU) ID_BUTTON2, NULL, NULL);
hwndTextbox = CreateWindow(TEXT("EDIT"), TEXT("Change To What?"), WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 100, 200, 20, hwnd, (HMENU) TEXTBOX, NULL, NULL );
HMENU hMenubar = CreateMenu();
HMENU hFile = CreateMenu();
HMENU hOptions = CreateMenu();
HMENU hSubmenu = CreateMenu();
AppendMenu(hSubmenu, MF_POPUP, NULL, "SubMenu Item");
AppendMenu(hMenubar, MF_POPUP, (UINT_PTR)hFile, "File");
AppendMenu(hMenubar, MF_POPUP, NULL, "Edit");
AppendMenu(hMenubar, MF_POPUP, (UINT_PTR)hOptions, "Options");
AppendMenu(hFile, MF_STRING, FILE_MENU_EXIT, "Exit");
AppendMenu(hFile, MF_POPUP, (UINT_PTR)hSubmenu, "Open Submenu");
AppendMenu(hOptions, MF_STRING, NULL, "Option 1");
AppendMenu(hOptions, MF_SEPARATOR, NULL, NULL);
AppendMenu(hOptions, MF_STRING, NULL, "Option 2");
SetMenu(hwnd, hMenubar);
break;
}
case WM_COMMAND:{
switch(LOWORD(param)){
case ID_BUTTON:
MessageBox(hwnd, "button has been clicked", "title for popup", MB_ICONINFORMATION);
break;
case ID_BUTTON2:
int len = GetWindowTextLength(hwndTextbox) + 1;
static char title[500];
GetWindowText(hwndTextbox, title, len);
SetWindowText(hwnd, title);
case FILE_MENU_EXIT:
DestroyWindow(hwnd);
break;
case
}
break;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, msg, param, lparam);
}
}