CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Posts
    148

    Icon in Dialog..

    I am trying to add my dialog icon as part of the dialog also.
    I am trying to do this with the dialog editor and using the "Picture Control" option..

    Anyway, when I go to view the dialog the icon does not appear?

    Anyone know how to do this?

    *EDIT* When I test the dialog the icon is displayed in the dialog, however when it is brought up from the menu the icon is not there? Is it a possibility I am calling the dialog incorrectly?

  2. #2
    Join Date
    Dec 2003
    Location
    Syracuse, NY
    Posts
    400

    Re: Icon in Dialog..

    We need code to see if you did something wrong
    "Windows programming is like going to the dentist: You know it's good for you, but no one likes doing it."
    - Andre LaMothe

    DLL For Beginners(UPDATED)
    Please use CODE tags
    Rate me if I've helped.

  3. #3
    Join Date
    Aug 2004
    Posts
    148

    Re: Icon in Dialog..

    Code:
    case WM_COMMAND:
    			switch(HIWORD(wparam))
    			{
                                      if(LOWORD(wparam) == IDM_ABOUT)
    					{
    						DialogBox(0,MAKEINTRESOURCE(IDD_ABOUTBOX),0,AboutDlgProc);
    					}
                            }
    That is a snippet where the dialog is selected..

    Code:
    INT_PTR CALLBACK AboutDlgProc( HWND hwnd , UINT msg , WPARAM wparam , LPARAM lparam)
    {
    	switch(msg)
    	{
    	case WM_INITDIALOG:
    		{
    			SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ADD)));
    		}
    		case WM_COMMAND:
    			switch(HIWORD(wparam))
    				{
    				case BN_CLICKED:
    					{
    						if(LOWORD(wparam) == IDOK)
    							EndDialog(hwnd,LOWORD(wparam));
    					}
    					if(LOWORD(wparam) == IDCANCEL)
    							EndDialog(hwnd,LOWORD(wparam));
    						break;
    				}
    			
    	}
    	return false;
    }
    That is the Dialog Procedure..

    Thanks for your help...

  4. #4
    Join Date
    Dec 2003
    Location
    Syracuse, NY
    Posts
    400

    Re: Icon in Dialog..

    I think WM_INITDIALOG should return TRUE;
    "Windows programming is like going to the dentist: You know it's good for you, but no one likes doing it."
    - Andre LaMothe

    DLL For Beginners(UPDATED)
    Please use CODE tags
    Rate me if I've helped.

  5. #5
    Join Date
    Aug 2004
    Posts
    148

    Re: Icon in Dialog..

    No sorry the dialog does not display at all then?

  6. #6
    Join Date
    Aug 2004
    Posts
    148

    Re: Icon in Dialog..

    Sorted now..

  7. #7
    Join Date
    Dec 2003
    Posts
    45

    Re: Icon in Dialog..

    you should add message WM_PAINT in you AboutDlgProc as this:
    Code:
    	case WM_PAINT:
    		{
    			HDC hdc;
    			PAINTSTRUCT ps;
    
    			hdc = BeginPaint(hwnd, &ps);
    			HANDLE hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
    			DrawIconEx(hdc, 25, 40, (HICON)hIcon, 32, 32, 0, NULL, DI_IMAGE | DI_MASK);
    			DestroyIcon((HICON)hIcon);
    
    			EndPaint(hwnd, &ps);
    		}
    		break;

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

Featured