Win11 and DirOpus does not open in a fixed position and with a fixed size

I have had this problem and added the following code to MainFrame.cpp and WinPos.h and WinPos.cpp to control where the app opens upon startup. DirOpus needs something similar.

Bob Van Tuyl
Software Engineer, Retired
San Jose, CA

void MainFrame::OnMove(int x, int y)
           {CRect winRect;   GetWindowRect(&winRect);   winPos.set(winRect);   CFrameWndEx::OnMove(x, y);}

void MainFrame::OnSize(UINT nType, int cx, int cy) {
CRect winRect;

  CFrameWndEx::OnSize(nType, cx, cy);

  if (!isInitialized) return;

  GetWindowRect(&winRect);   winPos.set(winRect);

#pragma once

struct WinPosData {
int left;
int top;
int width;
int depth;

  WinPosData() : left(0), top(0), width(0), depth(0) { }
 ~WinPosData() { }

  WinPosData& operator= (RECT& r)
           {left = r.left; top =; width = r.right - r.left; depth = r.bottom -; return *this;}

  operator RECT() {return {left, top, width, depth};}

  void load(RECT& defaultRect);

  void save();

  void normalize(int screenWidth, int maxDepth);

class WinPos {

WinPosData data;                                // App window position and size

int        screenWidth;                         // Maximum Screen width and height
int        screenHeight;


 ~WinPos() {save();}

  // initialize the window to the saved position and size, only call once

  void initialPos(CWnd* wnd, RECT& defaultRect);

  void set(CRect& curPos) {data = curPos;}


  void save() {;}                     // Save the current position and size when app closes.
// Manage Window Position and Size

#include "pch.h"
#include "WinPos.h"
#include "IniFile.h"

WinPos::WinPos() {
RECT rsys;

  SystemParametersInfo(SPI_GETWORKAREA, 0, &rsys, 0);

  screenWidth = rsys.right;   screenHeight = rsys.bottom;

void WinPos::initialPos(CWnd* wnd, RECT& defaultRect) {

  data.load(defaultRect);   data.normalize(screenWidth, screenHeight);

  wnd->SetWindowPos(0, data.left,, data.width, data.depth, SWP_NOCOPYBITS);    // | SWP_NOACTIVATE

static TCchar* WindowPosData = _T("Window Position Data");
static TCchar* Left          = _T("Left");
static TCchar* Top           = _T("Top");
static TCchar* Width         = _T("Width");
static TCchar* Depth         = _T("Depth");

void WinPosData::save() {
  iniFile.write(WindowPosData, Left,  left);
  iniFile.write(WindowPosData, Top,   top);
  iniFile.write(WindowPosData, Width, width);
  iniFile.write(WindowPosData, Depth, depth);

void WinPosData::load(RECT& defaultRect) {
  left   = iniFile.readInt(WindowPosData, Left,  defaultRect.left);
  top    = iniFile.readInt(WindowPosData, Top,;
  width  = iniFile.readInt(WindowPosData, Width, defaultRect.right  - defaultRect.left);
  depth  = iniFile.readInt(WindowPosData, Depth, defaultRect.bottom -;
  if (left   <  0) left   =   0;
  if (top    <  0) top    =   0;
  if (width  < 100) width = 100;
  if (depth  < 100) depth = 100;

void WinPosData::normalize(int screenWidth, int screenHeight) {

  if (width        < 100 || screenWidth < width) width = 100;
  if (depth        < 100 || screenHeight < depth) depth = 100;
  if (left         < 0)                       left  = 0;
  if (left + width > screenWidth)                left  = screenWidth  - width;
  if (top          < 0)                       top   = 0;
  if (top  + depth > screenHeight)                top   = screenHeight - depth;

A saved Lister layout is one way you can have Opus always open a window in the same position:

Just tried that setting and it does not work in Win11. Sorry. Bob

I suspect Opus is already running when you're asking it to open a new window, in which case the Startup settings don't apply.

Make sure Preferences / Launching Opus / Default Lister / Always in the same position is also chosen, assuming the default lister is what's being opened. (It usually is, but if you're using a layout or special command to open something else, then it might not be.)

(Is there any reason you think Windows 11 is involved?)

The setting I showed earlier has been that way since I started using DirOpus many years ago. I can restart windows and the result is the same. DirOpus moves horizontally to the center and takes about 2/3 to 3/4 of the screen horizontally and 100% vertically. My default profile has it tucked into the right border of the screen and about 1/2 of the horizontal width and 100% of the vertical height.

I am using Win 11 Pro on a Dell XPS 8940 not that this should make any difference...

My conclusion is that either DirOpus is not behaving correctly or Win11 is not behaving correctly. As I said earlier I took charge of the position and size issue in my c++ applications.

Hi mate,
I have no issue on this matter -- Opus always opens in the last state it was in. I move Opus about and close it - openning it does so in same position and scale.

I did set this up like below when experimenting this desired behavior.