GreenPad icon indicating copy to clipboard operation
GreenPad copied to clipboard

Support even older Windows versions

Open RamonUnch opened this issue 2 years ago • 51 comments

For now GreenPad works fine on: Windows NT3.1 build 404 (oldest build I tested) Win3.1 + Win32s 1.15a

I tested Windows 3.1 + Win32s 1.1 (build 88) and the System freezes without other errors when I try to start GreenPad, If I delete the .ini file it gets created again, so the lockup does not happen immediately.

RamonUnch avatar Jan 03 '23 21:01 RamonUnch

Actually I just needed to define NO_ASMTHUNK and the exe works on Win3.1+Win32s 1.1 I just need to try with even older Win32s versions.

RamonUnch avatar Jan 04 '23 17:01 RamonUnch

Seems useless to support Win32s beta because it does not support codepages and WideCharToMultiByte/MultiByteToWideCharare stubs. https://github.com/RamonUnch/GreenPad/commit/0047c940646b355ec7dcccf753146343931c84e7

RamonUnch avatar Jan 05 '23 10:01 RamonUnch

my build crashes with GPF in chicago build 58s: image

I wonder if I completely disabling status bar will help or not.

roytam1 avatar Jan 11 '23 07:01 roytam1

yeah kind of working now, but it seems that WC2MB and/or MB2WC is failing: image

I can type something but it returns empty lines.

roytam1 avatar Jan 11 '23 08:01 roytam1

Probably GetCharWidthW and TextOutW are also not supported on old Chicago builds.

RamonUnch avatar Jan 11 '23 16:01 RamonUnch

For me it was enough to set StatusBar=0 in the ini file and I got the same problem tha you.

RamonUnch avatar Jan 11 '23 17:01 RamonUnch

Probably GetCharWidthW and TextOutW are also not supported on old Chicago builds.

since I'm testing win32s builds not NT31 ANSI builds so this is not a problem here.

roytam1 avatar Jan 12 '23 01:01 roytam1

for NT 340, I can make it opening Open File dialog but it looks quirk: image

and Save File dialog can't be shown right now.

roytam1 avatar Jan 14 '23 04:01 roytam1

changed dialog template font, open dialog works now: image

but Save File (As) still returns LastError 6 unless I remove OFN_ENABLEHOOK flag (but this is deal breaker) image

roytam1 avatar Jan 14 '23 05:01 roytam1

Quite some progress indeed, congratulations!

RamonUnch avatar Jan 14 '23 09:01 RamonUnch

but Save File (As) still returns LastError 6 unless I remove OFN_ENABLEHOOK flag (but this is deal breaker) image

for further testing, I used its SDK samples\multipad adding OFN_ENABLEHOOK for both GetOpenFilename and GetSaveFilename with a stub ofnhook function which just returns FALSE, such save hook works on later versions but not in 340. I wonder that 340's comdlg32.dll may need some binary patching.

roytam1 avatar Jan 15 '23 16:01 roytam1

How do you get status bar on NT build 340?

RamonUnch avatar Jan 15 '23 22:01 RamonUnch

Actually copying comctl32.dll from build 404 did the trick for me!

RamonUnch avatar Jan 15 '23 22:01 RamonUnch

For me on NT3.10.340, I can barely use the open dialog. After a fresh restart it displays fine, but then

  1. If I do Ctrl+O then I press esc,/cancel I get insta crash.
  2. When I select a file everything is OK, however later instances of GreenPad get a glitched Open dialog that aslo crashed on cancel. So I need a full restart. login/logout does not do it. Notepad does not have the problem though.

RamonUnch avatar Jan 16 '23 09:01 RamonUnch

2. Notepad does not have the problem though.

because notepad doesn't use common dialog templates and hooks.

roytam1 avatar Jan 16 '23 10:01 roytam1

So I guess we have to drop the hook and resolve to the simple open dialog. The codepage can be selected later via the reopen dialog. For saving that is a bigger issue. So we should allow to change current cs even on unsaved files, so that it gets used for saving.

RamonUnch avatar Jan 16 '23 10:01 RamonUnch

So I guess we have to drop the hook and resolve to the simple open dialog.

