Esempio n. 1
0
static LRESULT CALLBACK winDialogMDIChildProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    LRESULT result;
    Ihandle *ih = iupwinHandleGet(hwnd);
    if (!ih)
    {
        /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
        if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
        {
            if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
                return 0;
        }

        return DefMDIChildProc(hwnd, msg, wp, lp);
    }

    if (msg == WM_MDIACTIVATE)
    {
        HWND hNewActive = (HWND)lp;
        if (hNewActive == ih->handle)
        {
            Icallback cb = (Icallback)IupGetCallback(ih, "MDIACTIVATE_CB");
            if (cb) cb(ih);
        }
    }

    if (winDialogBaseProc(ih, msg, wp, lp, &result))
        return result;

    return DefMDIChildProc(hwnd, msg, wp, lp);
}
Esempio n. 2
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    LRESULT result;
    HWND hWndClient = NULL;
    Ihandle *ih = iupwinHandleGet(hwnd);
    if (!ih)
    {
        /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
        if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
        {
            if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
                return 0;
        }

        return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
    }

    {
        Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
        if (client) hWndClient = client->handle;
    }

    if (winDialogBaseProc(ih, msg, wp, lp, &result))
        return result;

    if (msg == WM_MENUCOMMAND)
    {
        int menuId = GetMenuItemID((HMENU)lp, (int)wp);
        if (menuId >= IUP_MDI_FIRSTCHILD && hWndClient)
        {
            /* we manually activate the MDI child when its menu item is selected. */
            HWND hChild = GetDlgItem(hWndClient, menuId);
            if (hChild)
                SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)hChild, 0);
        }
        else if (menuId >= SC_SIZE && menuId <= SC_CONTEXTHELP)
        {
            /* we manually forward the message to the MDI child */
            HWND hChild = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0);
            if (hChild)
                SendMessage(hChild, WM_SYSCOMMAND, (WPARAM)menuId, 0);
        }
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}
Esempio n. 3
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{   
  LRESULT result;
  HWND hWndClient = NULL;
  Ihandle *ih = iupwinHandleGet(hwnd); 
  if (!ih)
  {
    /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
    if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
    {
      if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
        return 0;
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
  }

  {
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (client) hWndClient = client->handle;
  }

  if (winDialogBaseProc(ih, msg, wp, lp, &result))
    return result;

  switch (msg)
  {
  case WM_MENUCOMMAND:
    {
      int menuId = GetMenuItemID((HMENU)lp, (int)wp);
      if (menuId >= IUP_MDICHILD_START && hWndClient)
      {
        Ihandle* child = winDialogGetMdiChildId(ih, menuId-IUP_MDICHILD_START);
        if (child)
          SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)child->handle, 0);
        break;
      }
    }
  }


  return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}
