Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - Errori in Programma win32 nei cicli if e switch...
Forum - C/C++ - Errori in Programma win32 nei cicli if e switch...

Avatar
Zimo (Normal User)
Newbie


Messaggi: 10
Iscritto: 15/08/2009

Segnala al moderatore
Postato alle 12:08
Giovedì, 03/09/2009
Ecco i tre file che costituiscono il programma:
file1c.c
Codice sorgente - presumibilmente C#

  1. #include<windows.h>
  2. #include"file2menu.h"
  3. #define WIN32_LEAN_AND_MEAN
  4.  
  5. BOOL CALLBACK Procedura(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){
  6.      
  7. if(uMsg==WM_CLOSE){
  8.  EndDialog(hwndDlg, 0);
  9.  return TRUE;
  10. }else if(uMsg==WM_COMMAND){
  11. UINT codice = HIWORD(wParam);
  12. if(codice != BN_CLICKED) return FALSE;
  13. int idCliccato = LOWORD(wParam);
  14.  if(idCliccato!=IDC_BOTTONE) return FALSE;
  15.  HWND hScritta = GetDlgItem(hwndDlg,IDC_PRIMO);
  16.  if(!hScritta) return FALSE;
  17.  return SetWindowText(hScritta, idCliccato==IDC_BOTTONE?"Primo":"");
  18.  
  19.  
  20. } else if(uMsg==WM_COMMAND){
  21. switch(LOWORD(wParam))
  22.        {
  23.         case IDM_HELP_ABOUT:
  24.         MessageBox(0, "Questo programma è stato realizzato da Zimo", "Informazione", MB_OK | MB_ICONINFORMATION);
  25.         return TRUE;
  26.        
  27.         case IDM_FILE_EXIT:
  28.              EndDialog(hwndDlg, 0);
  29.         return TRUE;
  30.        }
  31. }
  32. return FALSE;
  33. }
  34.  
  35.  
  36. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow){
  37. DialogBoxParam(0, "Dialogo", 0, Procedura, 0);
  38. return 0;
  39. }



file1.rc
Codice sorgente - presumibilmente Delphi

  1. #include<windows.h>
  2. #include"file2menu.h"
  3.  
  4. Dialogo DIALOG DISCARDABLE 0, 0, 182, 172
  5. STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_OVERLAPPEDWINDOW
  6. CAPTION "Mia Applicazione ;)"
  7. FONT 8,"MS Sans Serif"
  8. MENU IDR_MAIN_MENU
  9. BEGIN
  10. CONTROL "Questo è un programma scritto da Zimo", IDC_PRIMO, "STATIC", SS_CENTER | SS_SUNKEN, 5, 5 , 170, 10
  11. CONTROL "Conferma", IDC_BOTTONE, "BUTTON", BS_PUSHBUTTON, 10, 40, 40, 10
  12. CONTROL "", 103, "EDIT", WS_BORDER, 60, 50, 60, 10
  13. END
  14.  
  15. IDR_MAIN_MENU MENU
  16. BEGIN
  17.     POPUP "&File"
  18.     BEGIN
  19.         MENUITEM "Se&lect a Sound",             IDM_FILE_SOUND
  20.         MENUITEM "E&xit",                       IDM_FILE_EXIT
  21.     END
  22.     POPUP "&Help"
  23.     BEGIN
  24.         MENUITEM "&About...\tF1",               IDM_HELP_ABOUT
  25.     END
  26. END



file2menu.h
Codice sorgente - presumibilmente C++

  1. #define IDR_MAIN_MENU                   102
  2. #define IDR_POPUP                       103
  3. #define IDM_FILE_SOUND                  2001
  4. #define IDM_FILE_EXIT                   2002
  5. #define IDM_HELP_ABOUT                  2003
  6. #define IDC_PRIMO                       101
  7. #define IDC_BOTTONE                     102



Riesco a compilare questo programma senza errori, ma quando vado ad eseguirlo riesco a svolgere il ciclo in cui se clicco in un bottone mi cambia il testo di uno static, ma se provo a cliccare nel menu ad esempio in 'About' o 'Exit' non mi fa niente.So che il pezzo di codice riguardante queste procedure è incasinato parecchio, però è da stamattina che provo a risolvere il problema senza risultato.

PM Quote