Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Add drop shadow to a child dialog

Add drop shadow to a child dialog

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dSolariuM
    wrote on last edited by
    #1

    Hi, I want to add drop shadow to a child window... please help me. thank you.

    Every new thing you learn,Gives you a new personality.

    S 1 Reply Last reply
    0
    • D dSolariuM

      Hi, I want to add drop shadow to a child window... please help me. thank you.

      Every new thing you learn,Gives you a new personality.

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      I will assume you're using MFC:

      BOOL CShadowDlg::OnInitDialog()
      {
      CDialog::OnInitDialog();

      // Add "About..." menu item to system menu.
      
      // IDM\_ABOUTBOX must be in the system command range.
      ASSERT((IDM\_ABOUTBOX & 0xFFF0) == IDM\_ABOUTBOX);
      ASSERT(IDM\_ABOUTBOX < 0xF000);
      
      CMenu\* pSysMenu = GetSystemMenu(FALSE);
      if (pSysMenu != NULL)
      {
      	CString strAboutMenu;
      	strAboutMenu.LoadString(IDS\_ABOUTBOX);
      	if (!strAboutMenu.IsEmpty())
      	{
      		pSysMenu->AppendMenu(MF\_SEPARATOR);
      		pSysMenu->AppendMenu(MF\_STRING, IDM\_ABOUTBOX, strAboutMenu);
      	}
      }
      
      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m\_hIcon, TRUE);			// Set big icon
      SetIcon(m\_hIcon, FALSE);		// Set small icon
      
      // TODO: Add extra initialization here
      **::SetClassLong(
      	GetSafeHwnd(),
      	GCL\_STYLE,
      	::GetClassLong(GetSafeHwnd(), GCL\_STYLE) | CS\_DROPSHADOW/\*0x00020000\*/
      	);**
      
      return TRUE;  // return TRUE  unless you set the focus to a control
      

      }

      Note that CS_DROPSHADOW requires a Windows version >= XP. Note that after this code is run ALL dialogs will have shadows!

      Steve

      N B 2 Replies Last reply
      0
      • S Stephen Hewitt

        I will assume you're using MFC:

        BOOL CShadowDlg::OnInitDialog()
        {
        CDialog::OnInitDialog();

        // Add "About..." menu item to system menu.
        
        // IDM\_ABOUTBOX must be in the system command range.
        ASSERT((IDM\_ABOUTBOX & 0xFFF0) == IDM\_ABOUTBOX);
        ASSERT(IDM\_ABOUTBOX < 0xF000);
        
        CMenu\* pSysMenu = GetSystemMenu(FALSE);
        if (pSysMenu != NULL)
        {
        	CString strAboutMenu;
        	strAboutMenu.LoadString(IDS\_ABOUTBOX);
        	if (!strAboutMenu.IsEmpty())
        	{
        		pSysMenu->AppendMenu(MF\_SEPARATOR);
        		pSysMenu->AppendMenu(MF\_STRING, IDM\_ABOUTBOX, strAboutMenu);
        	}
        }
        
        // Set the icon for this dialog.  The framework does this automatically
        //  when the application's main window is not a dialog
        SetIcon(m\_hIcon, TRUE);			// Set big icon
        SetIcon(m\_hIcon, FALSE);		// Set small icon
        
        // TODO: Add extra initialization here
        **::SetClassLong(
        	GetSafeHwnd(),
        	GCL\_STYLE,
        	::GetClassLong(GetSafeHwnd(), GCL\_STYLE) | CS\_DROPSHADOW/\*0x00020000\*/
        	);**
        
        return TRUE;  // return TRUE  unless you set the focus to a control
        

        }

        Note that CS_DROPSHADOW requires a Windows version >= XP. Note that after this code is run ALL dialogs will have shadows!

        Steve

        N Offline
        N Offline
        nitin3
        wrote on last edited by
        #3

        Is it possible to set drop shadow for controls ?

        S 1 Reply Last reply
        0
        • N nitin3

          Is it possible to set drop shadow for controls ?

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          I don't think so. You could always implement this functionality yourself however.

          Steve

          1 Reply Last reply
          0
          • S Stephen Hewitt

            I will assume you're using MFC:

            BOOL CShadowDlg::OnInitDialog()
            {
            CDialog::OnInitDialog();

            // Add "About..." menu item to system menu.
            
            // IDM\_ABOUTBOX must be in the system command range.
            ASSERT((IDM\_ABOUTBOX & 0xFFF0) == IDM\_ABOUTBOX);
            ASSERT(IDM\_ABOUTBOX < 0xF000);
            
            CMenu\* pSysMenu = GetSystemMenu(FALSE);
            if (pSysMenu != NULL)
            {
            	CString strAboutMenu;
            	strAboutMenu.LoadString(IDS\_ABOUTBOX);
            	if (!strAboutMenu.IsEmpty())
            	{
            		pSysMenu->AppendMenu(MF\_SEPARATOR);
            		pSysMenu->AppendMenu(MF\_STRING, IDM\_ABOUTBOX, strAboutMenu);
            	}
            }
            
            // Set the icon for this dialog.  The framework does this automatically
            //  when the application's main window is not a dialog
            SetIcon(m\_hIcon, TRUE);			// Set big icon
            SetIcon(m\_hIcon, FALSE);		// Set small icon
            
            // TODO: Add extra initialization here
            **::SetClassLong(
            	GetSafeHwnd(),
            	GCL\_STYLE,
            	::GetClassLong(GetSafeHwnd(), GCL\_STYLE) | CS\_DROPSHADOW/\*0x00020000\*/
            	);**
            
            return TRUE;  // return TRUE  unless you set the focus to a control
            

            }

            Note that CS_DROPSHADOW requires a Windows version >= XP. Note that after this code is run ALL dialogs will have shadows!

            Steve

            B Offline
            B Offline
            balaji167
            wrote on last edited by
            #5

            I used this in my dialog, After that try to hide the dialog, Dialog is hiding but the shadow is not hiding. I am using ShowWindow(SW_HIDE).

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups