davido@asylum.SF.CA.US (David Ornstein) (11/07/90)
I have a program which runs in the MDI style (IOW, it has a bunch of child windows in the main window which it uses to display "documents." These documents are actually graphical, and I want the iconized version of the child windows to look like a tiny bitmap that I can create for it so it looks like a shrunken of the current graphic. I spent about 5 hours today thrashing with PM and here's what I tried that didn't work. Help is greatly appreciated!!! Basically, I created a bitmap that I know represents a good bitmap for the icon. I've tried several bitmap sizes including 16x16 and 32x32. I can get the bitmap to display OK on the screen without any trouble. The problem comes when I try to create an icon from the bitmap. I use the WinCreatePointer() function which should take a bitmap handle and create a pointer. I set the parms so that it would create an icon-sized pointer (actually, I tried the flag both ways). I passed in the bitmap handle and got back an icon handle. The system clearly created an icon for me, because I can both see the icon if I display it with WinDrawPointer() and I appear to be succesfully associating the icon with the frame window for my child document window (when I minimize it, I get the same icon that I got with WinDrawPointer). The problem is that the bitmap is a mess. It has no recognizable structure. I've tried color and b&w bitmaps. Parts of the resulting icon appear to be transparent. The documentation does say something cryptic in the WinCreatePointer() call, that the bitmap supplied needs to "be logically divided into two sections vertically, each half representing one of the two images used as successive drawing masks for the pointer." Now I tried all sorts of things to guess at what they meant by this, including build a bunch of 0xFFs at the end of the bitmap, duplicating the buffer's first half in the second half, etc. All yielded dead ends. All of this leads me to assume that my use of WinCreatePointer() requires something that I don't know. HAS ANYBODY EVER USED THIS FUNCTION WITH ANY SUCCESS????????????? Help!!! David Ornstein Sage Software, Santa Clara, CA 408-988-7575 davido@ccgate.sage.com
lsalomo@hubcap.clemson.edu (lsalomo) (11/08/90)
Have you looked in Appendix B of the Tech Ref? The format for bitmaps, icons, and pointers is discussed there. An alternative way to do this, if I understand you correctly, is to draw the icon yourself once you realize you are being minimized. This is how the popular clock programs do it. If you'll notice, you need to subclass the frame IF THE WINDOW IS NOT A DIALOG BOX!!! If the window is a dialog box, cut the WM_PAINT from newFrameProc and paste it in your dialog proc. This is because dialog boxes are a cut-back subclassed frame. Notice that the frame sends a WM_MINMAXFRAME to the client telling it that it is being maximize, minimized, or restored. We could have intercepted it in newFrameProc, but I don't know how to do it that way. BOOL minimized; MRESULT EXPENTRY newFrameProc(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { switch (msg) { case WM_PAINT: if (minimized) { HPS hps; hps=WinBeginPaint(hwnd,NULL,NULL); /* Do your drawing here */ WinEndPaint(hps); return (MRESULT)FALSE; } /* endif */ break; default: break; } /* endswitch */ return (*oldFrameProc)(hwnd,msg,mp1,mp2); } MRESULT EXPENTRY myWinProc(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { switch (msg) { : : case WM_MINMAXFRAME: minimized=(((PSWP)mp1)->fs & SWP_MINIMIZE); break; : : default: return WinDefWindowProc(hwnd,msg,mp1,mp2); break; } /* endswitch */ return (MRESULT)FALSE; }