Esempio n. 4
0
static LRESULT CALLBACK winDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    LRESULT result;
    Ihandle *ih = iupwinHandleGet(hwnd);
    if (!ih)
    {
        /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
        if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
        {
            if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
                return 0;
        }

        return DefWindowProc(hwnd, msg, wp, lp);
    }

    if (winDialogBaseProc(ih, msg, wp, lp, &result))
        return result;

    return DefWindowProc(hwnd, msg, wp, lp);
}
Esempio n. 5
0
static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
    if (iupwinBaseContainerProc(ih, msg, wp, lp, result))
        return 1;

    iupwinMenuDialogProc(ih, msg, wp, lp);

    switch (msg)
    {
    case WM_GETMINMAXINFO:
    {
        if (winDialogCheckMinMaxInfo(ih, (MINMAXINFO*)lp))
        {
            *result = 0;
            return 1;
        }
        break;
    }
    case WM_MOVE:
    {
        IFnii cb = (IFnii)IupGetCallback(ih, "MOVE_CB");
        int x, y;
        /* ignore LPARAM because they are the clientpos */
        iupdrvDialogGetPosition(ih, NULL, &x, &y);
        if (cb) cb(ih, x, y);
        break;
    }
    case WM_SIZE:
    {
        if (ih->data->ignore_resize)
            break;

        switch(wp)
        {
        case SIZE_MINIMIZED:
        {
            if (ih->data->show_state != IUP_MINIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_MINIMIZE;
                if (show_cb && show_cb(ih, IUP_MINIMIZE) == IUP_CLOSE)
                    IupExitLoop();
            }
            break;
        }
        case SIZE_MAXIMIZED:
        {
            if (ih->data->show_state != IUP_MAXIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_MAXIMIZE;
                if (show_cb && show_cb(ih, IUP_MAXIMIZE) == IUP_CLOSE)
                    IupExitLoop();
            }

            winDialogResize(ih, LOWORD(lp), HIWORD(lp));

            if (iupAttribGetBoolean(ih, "MDICHILD"))
            {
                /* WORKAROUND: when a child MDI dialog is maximized,
                   its title is displayed inside the MDI client area.
                   So we force a MDI client size update */
                RECT rect;
                Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
                GetClientRect(client->handle, &rect);
                PostMessage(client->handle, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(rect.right-rect.left, rect.bottom-rect.top));
            }
            break;
        }
        case SIZE_RESTORED:
        {
            if (ih->data->show_state == IUP_MAXIMIZE || ih->data->show_state == IUP_MINIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_RESTORE;
                if (show_cb && show_cb(ih, IUP_RESTORE) == IUP_CLOSE)
                    IupExitLoop();
            }

            winDialogResize(ih, LOWORD(lp), HIWORD(lp));
            break;
        }
        }

        if (iupAttribGetBoolean(ih, "MDIFRAME"))
        {
            /* We are going to manually position the MDI client,
               so abort MDI frame processing. */
            *result = 0;
            return 1;
        }
        else
            break;
    }
    case WM_USER+IUPWIN_TRAY_NOTIFICATION:
    {
        int dclick  = 0;
        int button  = 0;
        int pressed = 0;

        switch (lp)
        {
        case WM_LBUTTONDOWN:
            pressed = 1;
            button  = 1;
            break;
        case WM_MBUTTONDOWN:
            pressed = 1;
            button  = 2;
            break;
        case WM_RBUTTONDOWN:
            pressed = 1;
            button  = 3;
            break;
        case WM_LBUTTONDBLCLK:
            dclick = 1;
            button = 1;
            break;
        case WM_MBUTTONDBLCLK:
            dclick = 1;
            button = 2;
            break;
        case WM_RBUTTONDBLCLK:
            dclick = 1;
            button = 3;
            break;
        case WM_LBUTTONUP:
            button = 1;
            break;
        case WM_MBUTTONUP:
            button = 2;
            break;
        case WM_RBUTTONUP:
            button = 3;
            break;
        }

        if (button != 0)
        {
            IFniii cb = (IFniii)IupGetCallback(ih, "TRAYCLICK_CB");
            if (cb && cb(ih, button, pressed, dclick) == IUP_CLOSE)
                IupExitLoop();
        }

        break;
    }
    case WM_CLOSE:
    {
        Icallback cb = IupGetCallback(ih, "CLOSE_CB");
        if (cb)
        {
            int ret = cb(ih);
            if (ret == IUP_IGNORE)
            {
                *result = 0;
                return 1;
            }
            if (ret == IUP_CLOSE)
                IupExitLoop();
        }

        /* child mdi is automatically destroyed */
        if (iupAttribGetBoolean(ih, "MDICHILD"))
            IupDestroy(ih);
        else
        {
            if (!winDialogMDICloseChildren(ih))
            {
                *result = 0;
                return 1;
            }

            IupHide(ih); /* IUP default processing */
        }

        *result = 0;
        return 1;
    }
    case WM_COPYDATA:  /* usually from SetGlobal("SINGLEINSTANCE") */
    {
        COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lp;
        IFnsi cb = (IFnsi)IupGetCallback(ih, "COPYDATA_CB");
        if (cb) cb(ih, cds->lpData, cds->cbData);
        break;
    }
    case WM_SETCURSOR:
    {
        if (ih->handle == (HWND)wp && LOWORD(lp)==HTCLIENT)
        {
            HCURSOR hCur = (HCURSOR)iupAttribGet(ih, "_IUPWIN_HCURSOR");
            if (hCur)
            {
                SetCursor(hCur);
                *result = 1;
                return 1;
            }
            else if (iupAttribGet(ih, "CURSOR"))
            {
                SetCursor(NULL);
                *result = 1;
                return 1;
            }
        }
        break;
    }
    case WM_ERASEBKGND:
    {
        HBITMAP hBitmap = (HBITMAP)iupAttribGet(ih, "_IUPWIN_BACKGROUND_BITMAP");
        if (hBitmap)
        {
            RECT rect;
            HDC hdc = (HDC)wp;

            HBRUSH hBrush = CreatePatternBrush(hBitmap);
            GetClientRect(ih->handle, &rect);
            FillRect(hdc, &rect, hBrush);
            DeleteObject(hBrush);

            /* return non zero value */
            *result = 1;
            return 1;
        }
        else
        {
            unsigned char r, g, b;
            char* color = iupAttribGet(ih, "_IUPWIN_BACKGROUND_COLOR");
            if (iupStrToRGB(color, &r, &g, &b))
            {
                RECT rect;
                HDC hdc = (HDC)wp;

                SetDCBrushColor(hdc, RGB(r,g,b));
                GetClientRect(ih->handle, &rect);
                FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));

                /* return non zero value */
                *result = 1;
                return 1;
            }
        }
        break;
    }
    case WM_DESTROY:
    {
        /* Since WM_CLOSE changed the Windows default processing                            */
        /* WM_DESTROY is NOT received by IupDialogs                                         */
        /* Except when they are children of other IupDialogs and the parent is destroyed.   */
        /* So we have to destroy the child dialog.                                          */
        /* The application is responsable for destroying the children before this happen.   */
        IupDestroy(ih);
        break;
    }
    }

    if (msg == (UINT)WM_HELPMSG)
    {
        Ihandle* child = NULL;
        DWORD* struct_ptr = (DWORD*)lp;
        if (*struct_ptr == sizeof(CHOOSECOLOR))
        {
            CHOOSECOLOR* choosecolor = (CHOOSECOLOR*)lp;
            child = (Ihandle*)choosecolor->lCustData;
        }
        if (*struct_ptr == sizeof(CHOOSEFONT))
        {
            CHOOSEFONT* choosefont = (CHOOSEFONT*)lp;
            child = (Ihandle*)choosefont->lCustData;
        }

        if (child)
        {
            Icallback cb = IupGetCallback(child, "HELP_CB");
            if (cb && cb(child) == IUP_CLOSE)
                EndDialog((HWND)iupAttribGet(child, "HWND"), IDCANCEL);
        }
    }

    return 0;
}
Esempio n. 6
0
static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
  if (iupwinBaseContainerProc(ih, msg, wp, lp, result))
    return 1;

  iupwinMenuDialogProc(ih, msg, wp, lp);

  switch (msg)
  {
  case WM_GETDLGCODE:
    *result = DLGC_WANTALLKEYS;
    return 1;
  case WM_GETMINMAXINFO:
    {
      if (winDialogCheckMinMaxInfo(ih, (MINMAXINFO*)lp))
      {
        *result = 0;
        return 1;
      }
      break;
    }
  case WM_SIZE:
    {
      if (ih->data->ignore_resize)
        break;

      switch(wp)
      {
      case SIZE_MINIMIZED:
        {
          if (ih->data->show_state != IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_MINIMIZE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_MINIMIZE;
          }
          break;
        }
      case SIZE_MAXIMIZED:
        {
          if (ih->data->show_state != IUP_MAXIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_MAXIMIZE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_MAXIMIZE;
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));
          break;
        }
      case SIZE_RESTORED:
        {
          if (ih->data->show_state == IUP_MAXIMIZE || ih->data->show_state == IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_RESTORE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_RESTORE;
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));
          break;
        }
      }

      break;
    }
  case WM_USER+IWIN_TRAY_NOTIFICATION:
    {
      int dclick  = 0;
      int button  = 0;
      int pressed = 0;

      switch (lp)
      {
      case WM_LBUTTONDOWN:
        pressed = 1;
        button  = 1;
        break;
      case WM_MBUTTONDOWN:
        pressed = 1;
        button  = 2;
        break;
      case WM_RBUTTONDOWN:
        pressed = 1;
        button  = 3;
        break;
      case WM_LBUTTONDBLCLK:
        dclick = 1;
        button = 1;
        break;
      case WM_MBUTTONDBLCLK:
        dclick = 1;
        button = 2;
        break;
      case WM_RBUTTONDBLCLK:
        dclick = 1;
        button = 3;
        break;
      case WM_LBUTTONUP:
        button = 1;
        break;
      case WM_MBUTTONUP:
        button = 2;
        break;
      case WM_RBUTTONUP:
        button = 3;
        break;
      }

      if (button != 0)
      {
        IFniii cb = (IFniii)IupGetCallback(ih, "TRAYCLICK_CB");
        if (cb && cb(ih, button, pressed, dclick) == IUP_CLOSE)
          IupExitLoop();
      }

      break;
    }
  case WM_CLOSE:
    {
      Icallback cb = IupGetCallback(ih, "CLOSE_CB");
      if (cb)
      {
        int ret = cb(ih);
        if (ret == IUP_IGNORE)
        {
          *result = 0;
          return 1;
        }
        if (ret == IUP_CLOSE)
          IupExitLoop();
      }

      /* child mdi is automatically destroyed */
      if (iupAttribGetInt(ih, "MDICHILD"))
        IupDestroy(ih);
      else
      {
        if (!winDialogMDICloseChildren(ih))
        {
          *result = 0;
          return 1;
        }

        IupHide(ih); /* IUP default processing */
      }

      *result = 0;
      return 1;
    }
  case WM_SETCURSOR: 
    { 
      if (ih->handle == (HWND)wp && LOWORD(lp)==HTCLIENT)
      {
        HCURSOR hCur = (HCURSOR)iupAttribGet(ih, "_IUPWIN_HCURSOR");
        if (hCur)
        {
          SetCursor(hCur); 
          *result = 1;
          return 1;
        }
        else if (iupAttribGet(ih, "CURSOR"))
        {
          SetCursor(NULL); 
          *result = 1;
          return 1;
        }
      }
      break; 
    } 
  case WM_ERASEBKGND:
    {
      HBITMAP hBitmap = (HBITMAP)iupAttribGet(ih, "_IUPWIN_BACKGROUND_BITMAP");
      if (hBitmap) 
      {
        RECT rect;
        HDC hdc = (HDC)wp;

        HBRUSH hBrush = CreatePatternBrush(hBitmap);
        GetClientRect(ih->handle, &rect); 
        FillRect(hdc, &rect, hBrush); 
        DeleteObject(hBrush);

        /* return non zero value */
        *result = 1;
        return 1; 
      }
      else
      {
        unsigned char r, g, b;
        char* color = iupAttribGet(ih, "_IUPWIN_BACKGROUND_COLOR");
        if (iupStrToRGB(color, &r, &g, &b))
        {
          RECT rect;
          HDC hdc = (HDC)wp;

          SetDCBrushColor(hdc, RGB(r,g,b));
          GetClientRect(ih->handle, &rect); 
          FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH)); 

          /* return non zero value */
          *result = 1;
          return 1;
        }
      }
      break;
    }
  case WM_DESTROY:
    {
      /* Since WM_CLOSE changed the Windows default processing                            */
      /* WM_DESTROY is NOT received by IupDialogs                                         */
      /* Except when they are children of other IupDialogs and the parent is destroyed.   */
      /* So we have to destroy the child dialog.                                          */
      /* The application is responsable for destroying the children before this happen.   */
      IupDestroy(ih);
      break;
    }
  }

  if (msg == (UINT)WM_HELPMSG)
  {
    Ihandle* child = NULL;
    DWORD* struct_ptr = (DWORD*)lp;
    if (*struct_ptr == sizeof(CHOOSECOLOR))
    {
      CHOOSECOLOR* choosecolor = (CHOOSECOLOR*)lp;
      child = (Ihandle*)choosecolor->lCustData;
    }
    if (*struct_ptr == sizeof(CHOOSEFONT))
    {
      CHOOSEFONT* choosefont = (CHOOSEFONT*)lp;
      child = (Ihandle*)choosefont->lCustData;
    }

    if (child)
    {
      Icallback cb = IupGetCallback(child, "HELP_CB");
      if (cb && cb(child) == IUP_CLOSE)
        EndDialog((HWND)iupAttribGet(child, "HWND"), IDCANCEL);
    }
  }

  return 0;
}