hook: how can i get the checkbox state?

i'm changing some MessageBox() options.
using a hook procedure:
1
2
3
SetWindowsHookEx(WH_CBT,
                                MsgBoxHook,
                                GetModuleHandle(NULL), GetCurrentThreadId());

i add a checkbox without window 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
61
62
63
64
bool blnMessageBoxCheckBox=false;
LRESULT CALLBACK MsgBoxHook(int nCode, WPARAM wParam, LPARAM lParam)
{


    if(nCode==HCBT_ACTIVATE)//center the text on STATIC child control

    {
        
        HWND CheckBox;
        //checking the checkbox stated
        UINT t=SendMessage(CheckBox,BM_GETCHECK,0, 0);

        if(t==BST_CHECKED)
            blnMessageBoxCheckBox=true;
        else
            blnMessageBoxCheckBox=false;
        HWND hwnd = (HWND)wParam;
        HWND hwnd2 = FindWindowEx(hwnd, NULL,"STATIC",NULL);
        if (hwnd2!=NULL && (MGBEXTENDED & MB_EX_TEXTCENTER))
        {
            SetWindowLong(hwnd2, GWL_STYLE, GetWindowLong(hwnd2, GWL_STYLE) | SS_CENTER);
            //MessageBox(NULL, to_string(GetLastError()).c_str(), "error", MB_OK);
        }
        if (((GetWindowLong(hwnd, GWL_STYLE) & WS_DLGFRAME) || (GetWindowLong(hwnd, GWL_STYLE) & WS_POPUP)) && hwnd2!=NULL)
        {
            //creating a checkbox and set it's state, depending on last value
            RECT a;
            GetClientRect(hwnd,&a);
            CheckBox = CreateWindowEx(NULL, "BUTTON", "Hel&lo",
                WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_TEXT,
                2, 50, a.right-a.left-4, 15, hwnd, NULL, GetModuleHandle(NULL), NULL);
            HFONT g_hfFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessage(CheckBox, WM_SETFONT,(WPARAM) g_hfFont, TRUE);
            if(blnMessageBoxCheckBox==true)
                SendMessage(CheckBox,BM_SETCHECK,(WPARAM)BST_CHECKED, TRUE);
        }

    }
    else if (nCode == HCBT_CREATEWND)//center the messagebox on it's parent
    {
        CREATESTRUCT *pcs = ((CBT_CREATEWND *)lParam)->lpcs;

        if ((pcs->style & WS_DLGFRAME) || (pcs->style & WS_POPUP))
        {
            HWND hwnd = (HWND)wParam;

            // At this point you have the hwnd of the newly created
            // message box that so you can position it at will
            //SendMessage(hwnd, WM_SETA ,(WPARAM) font, TRUE)
            if(MGBEXTENDED & MB_EX_PARENTCENTER)
            {
                RECT parentrct;
                GetWindowRect(ActivatedForm,&parentrct);
                LONG x=parentrct.left+(parentrct.right-parentrct.left)/2 - pcs->cx/2;
                LONG y=parentrct.top+(parentrct.bottom-parentrct.top)/2 - pcs->cy/2;
                pcs->x=x;
                pcs->y=y;
            }
        }
    }

  return (CallNextHookEx(hhookCBTProc, nCode, wParam, lParam));
}

maybe i miss some nCode. i have tryied some without sucess. can anyone advice me how can i get the checkbox state?
Topic archived. No new replies allowed.