User:Lucas Brooks/Researches/Windows 1.x Overlapping Windows

Insert the following code into the beginning (after function prologue) of the CreateWindow function of the Windows User Interface module (USER.EXE) to make applications display overlapping windows in Windows 1.x.

        ...                                 ; function prologue
EXTRA:
        TEST    WORD PTR [BP+1AH], 4000H    ; check if child
        JNZ     SHORT CONTINUE
        TEST    WORD PTR [BP+1AH], 8000H    ; check if popup
        JNZ     SHORT CONTINUE
        OR      BYTE PTR [BP+1BH], 80H      ; make it a popup
        CMP     WORD PTR [BP+12H], 0        ; check if width = 0
        JNZ     SHORT CHECK_HEIGHT
        MOV     WORD PTR [BP+12H], 300      ; set width to 300

CHECK_HEIGHT:
        CMP     WORD PTR [BP+10H], 0        ; check if height = 0
        JNZ     SHORT CONTINUE
        MOV     WORD PTR [BP+10H], 100      ; set height to 100

CONTINUE:
        ...                                 ; the original code

The above 8086 Assembly instructions are equivalent to the following C code:

    if (!(dwStyle & WS_CHILD) && !(dwStyle & WS_POPUP))
    {
        dwStyle |= WS_POPUP;
        if (!nWidth) {
            nWidth = 300;
        }
        if (!nHeight) {
            nHeight = 100;
        }
    }

This works for all versions of Windows 1.x since Windows 1.0 Alpha Release, with the following limitations:

  • Overlapping windows in Windows 1.0 Alpha Release cannot be brought to front, meaning newer windows will always be on top of older windows.
  • Overlapping windows cannot be minimized or maximized (applies to all versions of Windows 1.0).