Search code examples
buttonhyperlinkbackgroundmfcmdi

MFC with active links or buttons as background in mainframe


I'm able to change the background of my MFC MDI application's mainframe, but I'm wondering if it's possible to add links or buttons to the background? Similar to what's possible with HTML Images and multiple links and create the effect of having tiles.


Solution

  • If you are looking for the same thing (which you referred) in MFC, you can do it by tracking the position of mouse pointer, but you can't create a button or link on the background. To track follow the step,

    1. Get the co-ordinates of the each logo and store it in individual CRect objects (as explained in the reference example).
    2. Listen to one of ON_WM_LBUTTONDOWN or ON_WM_LBUTTONUP message and track the mouse click event on OnLButtonDown() or OnLButtonUp() function accordingly.
    3. When the function is called, check whether the CPoint is inside the CRect using PtInRect() function.
    4. If the point lies inside any of the CRect objects the perform the operations accordingly.


    NOTE: Even it is possible to change the mouse pointer on hover the logo by listening to ON_WM_SETCURSOR message.