0030948: Configuration, CMake - problem building with CMake 3.15.2
[occt.git] / src / Draw / MainWindow.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 82a1efe..3e95c96
@@ -1,21 +1,30 @@
-// File:       MainWindow.cxx
-// Created:    Thu Aug  6 10:00:35 1998
-// Author:     Administrateur Atelier MDL
-//             <mdl@efalakox.paris1.matra-dtv.fr>
-
-
-
-#ifdef WNT
-
+// Created on: 1998-08-06
+// Created by: Administrateur Atelier MDL
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifdef _WIN32
 
 #include <windows.h>
 #include <DrawRessource.h>
 #include <init.h>
-#include <MainWindow.h>
 #include <Draw_Window.hxx>
+
+#include <MainWindow.h>
 #include <CommandWindow.h>
 
-Standard_Boolean Draw_Interprete(char* command); // Implemented in Draw.cxx
+Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
 extern Standard_Boolean Draw_IsConsoleSubsystem;
 
 //extern "C" int  compat_unlink(const char *fname); // Implemente dans TCL
@@ -25,35 +34,35 @@ extern Standard_Boolean Draw_IsConsoleSubsystem;
 |
 |
 \*--------------------------------------------------------*/
-LONG APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LONG lParam )
+LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
 {
-  HWND hWndClient;     
-  switch(wMsg)
+  switch (wMsg)
   {
-    case WM_CREATE :
+    case WM_CREATE:
+    {
+      CreateProc (hWndFrame);
+      HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
+      DrawWindow::hWndClientMDI = hWndClient;
+      if (!Draw_IsConsoleSubsystem)
       {
-       CreateProc(hWndFrame);                                  
-       hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
-       DrawWindow::hWndClientMDI = hWndClient;
-       if (!Draw_IsConsoleSubsystem)
-         CreateCommandWindow(hWndFrame,0);                                     
+        CreateCommandWindow (hWndFrame, 0);
       }
-      break;
-
-    case WM_COMMAND :
-      CommandProc(hWndFrame, wParam, lParam);
-      break;
-      
-    case WM_DESTROY :
-      Draw_Interprete("exit");
-      DestroyProc(hWndFrame);                                                          
-      break;
-
-    default :
-      hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
-      return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam));
+      return 0;
+    }
+    case WM_COMMAND:
+    {
+      CmdProc (hWndFrame, LOWORD(wParam), wParam, lParam);
+      return 0;
+    }
+    case WM_DESTROY:
+    {
+      Draw_Interprete ("exit");
+      DestroyProc (hWndFrame);
+      return 0;
+    }
   }
-  return(0l);
+  HWND hWndClient = (HWND)GetWindowLongPtrW(hWndFrame, CLIENTWND);
+  return DefFrameProcW(hWndFrame, hWndClient, wMsg, wParam, lParam);
 }
 
 
@@ -64,11 +73,12 @@ LONG APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LONG lParam )
 \*--------------------------------------------------------------------------*/
 BOOL CreateProc(HWND hWndFrame)
 {
-  HWND hWnd;
-
-  // Save hWnd in the main window in extra memory in 0
-  if (hWnd = CreateMDIClientWindow(hWndFrame))
-    SetWindowLong(hWndFrame, CLIENTWND, (LONG)hWnd);
+  HWND hWnd = CreateMDIClientWindow (hWndFrame);
+  if (hWnd != NULL)
+  {
+    // Save hWnd in the main window in extra memory in 0
+    SetWindowLongPtrW (hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
+  }
   return(TRUE);
 }
 
@@ -76,45 +86,56 @@ BOOL CreateProc(HWND hWndFrame)
 /*--------------------------------------------------------------------------*\
 |  COMMAND PROCEDURE
 |              Handler for message WM_COMMAND   
-|
+|     It is used when Draw_IsConsoleSubsystem = Standard_False
+|     i.e. in non-console mode (see Draw_main() in Draw_Main.cxx).
 \*--------------------------------------------------------------------------*/
-BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM lParam)
+LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*lParam*/)
 {
-  HWND hWndClient; // Handle on window MDI
-  HWND hWndActive;
-
-       hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
-  switch (LOWORD(wParam))
-       {
-         case IDM_WINDOW_NEXT :
-                                       if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
-                                         hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l);
-                                               SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l);  
-                                       break;
-
-               case IDM_WINDOW_CASCADE :
-                                       if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
-                                               SendMessage(hWndClient, WM_MDICASCADE, 0, 0l);
-                                       break;
-                                        
-               case IDM_WINDOW_TILEHOR :
-                                       if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
-                                               SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
-                                       break;
-
-               case IDM_WINDOW_TILEVERT :
-                                       if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
-                                               SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
-                                       break;
-               
-               case IDM_FILE_EXIT :
-                                       Draw_Interprete("exit");
-                                       //compat_unlink(NULL);
-
-                                       DestroyProc(hWndFrame);
-                                       break;
-       }
-  return(TRUE);
+  // Handle on window MDI
+  HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
+  switch (wMsg)
+  {
+    case IDM_WINDOW_NEXT:
+    {
+      if (hWndClient != NULL)
+      {
+        HWND hWndActive = (HWND )SendMessageW (hWndClient, WM_MDIGETACTIVE, 0, 0l);
+        SendMessageW (hWndClient, WM_MDINEXT, (WPARAM )hWndActive, 0l);
+      }
+      break;
+    }
+    case IDM_WINDOW_CASCADE:
+    {
+      if (hWndClient != NULL)
+      {
+        SendMessageW (hWndClient, WM_MDICASCADE, 0, 0l);
+      }
+      break;
+    }
+    case IDM_WINDOW_TILEHOR:
+    {
+      if (hWndClient != NULL)
+      {
+        SendMessageW (hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
+      }
+      break;
+    }
+    case IDM_WINDOW_TILEVERT:
+    {
+      if (hWndClient != NULL)
+      {
+        SendMessageW (hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
+      }
+      break;
+    }
+    case IDM_FILE_EXIT:
+    {
+      Draw_Interprete ("exit");
+      DestroyProc (hWndFrame);
+      break;
+    }
+  }
+  return 0;
 }
 
 
@@ -125,11 +146,8 @@ BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM lParam)
 \*--------------------------------------------------------------------------*/
 VOID DestroyProc(HWND hWnd)
 {
-#ifndef _WIN64
-  HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
-#else
-  HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE);
-#endif
+  HINSTANCE hInst = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
+
   Destroy_Appli(hInst);
   PostQuitMessage(0);
 }