There already is API for this reason....
Use the following message "nMsg" that is broadcasted to all toplevel windows, in order to receive BOSS mode changes
code:
MessengerPlus_ModeChange
wParam = 1 for boss-protect, 2 for lock messenger
lParam = 1 when entering mode, 0 when leavingmode
UINT nMsg = RegisterWindowMessage("MessengerPlus_ModeChange");