[win32] - the button messages aren't activated :(

1 friend help me do these code for make my own control class's. and works fine with static. i did some changes for the button and the button is created, but the messages aren't :(
(if you need i can share the header file)
set parent:
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
void setParent(HWND parent=GetForegroundWindow())
    {
        if (hwnd==NULL)
        {
            static int i=0;
            i=i+1;
            strCaption=strCaption + to_string(i);
            WNDCLASS wc;
            HINSTANCE mod = (HINSTANCE)GetModuleHandle(NULL);

            ZeroMemory(&wc, sizeof(WNDCLASS));
            GetClassInfo(mod, TEXT("button"), &wc);

            wc.hInstance = mod;
            wc.lpszClassName = "CBUTTON";

            // store the old WNDPROC of the EDIT window class
            SetProp(parent, buttonpropname, (HANDLE)wc.lpfnWndProc);

            // replace it with local WNDPROC
            wc.lpfnWndProc = WndProcButton;
            wc.hbrBackground = (HBRUSH) ((COLOR_WINDOW)+1);

            // register the new window class, "ShEdit"
            RegisterClass(&wc);

            hwnd = CreateWindowEx(
                WS_EX_LEFT| WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_TRANSPARENT,
                TEXT("button"),
                strCaption.c_str(),
                WS_CHILD | WS_VISIBLE | BS_TEXT | WS_TABSTOP | BS_NOTIFY,
                0, 0, 60, 30,
                parent,
                NULL,
                mod,
                (LPVOID)this);

            if (hwnd == NULL)
                MessageBox(NULL, "error in create", "error", MB_OK);

            if (SetProp(hwnd, buttonclassprop, (HANDLE)this) == 0)
                MessageBox(NULL, "set class prop error", "error", MB_OK);
            clrBackColor= GetBkColor(GetDC(GetParent(hwnd)));
            clrTextColor = GetTextColor(GetDC(hwnd));
        }
        else
        {
            SetParent(hwnd,parent);
        }

        RECT a;
        GetClientRect(hwnd,&a);
        intTop=a.top;
        intLeft=a.left;
        intWidth=a.right-a.left;
        intHeight=a.bottom-a.top;
    }

heres the button procedure:
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
static void TrackMouseButton(HWND hwnd, long HoverTime=HOVER_DEFAULT)
    {
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(TRACKMOUSEEVENT);
        tme.dwFlags = TME_HOVER | TME_LEAVE; //Type of events to track & trigger.
        tme.dwHoverTime = HoverTime; //How long the mouse has to be in the window to trigger a hover event.
        tme.hwndTrack = hwnd;
        TrackMouseEvent(&tme);
    }

    static LRESULT CALLBACK WndProcButton(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        static POINT PreviousLocation, Location;
        static bool Tracking = false;
        static MouseButtons MBButtons;
        static bool blControl=false;
        static bool blShift=false;
        static bool blResize=false;
        static bool blnClick=false;
        static int xPos=0;
        static int yPos=0;
        static UINT_PTR timerid;
        static bool blnDrag=false;

        WNDPROC oldproc = (WNDPROC)GetProp(GetParent(hwnd), buttonpropname);
        if (oldproc == NULL)
            MessageBox(NULL, "oldprocnull", "oldprocnull", MB_OK);

        button *inst = (button*)GetProp(hwnd, buttonclassprop);
        if (inst == NULL && msg == WM_NCCREATE)
        {
            inst = (button*)(((LPCREATESTRUCT)lParam)->lpCreateParams);
            SetProp(hwnd, buttonclassprop, (HANDLE)inst);
        }

        if (inst == NULL)
            MessageBox(NULL, "instnull", "instnull", MB_OK);

        HBRUSH g_hbrBackground = NULL;

        //Working with messages
        switch(msg)
        {
           case WM_NOTIFY:
            {
                switch(HIWORD(wParam))
                {
                    case  BN_CLICKED:
                    {
                        MessageBox(NULL, TEXT("hello"),TEXT("hi"),MB_OK);
                    }
                    break;
                }
            }
            break;
      }

        //If oldproc is NULL then use DefWindowProc - but shouldn't be!
        return oldproc ? CallWindowProc(oldproc, hwnd, msg, wParam, lParam) : DefWindowProc(hwnd, msg, wParam, lParam);
    }

what's wrong with the WM_NOTIFY message? i even tried the WM_COMMAND :(
that message isn't activated :(
i event notice the WM_CREATE isn't activated too :(
Last edited on
Topic archived. No new replies allowed.