 |
Dialog Icon.
If you're lazy, like me, and can't be bothered with all that 'RegisterClass' and
'CreateWindow' rubbish, or you want to create a window that's based on a dialog
box template (like most of the wizardy stuff that's about now) then you'll know
that as standard you just get the cacky little 'flying windows' icon. Here's how
you change it. The web demo applet's got a better example of this in it.
|   |
  |
 |
|   |
...
HICON hIcon
...
int WINAPI WinMain(...){
   ...
   hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON));
   DialogBox(...(FARPROC)DialogProc...);
   DestroyIcon(hIcon);
   ...
}
BOOL CALLBACK DialogProc(...){
   ...
     case WM_INITDIALOG:
       ...
       SetClassLong(hWnd,GCL_HICON,(LONG)hIcon);
       ...
     break;
   ...
}
...
|
  |
|   |
  |
  |
And that's all there is to it. Define a global icon handle, load this at the start of
WinMain and destroy it just before the end. Then, in each WM_INITDIALOG message handler
do a SetClassLong. Bargain. I think this might change the icon for all dialog windows
of the current task, never mind, you can't have everything can you.
|
  |