Results 1 to 5 of 5

Thread: icon of dialog

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Posts
    41

    icon of dialog

    just new to MFC...... I couldn't put an icon to a dialog box( CMyDlg:CDlg)......like icon of the form in Vb....can you tell me?

    Thanks.

  2. #2
    amac
    Guest
    In the OnCreate() message handler you can use CWnd::SetIcon()

    The dialog class, CDialog, is derived from CWnd... if you didn't know...

    so you could just do this

    Code:
    int CAboutDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    
        if (CDialog::OnCreate(lpCreateStruct) == -1)
            return -1;
    
        SetIcon( LoadIcon( IDI_SMALLICON ), FALSE );	
        SetIcon( LoadIcon( IDI_BIGICON ), TRUE );
    	
        return 0;
    
    }

    If this doesn't work, try putting it in the OnInitDialog() message handler.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2001
    Posts
    41
    I tried but can only display standard icon by this:
    ........
    SetIcon( LoadIcon( NULL, IDI_ASTERISK), TRUE );
    ........

    when I changed it to my icon:
    SetIcon( LoadIcon( NULL, MAKEINTRESOURCE(IDI_ICON1)), TRUE );
    nothing is display there. why?

    Thanks lot.

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Anyone have an answer to this?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Pass your resource handle instead of NULL. Something like AfxGetApp()->hResource
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width