Bonjour,

Lorsque je fait la copilation de mon code il me donne l'erreur suivante:


C:\DOCUME~1\SUPERN~1\LOCALS~1\Temp\ccoRaaaa.o(.text+0x24d) In function `Z11MainWndProcP6HWND__jjl':
[Linker error] undefined reference to `GetStockObject@4'
C:\DOCUME~1\SUPERN~1\LOCALS~1\Temp\ccoRaaaa.o(.text+0x24d) ld returned 1 exit status


voici le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#include <windows.h>
 
#define IDM_QUIT 1
 
HINSTANCE hinst;
 
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
 
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
                                                LPSTR lpCmdLine, int nCmdShow)
{
    HWND hwnd;
    MSG msg;
    WNDCLASS wc;
    HMENU hMenu, hSousMenu;
 
    hinst = hinstance;
 
    wc.style = 0 ;
    wc.lpfnWndProc = MainWndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hinstance;
    wc.hIcon = NULL;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName =  NULL;
    wc.lpszClassName = "MaWinClass";
 
    if(!RegisterClass(&wc)) return FALSE;
 
    hSousMenu = CreateMenu();
    AppendMenu(hSousMenu, MF_STRING, IDM_QUIT, "Quitter");
    hMenu  = CreateMenu();
    AppendMenu(hMenu,MF_POPUP,(UINT)hSousMenu,"Fichier");
 
    hwnd = CreateWindow("MaWinClass", "Titre", WS_OVERLAPPEDWINDOW,
                                   CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
                                                   NULL, hMenu, hinstance, NULL);
    if (!hwnd)  return FALSE;
 
    ShowWindow(hwnd, nCmdShow);
 
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
/******************************************************************************/
 
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static HWND hEdit;
    static BOOL EditNotChg = TRUE;
 
    switch (uMsg)
    {
        case WM_CREATE:
            {
             HFONT hFont;
             hEdit = CreateWindow("edit", "Texte",
               WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL,
                                            0, 0, 0, 0, hwnd, NULL, hinst, NULL);
             hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
             SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);
             SendMessage(hEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN,
                                                                MAKELONG(5, 5));
             return 0;
            }
 
        case WM_CLOSE:
            if(EditNotChg ||
               MessageBox(hwnd,"Le texte a été modifié.\r\nEtes vous sûr de \
vouloir fermer l'application ?"
                            ,"Question ?",MB_YESNO | MB_ICONQUESTION ) == IDYES)
                                                            DestroyWindow(hwnd);
            return 0;
 
        case WM_COMMAND:
            if(LOWORD(wParam) == IDM_QUIT) PostMessage(hwnd, WM_CLOSE,0,0);
            if(HIWORD(wParam) == EN_CHANGE) EditNotChg = FALSE;
            return 0;
 
        case WM_SIZE:
            MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
             return 0;            
 
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
 
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
}


Je compile avec Dev-C++ sous windows
Merci de me répondre