remove all borders

 
Hi there, i found this script to remove all windows borders.
But infortunately, it does not work.

Can you please help me (or fix it for the community) ?
Regards

//#property script_show_inputs
#import "user32.dll"
  int SetWindowLongA(int hWnd,int nIndex, int dwNewLong);
  int GetWindowLongA(int hWnd,int nIndex);
  int SetWindowPos(int hWnd, int hWndInsertAfter,int X, int Y, int cx, int cy, int uFlags);
  int GetParent(int hWnd);
  int GetTopWindow(int hWnd);
  int GetWindow(int hWnd, int wCmd);
#import

#define GWL_STYLE         -16 
#define WS_CAPTION        0x00C00000 
#define WS_BORDER         0x00800000
#define WS_SIZEBOX        0x00040000
#define WS_DLGFRAME       0x00400000
#define SWP_NOSIZE        0x0001
#define SWP_NOMOVE        0x0002
#define SWP_NOZORDER      0x0004
#define SWP_NOACTIVATE    0x0010
#define SWP_FRAMECHANGED  0x0020
#define GW_CHILD          0x0005
#define GW_HWNDNEXT       0x0002

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int OnStart() 
{
   int hChartParent = GetParent((int)ChartGetInteger(ChartID(), CHART_WINDOW_HANDLE));    
   int hMDIClient = GetParent(hChartParent); 
   int hChildWindow = GetTopWindow(hMDIClient);
   while (hChildWindow > 0)
   {
      RemoveBorderByWindowHandle(hChildWindow);
      hChildWindow = GetWindow(hChildWindow, GW_HWNDNEXT);
   }
 
   
   return(0);
}
void RemoveBorderByWindowHandle(int hWindow)
{
   int iNewStyle = (int)(GetWindowLongA(hWindow, GWL_STYLE) & (~(WS_BORDER | WS_DLGFRAME | WS_SIZEBOX)));    
   if (hWindow>0 && iNewStyle>0) 
   {
      SetWindowLongA(hWindow, GWL_STYLE, iNewStyle);
      SetWindowPos(hWindow,0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
   }
}
 
Hello, have you fixed the script? I have the same problem.
 
dzmitry.zimin #:
Hello, have you fixed the script? I have the same problem.

No, I didn't tried yet.

 

without specific error messages or behaviors described, troubleshooting can be a bit generic

any else information?

 
Nguyen An Nguyen #:

without specific error messages or behaviors described, troubleshooting can be a bit generic

any else information?

No error , nothing.
It just does not work.

 
this script version works for single instrument in maximized mode.... (MT5 ONLY)

---

//+------------------------------------------------------------------+
//|                                                RemoveBorders.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property script_show_inputs

//--- Importação da DLL User32 para 64-bits (MT5)
#import "user32.dll"
   long GetParent(long hWnd);
   long GetWindowLongPtrW(long hWnd, int nIndex);
   long SetWindowLongPtrW(long hWnd, int nIndex, long dwNewLong);
   bool SetWindowPos(long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
#import

//--- Constantes de Estilo de Janela (Win32 API)
#define GWL_STYLE          -16
#define WS_CAPTION         0x00C00000 // Barra de título
#define WS_THICKFRAME      0x00040000 // Borda redimensionável
#define WS_SYSMENU         0x00080000 // Botões X, min, max
#define WS_MINIMIZEBOX     0x00020000
#define WS_MAXIMIZEBOX     0x00010000
#define WS_BORDER          0x00800000 
#define WS_DLGFRAME        0x00400000

//--- Flags para SetWindowPos
#define SWP_NOSIZE         0x0001
#define SWP_NOMOVE         0x0002
#define SWP_NOZORDER       0x0004
#define SWP_NOACTIVATE     0x0010
#define SWP_FRAMECHANGED   0x0020 // Força o recálculo da área do cliente

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   // 1. Obtém o Handle do gráfico atual (Area de desenho)
   long hChart = ChartGetInteger(0, CHART_WINDOW_HANDLE);
   
   if(hChart == 0)
   {
      Print("Erro: Não foi possível obter o handle do gráfico.");
      return;
   }

   // 2. No MT5, a borda pertence ao PAI do gráfico.
   // Obtemos o "container" que segura o gráfico.
   long hParent = GetParent(hChart);

   if(hParent == 0)
   {
      Print("Erro: Não foi possível encontrar a janela pai.");
      return;
   }

   // 3. Remove a borda da janela PAI
   RemoveWindowBorder(hParent);
   
   // Atualiza o gráfico para redesenhar
   ChartRedraw();
}

//+------------------------------------------------------------------+
//| Função para remover estilos de borda e título                    |
//+------------------------------------------------------------------+
void RemoveWindowBorder(long hWnd)
{
   // Obtém o estilo atual da janela (Use PtrW para 64-bits)
   long currentStyle = GetWindowLongPtrW(hWnd, GWL_STYLE);
   
   // Define o que queremos remover (Título, Borda Grossa, Botões de sistema, Borda simples)
   long toRemove = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_BORDER | WS_DLGFRAME;
   
   // Remove os bits usando operação bitwise
   long newStyle = currentStyle & ~toRemove;
   
   // Aplica o novo estilo
   SetWindowLongPtrW(hWnd, GWL_STYLE, newStyle);
   
   // Força o Windows a atualizar a janela (FrameChanged é crucial aqui)
   SetWindowPos(hWnd, 0, 0, 0, 0, 0, 
                SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
}
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2025.11.27
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

I tried many things to remove borders for tile window charts, nothing work.  BUT, guess what? I found a way using UNDOCKED CHARTS.  (ALT+D) Works amazing if you use 2 monitors.

Intructions:

1 - Open MT5 and move to monitor 01 (as example)...  undock all charts and move all to Another monitor.  

2 - Arrange the charts in monitor by hand  or using win + arrows clicking chart by chart. 

3 - attach the script to any chart and fill the input section with the monitor where you moved the charts + this monitor resolution

4 - choose also the number of lines and columns do you want.    (as example for 2 charts tile vertically it's 1 line and 2 columns)

5 -  Press OK and see the magic happening.

6 - if you need to close the MT5, please,  Dock back all charts one by one by click the each chart and apply ALT + D.   DO THIS BEFORE CLOSE MT5 to avoid losing the chart with all indicators and customizations.

---

//+------------------------------------------------------------------+

//|                                     AutoWall_MultiMonitor.mq5    |

//|                                  Copyright 2024, MetaQuotes Ltd. |

//+------------------------------------------------------------------+

#property script_show_inputs

#property description "Organiza Gráficos Flutuantes em Grade no Monitor 1 ou 2"


//--- ENUMS PARA FACILITAR A ESCOLHA

enum ENUM_TARGET_MONITOR

  {

   MONITOR_1_PRINCIPAL = 0,      // Monitor 1 (Principal)

   MONITOR_2_DIREITA   = 1,      // Monitor 2 (Fica à Direita do Principal)

   MONITOR_2_ESQUERDA  = 2       // Monitor 2 (Fica à Esquerda do Principal)

  };


//--- INPUTS DO USUÁRIO

input ENUM_TARGET_MONITOR InpMonitor = MONITOR_2_DIREITA; // Qual Monitor usar?

input int InpRows = 2; // Numero de Linhas

input int InpCols = 2; // Numero de Colunas


input string separator = "--- Configuração do Monitor 2 ---"; // .

input int InpMon2_Width  = 1920; // Largura do Monitor 2 (px)

input int InpMon2_Height = 1080; // Altura do Monitor 2 (px)


//--- IMPORTAÇÕES DLL

#import "user32.dll"

   long GetParent(long hWnd);

   long GetWindowLongPtrW(long hWnd, int nIndex);

   long SetWindowLongPtrW(long hWnd, int nIndex, long dwNewLong);

   bool SetWindowPos(long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

   int  GetSystemMetrics(int nIndex);

   bool MoveWindow(long hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

#import


//--- CONSTANTES E FLAGS

#define SM_CXSCREEN 0

#define SM_CYSCREEN 1


#define GWL_STYLE -16

#define WS_CAPTION 0x00C00000 

#define WS_THICKFRAME 0x00040000 

#define WS_SYSMENU 0x00080000 

#define WS_BORDER 0x00800000 

#define WS_DLGFRAME 0x00400000

#define WS_POPUP 0x80000000


#define SWP_NOZORDER 0x0004

#define SWP_NOACTIVATE 0x0010

#define SWP_FRAMECHANGED 0x0020 


//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

{

   // 1. Obtém dados do Monitor Principal (Referência Zero)

   int primaryW = GetSystemMetrics(SM_CXSCREEN);

   int primaryH = GetSystemMetrics(SM_CYSCREEN);

   

   // 2. Define a Área de Trabalho Alvo (Offset e Tamanho)

   int targetX = 0;

   int targetY = 0;

   int targetW = primaryW;

   int targetH = primaryH;

   

   // Lógica de posicionamento baseada na escolha do usuário

   switch(InpMonitor)

   {

      case MONITOR_1_PRINCIPAL:

         targetX = 0;

         targetY = 0;

         targetW = primaryW;

         targetH = primaryH;

         break;

         

      case MONITOR_2_DIREITA:

         // Começa onde o monitor 1 termina

         targetX = primaryW; 

         targetY = 0; // Assume alinhamento pelo topo

         targetW = InpMon2_Width;

         targetH = InpMon2_Height;

         break;

         

      case MONITOR_2_ESQUERDA:

         // Começa antes do zero

         targetX = -InpMon2_Width;

         targetY = 0;

         targetW = InpMon2_Width;

         targetH = InpMon2_Height;

         break;

   }

   

   // 3. Calcula tamanho de cada célula na grade

   int cellW = targetW / InpCols;

   int cellH = targetH / InpRows;

   

   int currentIdx = 0;

   long currChartID = ChartFirst();

   

   // 4. Loop para aplicar nas janelas flutuantes

   while(currChartID != -1)

   {

      // Só processa se estiver DESACOPLADO (Floating)

      if(!ChartGetInteger(currChartID, CHART_IS_DOCKED))

      {

         long hChart = ChartGetInteger(currChartID, CHART_WINDOW_HANDLE);

         long hFrame = GetParent(hChart); 

         

         if(hFrame > 0)

         {

            // A. Remove Bordas

            RemoveBorder(hFrame);

            

            // B. Calcula Posição na Grade

            int row = currentIdx / InpCols;

            int col = currentIdx % InpCols;

            

            // A coordenada X final é: Onde começa o monitor + (coluna * largura)

            int finalX = targetX + (col * cellW);

            int finalY = targetY + (row * cellH);

            

            // C. Move para o Monitor 2 (ou 1)

            MoveWindow(hFrame, finalX, finalY, cellW, cellH, true);

            

            currentIdx++;

            

            // Reinicia o indice se tiver mais gráficos que espaços (sobrepõe do inicio)

            if(currentIdx >= InpRows * InpCols) currentIdx = 0; 

         }

         ChartRedraw(currChartID);

      }

      currChartID = ChartNext(currChartID);

   }

}


//+------------------------------------------------------------------+

//| Remove bordas e prepara para janela flutuante                    |

//+------------------------------------------------------------------+

void RemoveBorder(long hWnd)

{

   long currentStyle = GetWindowLongPtrW(hWnd, GWL_STYLE);

   long toRemove = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_BORDER | WS_DLGFRAME;

   

   // Adiciona WS_POPUP para garantir comportamento correto fora da MDI

   long newStyle = (currentStyle & ~toRemove) | WS_POPUP;

   

   if(newStyle != currentStyle)

   {

      SetWindowLongPtrW(hWnd, GWL_STYLE, newStyle);

      SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0001 | 0x0002 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);

   }

}
 
Here is the final, fully functional version translated **100% into English**.

**Reminder:** For this to work perfectly, remember to **Undock** (`Alt+D`) your charts first so they are floating windows.

### Script: `AutoWall_Final_EN.mq5`

```cpp

 //+------------------------------------------------------------------+
//|                                            AutoWall_Final_EN.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//+------------------------------------------------------------------+
#property script_show_inputs
#property description "Organizes Undocked Charts into a Grid on Monitor 1 or 2 (Borderless)"

//--- ENUMS FOR MONITOR SELECTION
enum ENUM_TARGET_MONITOR
  {
   MONITOR_1_MAIN  = 0,      // Monitor 1 (Primary)
   MONITOR_2_RIGHT = 1,      // Monitor 2 (Located to the Right of Primary)
   MONITOR_2_LEFT  = 2       // Monitor 2 (Located to the Left of Primary)
  };

//--- USER INPUTS
input ENUM_TARGET_MONITOR InpMonitor = MONITOR_2_RIGHT; // Which Monitor to use?
input int InpRows = 2; // Number of Rows
input int InpCols = 2; // Number of Columns

input string separator = "--- Monitor 2 Configuration ---"; // .
input int InpMon2_Width  = 1920; // Monitor 2 Width (px)
input int InpMon2_Height = 1080; // Monitor 2 Height (px)

//--- DLL IMPORTS (Windows API)
#import "user32.dll"
   long GetParent(long hWnd);
   long GetWindowLongPtrW(long hWnd, int nIndex);
   long SetWindowLongPtrW(long hWnd, int nIndex, long dwNewLong);
   bool SetWindowPos(long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
   int  GetSystemMetrics(int nIndex);
   bool MoveWindow(long hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
#import

//--- CONSTANTS AND FLAGS
#define SM_CXSCREEN 0
#define SM_CYSCREEN 1

#define GWL_STYLE -16
#define WS_CAPTION 0x00C00000 
#define WS_THICKFRAME 0x00040000 
#define WS_SYSMENU 0x00080000 
#define WS_BORDER 0x00800000 
#define WS_DLGFRAME 0x00400000
#define WS_POPUP 0x80000000

#define SWP_NOZORDER 0x0004
#define SWP_NOACTIVATE 0x0010
#define SWP_FRAMECHANGED 0x0020 

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   // 1. Get Main Monitor metrics (Zero Reference)
   int primaryW = GetSystemMetrics(SM_CXSCREEN);
   int primaryH = GetSystemMetrics(SM_CYSCREEN);
   
   // 2. Define Target Workspace (Offset and Size)
   int targetX = 0;
   int targetY = 0;
   int targetW = primaryW;
   int targetH = primaryH;
   
   // Positioning logic based on user selection
   switch(InpMonitor)
   {
      case MONITOR_1_MAIN:
         targetX = 0;
         targetY = 0;
         targetW = primaryW;
         targetH = primaryH;
         break;
         
      case MONITOR_2_RIGHT:
         // Starts exactly where Monitor 1 ends
         targetX = primaryW; 
         targetY = 0; // Assumes top alignment
         targetW = InpMon2_Width;
         targetH = InpMon2_Height;
         break;
         
      case MONITOR_2_LEFT:
         // Starts before zero (Negative coordinates)
         targetX = -InpMon2_Width;
         targetY = 0;
         targetW = InpMon2_Width;
         targetH = InpMon2_Height;
         break;
   }
   
   // 3. Calculate cell size for the grid
   int cellW = targetW / InpCols;
   int cellH = targetH / InpRows;
   
   int currentIdx = 0;
   long currChartID = ChartFirst();
   
   // 4. Loop to apply logic to floating windows
   while(currChartID != -1)
   {
      // Only process if the chart is UNDOCKED (Floating)
      if(!ChartGetInteger(currChartID, CHART_IS_DOCKED))
      {
         long hChart = ChartGetInteger(currChartID, CHART_WINDOW_HANDLE);
         long hFrame = GetParent(hChart); 
         
         if(hFrame > 0)
         {
            // A. Remove Borders
            RemoveBorder(hFrame);
            
            // B. Calculate Grid Position
            int row = currentIdx / InpCols;
            int col = currentIdx % InpCols;
            
            // Final X coordinate: Monitor Start Position + (Column * Width)
            int finalX = targetX + (col * cellW);
            int finalY = targetY + (row * cellH);
            
            // C. Move to Target Monitor
            MoveWindow(hFrame, finalX, finalY, cellW, cellH, true);
            
            currentIdx++;
            
            // Reset index if there are more charts than slots (Overlap from start)
            if(currentIdx >= InpRows * InpCols) currentIdx = 0; 
         }
         ChartRedraw(currChartID);
      }
      currChartID = ChartNext(currChartID);
   }
   
   Print("AutoWall Finished. Charts organized.");
}

//+------------------------------------------------------------------+
//| Remove borders and prepare floating window                       |
//+------------------------------------------------------------------+
void RemoveBorder(long hWnd)
{
   long currentStyle = GetWindowLongPtrW(hWnd, GWL_STYLE);
   long toRemove = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_BORDER | WS_DLGFRAME;
   
   // Add WS_POPUP to ensure correct behavior outside MDI (Flat look)
   long newStyle = (currentStyle & ~toRemove) | WS_POPUP;
   
   if(newStyle != currentStyle)
   {
      SetWindowLongPtrW(hWnd, GWL_STYLE, newStyle);
      SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0001 | 0x0002 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
   }
}