// programme de combo box : Combo1.c : // projet : application windows // logiciel : Dev C++ version 5.7.1 /* ****************** PROBLEME ******************** c:\program files (x86)\dev-cpp\mingw32\include\winbase.h:1986:0: error: token "##" is not valid in preprocessor expressions #if (NTDDI_VERSION >= NTDDI_WIN2KSP2) ^ compilation terminated due to -Wfatal-errors. C:\Dev C++ Projets\Makefile.win:29: recipe for target 'Combo1.o' failed mingw32-make.exe: *** [Combo1.o] Error 1 Compilation results... -------- - Errors: 1 - Warnings: 0 - Compilation Time: 0,45s */ /******************************************************************************/ // programme combo.rc #include #include "combo.h" LEMENU MENU BEGIN POPUP "Fichier" BEGIN MENUITEM "Propriétés...", IDM_PROP MENUITEM SEPARATOR MENUITEM "Quitter", IDM_QUIT END END DIALOG1 DIALOG 110, 0, 175, 100 STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Propriétés de la figure" BEGIN LTEXT "Figure", -1, 35, 10, 30, 10 WS_GROUP COMBOBOX ID_CB1, 20, 24, 56, 45, CBS_DROPDOWNLIST GROUPBOX " Trait ", -1, 96, 10, 60 , 60, WS_GROUP AUTORADIOBUTTON "Fin", ID_RB1, 106, 20, 40, 15 AUTORADIOBUTTON "Moyen", ID_RB2, 106, 35, 40, 15 AUTORADIOBUTTON "Large", ID_RB3, 106, 50, 40, 15 DEFPUSHBUTTON "OK", IDOK, 36, 77, 42, 12, WS_GROUP PUSHBUTTON "Cancel", IDCANCEL, 96, 77, 42, 12 END /******************************************************************************/ // programme combo.h #define IDM_QUIT 1 #define IDM_PROP 2 #define ID_RB1 101 #define ID_RB2 102 #define ID_RB3 103 #define ID_CB1 201 /******************************************************************************/ // programme combo1.c #include #include "combo.h" #define DB_OK 1 #define FIN 1 #define MOYEN 2 #define LARGE 8 #define ID_CARRE 0 #define ID_CERCLE 1 #define ID_TRIANGLE 2 UINT Forme; UINT Trait; HINSTANCE hinst; LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM); BOOL APIENTRY Dialog1Proc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASS wc; hinst = hinstance; wc.style = 0; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); wc.lpszMenuName = "LEMENU"; wc.lpszClassName = "MaWinClass"; if(!RegisterClass(&wc)) return FALSE; hwnd = CreateWindow("MaWinClass", "Check Box", WS_OVERLAPPED | WS_SYSMENU,CW_USEDEFAULT, CW_USEDEFAULT, 400, 260, NULL, NULL, hinstance, NULL); if (!hwnd) return FALSE; ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } /******************************************************************************/ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: Forme = ID_CARRE; Trait = FIN; return 0; case WM_COMMAND: if(LOWORD(wParam) == IDM_QUIT) PostMessage(hwnd, WM_CLOSE,0,0); if(LOWORD(wParam) == IDM_PROP) { if(DialogBox(hinst, "DIALOG1" , hwnd, (DLGPROC)Dialog1Proc)== DB_OK) InvalidateRect(hwnd,NULL,TRUE); } return 0; case WM_PAINT : { PAINTSTRUCT ps; HDC hdc ; HPEN hpen, hpOld; POINT ptTriangle[3]; ptTriangle[0].x = 20; ptTriangle[0].y = 20; ptTriangle[1].x = 20; ptTriangle[1].y = 170; ptTriangle[2].x = 170; ptTriangle[2].y = 95; hdc = BeginPaint(hwnd, &ps); hpen = CreatePen(PS_SOLID, Trait, 0); hpOld = SelectObject(hdc,hpen); if(Forme == ID_CARRE) Rectangle(hdc, 20, 20, 170, 170); if(Forme == ID_CERCLE) Ellipse(hdc, 20, 20, 170, 170); if(Forme == ID_TRIANGLE) Polygon(hdc, ptTriangle, 3); SelectObject(hdc,hpOld); DeleteObject(hpen); EndPaint(hwnd, &ps); return 0; } case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } } /******************************************************************************/ BOOL APIENTRY Dialog1Proc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { SendDlgItemMessage(hDlg, ID_CB1, CB_ADDSTRING, 0, (LONG)"Carré"); SendDlgItemMessage(hDlg, ID_CB1, CB_ADDSTRING, 0, (LONG)"Cercle"); SendDlgItemMessage(hDlg, ID_CB1, CB_ADDSTRING, 0,(LONG)"Triangle"); SendDlgItemMessage(hDlg, ID_CB1, CB_SETCURSEL, Forme, 0); if(Trait == FIN ) CheckDlgButton(hDlg, ID_RB1, BST_CHECKED); if(Trait == MOYEN) CheckDlgButton(hDlg, ID_RB2, BST_CHECKED); if(Trait == LARGE) CheckDlgButton(hDlg, ID_RB3, BST_CHECKED); return TRUE; } case WM_COMMAND: if (LOWORD(wParam) == IDOK) { if(IsDlgButtonChecked(hDlg, ID_RB1) == BST_CHECKED) Trait = FIN; if(IsDlgButtonChecked(hDlg, ID_RB2) == BST_CHECKED) Trait = MOYEN; if(IsDlgButtonChecked(hDlg, ID_RB3) == BST_CHECKED) Trait = LARGE; Forme = SendDlgItemMessage(hDlg, ID_CB1, CB_GETCURSEL, 0, 0); EndDialog(hDlg,DB_OK); return TRUE; } if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg,0); return TRUE; } default: return FALSE; } }