Bonjour,

Je suis en train de creer une petite classe pour creer facilement des fenetre Win32, et j'ai un probleme au niveau du passage de la fonction d'evennement dans la structure TWndClassEx.

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
 
type
    Window = class
    public
        constructor Create();
        destructor Destroy(); override;
 
        function InitWindow(width, height :integer; title :string) :boolean;
        function Update() : boolean;
 
 
    protected
         function MsgProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
        var
            m_Hwnd      : HWND;
            m_WndClass  : TWndClassEx;
 
    end; // class Window
 
implementation
 
constructor Window.Create();
begin
    inherited Create;
 
    with m_WndClass do
    begin
        cbSize          := SizeOf(TWndClassEx);
        style           := CS_CLASSDC;
        lpfnWndProc     := @MsgProc;
        cbClsExtra      := 0;
        cbWndExtra      := 0;
        hInstance       := GetModuleHandle(nil);
        hIcon           := 0;
        hCursor         := 0;
        hbrBackground   := 0;
        lpszMenuName    := nil;
        lpszClassName   := 'ConfEngine';
        hIconSm         := 0;
    end;
 
    RegisterClassEx(m_WndClass);
end;
 
destructor Window.Destroy;
begin
    UnregisterClass('ConfEngine', m_WndClass.hInstance);
end;
 
function Window.InitWindow(width: Integer; height: Integer; title: string):boolean;
begin
    m_Hwnd := CreateWindow('ConfEngine',
                           PAnsiChar(title),
                           WS_OVERLAPPEDWINDOW,
                           100, 100, width, height,
                           0, 0, m_WndClass.hInstance, self);
    // Show the window
    ShowWindow(m_Hwnd, SW_SHOWDEFAULT);
    UpdateWindow(m_Hwnd);
 
    result := true;
end;
 
function Window.Update() :boolean;
var
    msg : TMsg;
begin
    result := GetMessage(msg, 0, 0, 0);
    while result do
    begin
        TranslateMessage(msg);
        DispatchMessage(msg);
 
        result := GetMessage(msg, 0, 0, 0);
    end;
end;
j'ai l'erreur de compilation suivante, au niveau de la ligne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
lpfnWndProc     := @MsgProc;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
[DCC Error] application.window.pas(38): E2036 Variable required
Que faire ? j'ai loupé quelque chose ?