home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xlib_PMWM.c < prev    next >
C/C++ Source or Header  |  1999-11-02  |  2KB  |  85 lines

  1.  
  2. #include "Xlib_private.h"
  3.  
  4. #define UM_UNMAP (WM_USER+10)
  5. #define UM_MAP (WM_USER+11)
  6.  
  7. MRESULT EXPENTRY xpmframeproc(HWND, ULONG, MPARAM, MPARAM);
  8.  
  9. int Xlib_PMWM_Handler0(HWND* hWnd, ULONG* msg, MPARAM* mp1, MPARAM* mp2)
  10. {
  11.     if (msg && mp1) switch(*msg) {
  12.     case UM_SetWindowPos:
  13.     {
  14.         SWP oldswp;
  15.         HWND parent;
  16.         Xlib_SetWindowPos *args = PVOIDFROMMP(*mp1);
  17.         if (!args) break;
  18.  
  19.         parent = WinQueryWindow( args->hwnd, QW_PARENT );
  20.         WinQueryWindowPos( args->hwnd, &oldswp );
  21.  
  22.         if (parent == hwndDesktop) {
  23.             int cyscreen = WinQuerySysValue(hwndDesktop, SV_CYSCREEN);
  24.             int y, cy;
  25.             if (args->fl & SWP_MOVE) y = args->y; else y = oldswp.y;
  26.             if (args->fl & SWP_SIZE) cy = args->cy; else cy = oldswp.cy;
  27.             if (cy > cyscreen) {
  28.                 args->cy = cyscreen;
  29.                 if (!(args->fl & SWP_SIZE)) {
  30.                     args->cx = oldswp.cx;
  31.                     args->fl |= SWP_SIZE;
  32.                 }
  33.             }
  34.             if (y + cy > cyscreen) {
  35.                 args->y = cyscreen - cy;
  36.                 if (!(args->fl & SWP_MOVE)) {
  37.                     args->x = oldswp.x;
  38.                     args->fl |= SWP_MOVE;
  39.                 }
  40.             }
  41.         }
  42.  
  43.         if (args->fl & SWP_MOVE && args->x == oldswp.x && args->y == oldswp.y)
  44.             args->fl &= ~SWP_MOVE;
  45.         if (args->fl & SWP_SIZE && args->cx == oldswp.cx && args->cy == oldswp.cy)
  46.             args->fl &= ~SWP_SIZE;
  47.  
  48.         break;
  49.     }
  50.     default:
  51.         break;
  52.     }
  53.     return 0;
  54. }
  55.  
  56. int Xlib_PMWM_Handler1(HWND* hWnd, ULONG* msg, MPARAM* mp1, MPARAM* mp2)
  57. {
  58.     if(msg && mp1) switch(*msg) {
  59.     case UM_ChangeProperty:
  60.         {
  61.             Xlib_ChangeProperty *args = PVOIDFROMMP(mp1);
  62.             WinAttribData *attrib = WinQueryWindowPtr(args->w, QWP_WINATTRIB);
  63.  
  64.            if (args->property == XA_WM_ICON_NAME && args->type == XA_STRING) {
  65.                 HPOINTER tmpicon;
  66.                 HWND hwndframe = WinQueryWindowULong((HWND)args->w, QWP_FRAMEHWND);
  67.  
  68.                 if(hwndframe && attrib->wm_iconname)
  69.                 {
  70.                     char *newname = malloc(strlen(attrib->wm_iconname)+5);
  71.  
  72.                     strcpy(newname, attrib->wm_iconname);
  73.                     strcat(newname, ".ico");
  74.                     /* May need to search a path of some sort */
  75.                     if(tmpicon = WinLoadFileIcon(newname, FALSE))
  76.                         WinSendMsg(hwndframe, WM_SETICON, (MPARAM)tmpicon, 0);
  77.                     free(newname);
  78.                 }
  79.             }
  80.         }
  81.         break;
  82.     }
  83.     return 0;
  84. }
  85.