Salve, ho un problema con un programma; il compilatore mi dà questo errore:
"resource.h(3) : fatal error RC1004: unexpected end of file found".
Questo è il codice cpp:
Questo è il file di risorsa:codice:#include <windows.h> #include "resource.h" LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { static TCHAR szAppName[] = TEXT("About"); HWND hwnd; MSG msg; WNDCLASS wndclass; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, szAppName); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = szAppName; wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); //registrazione della classe hwnd = CreateWindow(szAppName, //nome della classe window TEXT("Programma che usa una finestra di dialogo About"), //titolo della finestra(barra del titolo) WS_OVERLAPPEDWINDOW, //stile window GetSystemMetrics(SM_CXSCREEN) / 4, //posizione x iniziale GetSystemMetrics(SM_CYSCREEN) / 4, //posizione y iniziale GetSystemMetrics(SM_CXSCREEN) / 3, //dimensione x iniziale(larghezza) GetSystemMetrics(SM_CXSCREEN) / 3, //dimensione y iniziale(altezza) NULL, //handle alla finestra genitore NULL, //handle al menù della finestra hInstance, //handle all'istanza del programma NULL); //parametri di creazione ShowWindow(hwnd, nCmdShow); //disegna la finestra sullo schermo, con le impostazioni iniziali date dall'utente UpdateWindow(hwnd); //disegna l'area client della finestra //ciclo dei messaggi while (GetMessage(&msg, NULL, 0, 0)) //recupera un messaggio dalla coda (restituisce FALSE (0) solo per WM_QUIT) { TranslateMessage(&msg); //opera alcune modifiche al messaggio a seconda della tastiera DispatchMessage(&msg); //invia il messaggio alla window procedure appropriata } return msg.wParam ; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hInstance; switch(message) { case WM_CREATE: hInstance = ((LPCREATESTRUCT)lParam)->hInstance; return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_APP_ABOUT: DialogBox(hInstance, TEXT("Finestra di About"), hwnd, AboutDlgProc); break; } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog(hDlg, 0); return TRUE; } break; } return FALSE; }
Infine questo è il file resource.h:codice:#include "resource.h" //Finestra di dialogo ABOUTBOX DIALOG 32, 32, 180, 100 STYLE DS_MODALFRAME | WS_POPUP FONT 8, "Ms Sans Serif" BEGIN DEFPUSHBUTTON "Ok", IDOK, 66, 80, 50, 14 ICON "ABOUT", IDC_STATIC, 7, 7, 21, 20 CTEXT "About", IDC_STATIC, 40, 12, 100, 8 CTEXT "Programma che usa una finestra di dialogo About", IDC_STATIC, 7, 40, 166, 8 CTEXT "(c) Minnoozzi Corrado, 2009", IDC_STATIC, 7, 52, 166, 8 END //Menu ABOUT MENU BEGIN POPUP "&Aiuto" BEGIN MENUITEM "&Informazioni su...", IDM_APP_ABOUT END END //Icona ABOUT ICON "About.ico"
codice:#define IDM_APP_ABOUT 5000 #define IDC_STATIC 5001

Rispondi quotando