it has no problem on open dialog (I can't test via hotkeys, but via menu is no problem here)

roytam1 avatar Jan 16 '23 10:01 roytam1

it has no problem on open dialog (I can't test via hotkeys, but via menu is no problem here)

You are right, I just had problems because I was using "MS Shell Dlg" font, with "Helv" I get no problems.

RamonUnch avatar Jan 16 '23 13:01 RamonUnch

I got it finally! image

NT 340's comdlg32.dll wants ofnHook returning TRUE when processing WM_INITDIALOG.

roytam1 avatar Jan 18 '23 04:01 roytam1

Amazing, I will give it a try.

RamonUnch avatar Jan 18 '23 07:01 RamonUnch

According to the doc, we should return TRUE for the WM_INITDIALOG processing even (i guess) for the open dialog even though it works with return FALSE.

DOC: for OFNHookProcOldStyle

Return Values If the hook procedure returns zero, the default dialog box procedure processes the message. If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message. ...

The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the default dialog procedure processes the message or ignores it.

For the new style dialog it is also safer to return nonzero value from WM_INITDIALOG:

If you provide a hook procedure for an Explorer-style common dialog box, the system creates a dialog box that is a child of the default dialog box. The hook procedure acts as the dialog procedure for the child dialog. This child dialog is based on the template you specified in the OPENFILENAME structure, or it is a default child dialog if no template is specified. The child dialog is created when the default dialog procedure is processing its WM_INITDIALOG message. After the child dialog processes its own WM_INITDIALOG message, the default dialog procedure moves the standard controls, if necessary, to make room for any additional controls of the child dialog. The system then sends the CDN_INITDONE notification message to the hook procedure.

So I guess this return TRUE should always apply.

RamonUnch avatar Jan 18 '23 08:01 RamonUnch

remaining systems:

  • NT Builds < 329/340
    • since EXE format differences from later versions, there is no good way to support them
  • ReactOS
    • ~~Dynamically loading VC1-compiled DLL kills app, see https://jira.reactos.org/browse/CORE-18796, https://jira.reactos.org/browse/CORE-18797~~ fix approved and merged
    • CS_OWNDC redraw issues, see https://jira.reactos.org/browse/CORE-18800 (workarounded in https://github.com/RamonUnch/GreenPad/pull/67 , but still a problem in ROS itself)
    • ~~context menu not showing when right-click in edit control, see https://jira.reactos.org/browse/CORE-18801~~ fix approved and merged
    • Global IME debug log spams
  • Chicago Build 58s and Win32s < 1.10.88
    • ~~WC2MB and MB2WC are stubs~~ workarounded in https://github.com/RamonUnch/GreenPad/compare/19f51039...314b989d
  • Win32s < 1.10.88 (cont.)
    • ~~CreateFileMapping() fails without setting LastError~~ workarounded in https://github.com/RamonUnch/GreenPad/pull/69

for later two, WC2MB and MB2WC need wrappers. for CreateFileMapping, may need to fallback to ReadFile.

1.00.61 CreateFileMappingA shows: image

so it only supports CreateFileMapping() from a "-1" handle which is not our case.

roytam1 avatar Jan 18 '23 09:01 roytam1

I did not test GreenPad under OS/2 warp.

It should be possible via two ways:

  1. Installing Win32s under WIN-OS2
  2. Using Odin

The odds are high everything works fine already but I will ll need to test this when I get a working OS/2 environment. OS/2 came back to my memory when I heard about ArcaOS. This latter should also have a native support for Win32 programs, it seems to be a continuation of eComStation that stopped development in 2011.

RamonUnch avatar Jan 22 '23 21:01 RamonUnch

From quick testing it seems that Win32s build of GreenPad works fine on WIN-OS2+Win32s1.25a (with comctl32.dll from beta) under OS/2 Warp 4.51.

RamonUnch avatar Jan 23 '23 08:01 RamonUnch

2. Using Odin

my old odin install is still working. image odin can only work with ANSI versions, and it work best with my NT31-ansi version.

roytam1 avatar Jan 23 '23 10:01 roytam1

Wow, that's so beautiful! Which Windows version does Odin identifies itself as?

RamonUnch avatar Jan 23 '23 10:01 RamonUnch

Which Windows version does Odin identifies itself as?

XP. image

roytam1 avatar Jan 23 '23 10:01 roytam1

Interesting to report that since it does not support proper Unicode...

RamonUnch avatar Jan 23 '23 10:01 RamonUnch

I took a glance at ReactOS source and It seems the DC is released on ReleaseDC()/EndPaint() even when the CS_OWNDC style is specified, the CS_OWNDC style is checked however to create a DC when calling CreateWindow which is good, I am unsure however how it is handled elsewere, But I need to check if the OWNDC version of GreenPad would work if I remove the EndPaint() and use ValidateRect() instead.

RamonUnch avatar Jan 23 '23 17:01 RamonUnch

I took a glance at ReactOS source and It seems the DC is released on ReleaseDC()/EndPaint() even when the CS_OWNDC style is specified,

but ros winetest doesn't show that: https://github.com/reactos/reactos/blob/master/modules/rostests/winetests/user32/dce.c https://jira.reactos.org/browse/CORE-18800?focusedCommentId=138102&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-138102

roytam1 avatar Jan 24 '23 00:01 roytam1