Click to See Complete Forum and Search --> : Icon in Dialog..
Code_Nerd
February 23rd, 2006, 04:33 PM
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?
Notsosuperhero
February 23rd, 2006, 04:37 PM
We need code to see if you did something wrong
Code_Nerd
February 23rd, 2006, 04:50 PM
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..
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... :)
Notsosuperhero
February 23rd, 2006, 05:08 PM
I think WM_INITDIALOG should return TRUE;
Code_Nerd
February 23rd, 2006, 05:18 PM
No sorry the dialog does not display at all then?
Code_Nerd
February 23rd, 2006, 10:36 PM
Sorted now.. ;)
ShelleyWang
February 24th, 2006, 11:44 PM
you should add message WM_PAINT in you AboutDlgProc as this:
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;
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.