Jump to content
COMBATSIM Forum

TFXplorer and Windows 10


mikew
 Share

Recommended Posts

Wonderful! Builds like a charm, both automatic and manual. :thumbsup:

 

Not yet sure why I'm not seeing any scenarios though.

tfxp.PNG.7979fba2a7fc4161efd810afb8c15744.PNG

so haven't had a chance to see what happens when there is no 3D hardware acceleration whatsoever. :)

 

Anyway, I'm off to make some new planes with the 'Vehicle Builder'

Link to comment
Share on other sites

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

2 hours ago, mikew said:

Not yet sure why I'm not seeing any scenarios though.

tfxp.PNG.7979fba2a7fc4161efd810afb8c15744.PNG

so haven't had a chance to see what happens when there is no 3D hardware acceleration whatsoever. :)

 

Anyway, I'm off to make some new planes with the 'Vehicle Builder'

 

 

I’m confused as well – your files are placed correctly and the keys seem correct, too.

 

Could it be that the TFX to UAW.dll plugin is placed at the wrong path, or you mixed 32- and 64-bit versions, or debug and release builds?

 

It could also be a path problem. The chain of casuality is:

  1. TFXplorer loads all DLLs from plugins x64 or plugins x86, according to architecture.
  2. There should be at least TFX3 F22 x64.dll in there.
  3. TFX3 F22 x64.dll, during initialization, loads TFX to UAW x64.dll.
    (This is an attempt to make TFX planes extensions which can be deployed and loaded in isolation, while still sharing the same code for TFX file handling. Being an attempt, it is incomplete, thereby making the chaos worse …)
  4. TFX to UAW x64.dll loads your TFX directories in tfx_load(), TFX to UAW.cpp, line 355. You should be able to set a breakpoint there, or insert INVOKE_DEBUGGER; into the first line and recompile. If that breakpoint is never hit, then it is likely a path issue loading the extension DLLs.
  5. It searches the registry for the keys you provided, and for each path calls versionOfTfxDirectory():
    1. open DID.DAT; read bytes 8–12; if 1 or 2 or 0x35812B86, it’s ADF/TAW/EF2000v2
    2. if no DID.DAT is found, check for files did1st.dat, lev\redsea.asc, and lev\norway.asc, which designate ADF/TAW/EF2000 (if you find a better way, let me know!)
    3. If any of those are found, it should land in declareEF2000v2Assets() and declareTawAssets() in the file TFX Levels.cpp and that’s where the scenarios are added to a list that is later read by the GUI.

Now that I peek at the code, I see that there is some mess going on with the working directory: When I wrote 3View ten years ago(!), it loaded all files relative to the current working directory. That stopped working the moment I allowed TFXplorer to load multiple TFX versions side-by-side, and changing all functions to absolute paths is a rather huge undertaking, so the code goes great lengths to set the current working directory to wherever the current DID.DAT is located. That looks pretty fragile and I have no idea if it works reliably with external drives, networked paths, or if it screws up loading of later DLLs (which may search for their dependencies in the current directory?). Sorry; that’s one of the ugly TODOs.

 

The other TODO was a proper options screen where

  1. you can see which extensions are loaded
  2. you can see a list of error messages from these extensions
  3. you can change settings of the extensions, e.g. set your TFX paths without messing with the registry.

Joysticks and Gamepads needed a GUI more than the plugin mechanism, so I haven’t gotten to program it yet. Would save us lots of time now :(

 

Link to comment
Share on other sites

I only had a few minutes with it, but there's a 4 day weekend coming up so will try those suggestions. I just ran the main exe from wherever VS built it and paid no attention to where the DLLs were.

 

Once I'm up and running again, I'll try and help with my new programming skills but I can't see where you've put the #include "windows.h" :)

Link to comment
Share on other sites

1 hour ago, mikew said:

I'll try and help with my new programming skills but I can't see where you've put the #include "windows.h" :)

Not using windows.h because it includes ~80k lines of code and needs a few #defines to work properly. When I need a WinAPI function, it is declared privately in a cpp that provides a wrapper (almost all of which are named OS Win32 ….cpp).

 

E.g. look at OS Win32 File.cpp (172) for an example of why and how to wrap WinAPI calls.

Link to comment
Share on other sites

I have no idea what's happened to this native Win 10 PC as it's the one I started this thread with and VS was working fine. Now it doesn't understand 'not'. I'll just post the error here and go back to the machine I was using yesterday.

vsfail.png.049b84b7c1d46403d1755f49552f7426.png

Link to comment
Share on other sites

“not” was introduced with the C++20 standard, so the compiler is too old.

 

Your snapshot says Developer Command Prompt v16.5.0, but mine is v16.10.0. In the environment file, did you point vcvarsall.bat to the wrong location (to an older version of Visual Studio)? Make sure it points to the 2019 version.

 

Edit: Duh, didn’t read it all! Your path already points to VS 2019. Interesting … in the TFXplorer project properties > C/C++ > Language > C++ Language Standard, does it say Preview? It should.

 

Also, try updating your Visual C++ by searching the Start menu for Visual Studio Installer.

Link to comment
Share on other sites

1 hour ago, Krycztij said:

“not” was introduced with the C++20 standard

What, really? Is this just an alternative to the ! operator?

 

Yep, that PC has only ever had VS2019, but the only update it was nagging me for was for some web component.

So, it seems useful updates have to be 'pulled' from MS but any frivolous 'social' stuff get 'pushed'.  :(

 

Right now, I'm back to the other PC with Linux+Win10 VM. I added that CFF tool and followed your instructions more carefully, and this time I get a _deploy folder with all the DLLs in the right place and now I see the scenarios. :)

It even runs them to some extent, so Windows must have some sort of SW renderer for the Direct3d9 stuff if it can't find a GPU.

It would be nice if I could build straight into the shared Linux folder so I could run straight away with Wine. The two OSs don't seem that well synched though.

I do have a good reason for doing things this way...

Link to comment
Share on other sites

4 hours ago, mikew said:

What, really? Is this just an alternative to the ! operator?

Exactly. You could basically run search-and-replace, but having a consistent build chain seems more desireable. (That’s why I had been talking about adding the compiler to source control in the other thread – we could just check out a specific version of TFXplorer with the according build chain. If only the dependencies weren’t such a mess.)

4 hours ago, mikew said:

Right now, I'm back to the other PC with Linux+Win10 VM. […] It even runs them to some extent, so Windows must have some sort of SW renderer for the Direct3d9 stuff if it can't find a GPU.

Wow, that’s fantastic news! I know that D3D 10/11/12 has a software renderer (it’s called WARP and I use it e.g. for Lean Viewer to run on low-end systems), but I never knew about D3D 9 having one. Maybe your VM comes with basic GPU emulation? I’ve heard many virtualization platforms support that now.

4 hours ago, mikew said:

It would be nice if I could build straight into the shared Linux folder so I could run straight away with Wine. The two OSs don't seem that well synched though.

If you get the folder mapped properly into Windows, it *should* be as easy as opening _auto_environment.bat again and in the last line, change DEPLOY_DIR to the shared folder. I never tested that, though.

 

Anyway, very glad to hear it builds and runs!

 

4 hours ago, mikew said:

I do have a good reason for doing things this way...

Thrilled to find out!

Link to comment
Share on other sites

56 minutes ago, Krycztij said:

Maybe your VM comes with basic GPU emulation? I’ve heard many virtualization platforms support that now.

Could be. It's just the one that comes with the Linux distro called 'Boxes'.

 

56 minutes ago, Krycztij said:

If you get the folder mapped properly into Windows, it *should* be as easy as opening _auto_environment.bat again and in the last line, change DEPLOY_DIR to the shared folder. I never tested that, though.

I might give it a go. I've had situations where files 'disappear' from 'dir' in a command prompt in the shared folder and I need to restart the terminal to see them again.

 

56 minutes ago, Krycztij said:

Thrilled to find out!

Nothing too exciting. I have a Mini PC (i5 NUC) that I usually take into work for times when I might get a spare minute or two to do personal stuff. So, the more things it can do, the better.

 

I've been wondering why TFXplorer/3View/Lean Viewer always start in a small window. You explained it elsewhere, but I'm trying to gather evidence to report to Wine.

The key will be knowing what to log. Here's the windows messages around where I think the window is being set up.

Would this be of any help?

 

EDIT:

I need to try and find the spoiler tag...back soon

 

Link to comment
Share on other sites

Hmmn, spoiler tags don't seem to work, so I'll just post it here and delete it if it's of no use...

 

Quote

0144:trace:message:SPY_EnterMessage     (0000000000010098)  DefWindowProc:[031a] WM_THEMECHANGED  wp=00000000 lp=00000000
0144:trace:message:SPY_ExitMessage      (0000000000010098)  DefWindowProc: [031a] WM_THEMECHANGED returned 00000000
0144:trace:message:SPY_ExitMessage  (0000000000010098) L"{ModernTextVie}" [031a] WM_THEMECHANGED returned 00000000
0144:trace:message:SPY_EnterMessage (00000000000100A2) L"{ModernDataGri}" [031a] WM_THEMECHANGED dispatched  wp=00000000 lp=00000000
0144:trace:message:SPY_EnterMessage     (00000000000100A2)  DefWindowProc:[031a] WM_THEMECHANGED  wp=00000000 lp=00000000
0144:trace:message:SPY_ExitMessage      (00000000000100A2)  DefWindowProc: [031a] WM_THEMECHANGED returned 00000000
0144:trace:message:SPY_ExitMessage  (00000000000100A2) L"{ModernDataGri}" [031a] WM_THEMECHANGED returned 00000000
0144:trace:message:SPY_EnterMessage (0000000000020066) L"Starting"      [8000] WM_USER+31744 dispatched  wp=00000000 lp=00000000
0144:trace:message:SPY_EnterMessage     (000000000001006C) L"\2026"         [000c] WM_SETTEXT sent from self wp=00000000 lp=000436d0
0144:trace:message:SPY_EnterMessage         (000000000001006C)  DefWindowProc:[000c] WM_SETTEXT  wp=00000000 lp=000436d0
0144:trace:message:SPY_ExitMessage          (000000000001006C)  DefWindowProc: [000c] WM_SETTEXT returned 00000001
0144:trace:message:SPY_ExitMessage      (000000000001006C) L"\2713"         [000c] WM_SETTEXT returned 00000001
0144:trace:message:SPY_EnterMessage     (0000000000020066)  DefWindowProc:[8000] WM_USER+31744  wp=00000000 lp=00000000
0144:trace:message:SPY_ExitMessage      (0000000000020066)  DefWindowProc: [8000] WM_USER+31744 returned 00000000
0144:trace:message:SPY_ExitMessage  (0000000000020066) L"Starting"      [8000] WM_USER+31744 returned 00000000
did1st.dat not opened; no patches will be considered
0144:trace:message:SPY_EnterMessage (000000000002004E) L"TFXplorer"     [0046] WM_WINDOWPOSCHANGING sent from self wp=00000000 lp=002fc2a0
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000002004E, after=0000000000000000, at (0,4) w=112 h=28, flags=0x00000014
0144:trace:message:SPY_EnterMessage     (000000000002004E)  DefWindowProc:[0046] WM_WINDOWPOSCHANGING  wp=00000000 lp=002fc2a0
0144:trace:message:SPY_EnterMessage         (000000000002004E) L"TFXplorer"     [0024] WM_GETMINMAXINFO sent from self wp=00000000 lp=002fba30
0144:trace:message:SPY_EnterMessage             (000000000002004E)  DefWindowProc:[0024] WM_GETMINMAXINFO  wp=00000000 lp=002fba30

trying to load .dat file ...
0144:trace:message:SPY_ExitMessage              (000000000002004E)  DefWindowProc: [0024] WM_GETMINMAXINFO returned 00000000
0144:trace:message:SPY_ExitMessage          (000000000002004E) L"TFXplorer"     [0024] WM_GETMINMAXINFO returned 00000000
identified an F-22 Total Air War .dat file
0144:trace:message:SPY_ExitMessage      (000000000002004E)  DefWindowProc: [0046] WM_WINDOWPOSCHANGING returned 00000000
0144:trace:message:SPY_ExitMessage  (000000000002004E) L"TFXplorer"     [0046] WM_WINDOWPOSCHANGING returned 00000000
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000002004E, after=0000000000000000, at (0,4) w=912 h=627, flags=0x00000014
0144:trace:message:SPY_EnterMessage (000000000002004E) L"TFXplorer"     [0083] WM_NCCALCSIZE sent from self wp=00000001 lp=002fc1b0
0144:trace:message:SPY_DumpStructure Rects (0,4)-(912,631) (0,0)-(112,27) (4,23)-(108,23)
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000002004E, after=0000000000000000, at (0,4) w=912 h=627, flags=0x00001814
0144:trace:message:SPY_EnterMessage     (000000000002004E)  DefWindowProc:[0083] WM_NCCALCSIZE  wp=00000001 lp=002fc1b0
0144:trace:message:SPY_ExitMessage      (000000000002004E)  DefWindowProc: [0083] WM_NCCALCSIZE returned 00000000
0144:trace:message:SPY_ExitMessage  (000000000002004E) L"TFXplorer"     [0083] WM_NCCALCSIZE returned 00000000
loading .dat directory
0144:trace:message:SPY_DumpStructure Rects (4,27)-(908,627) (0,0)-(112,27) (4,23)-(108,23)
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000002004E, after=0000000000000000, at (0,4) w=912 h=627, flags=0x00001814
loading 0144:trace:message:SPY_EnterMessage (000000000002004E) L"TFXplorer"     [0085] WM_NCPAINT sent from self wp=00000001 lp=00000000
0144:trace:message:SPY_EnterMessage     (000000000002004E)  DefWindowProc:[0085] WM_NCPAINT  wp=00000001 lp=00000000
0144:trace:message:SPY_ExitMessage      (000000000002004E)  DefWindowProc: [0085] WM_NCPAINT returned 00000000
0068:trace:message:SPY_EnterMessage (0000000000010020) L"{#32769}"      [0210] WM_PARENTNOTIFY dispatched  wp=00000085 lp=0002004e
0144:trace:message:SPY_ExitMessage  (000000000002004E) L"TFXplorer"     [0085] WM_NCPAINT returned 00000000
0068:trace:message:SPY_ExitMessage  (0000000000010020) L"{#32769}"      [0210] WM_PARENTNOTIFY returned 00000000
1050144:trace:message:SPY_EnterMessage (000000000002004E) L"TFXplorer"     [0014] WM_ERASEBKGND sent from self wp=0001007b lp=00000000
0144:trace:message:SPY_EnterMessage     (000000000002004E) L"TFXplorer"     [0136] WM_CTLCOLORDLG sent from self wp=0001007b lp=0002004e
0144:trace:message:SPY_ExitMessage      (000000000002004E) L"TFXplorer"     [0136] WM_CTLCOLORDLG returned 00010058
0144:trace:message:SPY_ExitMessage  (000000000002004E) L"TFXplorer"     [0014] WM_ERASEBKGND returned 00000001
0144:trace:message:SPY_EnterMessage (000000000001005E) L"\e72b"         [0085] WM_NCPAINT sent from self wp=00000001 lp=00000000
0144:trace:message:SPY_EnterMessage     (000000000001005E)  DefWindowProc:[0085] WM_NCPAINT  wp=00000001 lp=00000000
 directory names
loading 0144:trace:message:SPY_ExitMessage      (000000000001005E)  DefWindowProc: [0085] WM_NCPAINT returned 00000000
0144:trace:message:SPY_ExitMessage  (000000000001005E) L"\e72b"         [0085] WM_NCPAINT returned 00000000
710144:trace:message:SPY_EnterMessage (000000000001005E) L"\e72b"         [0014] WM_ERASEBKGND sent from self wp=002f0084 lp=00000000
0144:trace:message:SPY_EnterMessage     (000000000001005E)  DefWindowProc:[0014] WM_ERASEBKGND  wp=002f0084 lp=00000000
0144:trace:message:SPY_ExitMessage      (000000000001005E)  DefWindowProc: [0014] WM_ERASEBKGND returned 00000000
0144:trace:message:SPY_ExitMessage  (000000000001005E) L"\e72b"         [0014] WM_ERASEBKGND returned 00000000
0144:trace:message:SPY_EnterMessage (0000000000010060) L"\e946"         [0085] WM_NCPAINT sent from self wp=00000001 lp=00000000
0144:trace:message:SPY_EnterMessage     (0000000000010060)  DefWindowProc:[0085] WM_NCPAINT  wp=00000001 lp=00000000
 file extensions
0144:trace:message:SPY_ExitMessage      (0000000000010060)  DefWindowProc: [0085] WM_NCPAINT returned 00000000
0144:trace:message:SPY_ExitMessage  (0000000000010060) L"\e946"         [0085] WM_NCPAINT returned 00000000
extracting 0144:trace:message:SPY_EnterMessage (0000000000010060) L"\e946"         [0014] WM_ERASEBKGND sent from self wp=00430078 lp=00000000
0144:trace:message:SPY_EnterMessage     (0000000000010060)  DefWindowProc:[0014] WM_ERASEBKGND  wp=00430078 lp=00000000
0144:trace:message:SPY_ExitMessage      (0000000000010060)  DefWindowProc: [0014] WM_ERASEBKGND returned 00000000
0144:trace:message:SPY_ExitMessage  (0000000000010060) L"\e946"         [0014] WM_ERASEBKGND returned 00000000
0144:trace:message:SPY_EnterMessage (000000000002004E) L"TFXplorer"     [0047] WM_WINDOWPOSCHANGED sent from self wp=00000000 lp=002fc2a0
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000002004E, after=0000000000000000, at (0,4) w=912 h=627, flags=0x00000014
0144:trace:message:SPY_EnterMessage     (000000000001005E) L"\e72b"         [0046] WM_WINDOWPOSCHANGING sent from self wp=00000000 lp=0183ace0
0144:trace:message:SPY_DumpStructure WINDOWPOS hwnd=000000000001005E, after=0000000000000000, at (0,0) w=48 h=48, flags=0x00000214

 

Link to comment
Share on other sites

39 minutes ago, mikew said:

I've been wondering why TFXplorer/3View/Lean Viewer always start in a small window. You explained it elsewhere, but I'm trying to gather evidence to report to Wine.

 

Cool!

 

I’m using the Windows standard mechanism for dialog creation: A dialog template. These are normally created via resource files (.rc) in Visual Studio, but I hate to depend on Microsoft’s toolchain, so I wrote a few C++ templates which generate the exact same data.

 

The dialog template starts with a DLGTEMPLATE structure. This is defined in TFXplorer.cpp, as the global variable frameDialogTemplate. You only see an instance of OS::Win32::ClassicUI::DialogTemplateHeader there, but what this template does, is it generates the DLGTEMPLATE structure.

 

In generating it (OS Win32 ClassicUI CustomDialog.hpp ca. line 750), it sets

x=-32768

y=-32768

cx=32768

cy=32768

In this case, -32768 and 32768 are equal because x/y are signed 16-bit integers and cx/cy are unsigned 16-bit integers, so all four numbers evaluate to 0x8000. This equals the constant CW_USEDEFAULT.

x=CW_USEDEFAULT

y=CW_USEDEFAULT

cx=CW_USEDEFAULT

cy=CW_USEDEFAULT

 

 

The documentation of CreateWindow() describes CW_USEDEFAULT as:

 

Quote

x

Type: int

The initial horizontal position of the window. […] If this parameter is set to CW_USEDEFAULT, the system selects the default position for the window's upper-left corner and ignores the y parameter.

 

y

Type: int

The initial vertical position of the window. […] If an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT, then the y parameter determines how the window is shown. If the y parameter is CW_USEDEFAULT, then the window manager calls ShowWindow with the SW_SHOW flag after the window has been created.

 

nWidth

Type: int

The width, in device units, of the window. […] If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area.

 

nHeight

Type: int

The height, in device units, of the window. […] If nWidth is set to CW_USEDEFAULT, the system ignores nHeight.

 

(There is more talk about non-“overlapping” windows, which is not relevant to us here, as TFXplorer’s main window is indeed “overlapped”.)

 

So the expected behavior for CreateWindow() with 4×CW_USEDEFAULT is: Let the system decide where the window shows and how wide/high it is.

 

This is very useful if you don’t want to enumerate screens, analyze screen resolution, etc. on startup.

 

I couldn’t find information on whether this behavior is also guaranteed for dialog templates instead of calls to CreateWindow(). (TFXplorer creates its main window via CreateDialogIndirectParamW() on the DLGTEMPLATE, initiated in TFXplorer.cpp via tryToCreate(&frameDialogTemplate, nullptr).) But from all my experiments on Windows XP, 7, and 10 – it absolutely is. All my tools have shipped with it and never has a customer had a problem with it. Except for you on Wine.

 

So the bug report you’d write is: Wine does not honor CW_USEDEFAULT in dialog templates like Windows does.

 

Then you’d probably use one of the Visual Studio “New Project” templates to create a simple Win32 application, use Visual Studio’s Resource Editor to create a minimal dialog with one button, and enter 0x8000 as its x, y, width, and height. Compile it and it should start with a proper size on Windows, and at an invalid size on Wine.

 

And now, I’ll have a look at Wine’s source code for CreateDialogIndirectParamW().

Link to comment
Share on other sites

Okay, here’s my analysis of Wine’s code:

  1. DialogBoxIndirectParamW() is defined at https://github.com/wine-mirror/wine/blob/master/dlls/user32/dialog.c#L898
    (This is the right place, as the Win32 DialogBoxIndirectParamW() is also located in User32.dll)
     
  2. it redirects to DialogBoxIndirectParamAorW() (line 876)
     
  3. this, in turn, redirects dialog creation to DIALOG_CreateIndirect() (line 443)
     
  4. line 532 looks very promising:
    if (template.x == (SHORT)0x8000 /*CW_USEDEFAULT16*/)
        pos.x = pos.y = CW_USEDEFAULT;

    This conforms to the documentation I quoted above: The dialog position is chosen by the system.
     
  5. But what about the size?!
    Lines 517+ look very wrong:
     
    1. There is a call to SetRect() which, supposedly, converts the size from dialog units to pixels according to the dialog’s font size. This is indeed necessary to scale dialogs correctly with their font size. But the call is unconditionally; it never checks whether cx==CW_USEDEFAULT!
       
    2. So the whole computation on rect will overflow or produce straight out garbage. Then size.cx and size.cy are assigned from rect (lines 529+530), and also become garbage. And when the dimensions are passed to CreateWindowExW() (line 607) to actually create the window, CW_USEDEFAULT has become some garbage value. Wine then creates the window with garbage dimensions.
       
  6. I suppose a fix would be to put the whole scale-cx-and-cy-to-font-size thing inside an if(cx != 0x8000) block. If it indeed is 0x8000, like for TFXplorer, just pass that 0x8000 on to CreateWindowExW(), which will recognize it as “choose window size at your discretion”.
     

If you want to give the Wine people a more minimal and “serious” example than TFXplorer, try https://papas-best.com/stlviewer_en . It should be using the same mechanism (you may recognize a bit of Lean Viewer there) and its user base is much bigger. But I have two users saying it works “fine”, so test before you report :)

Link to comment
Share on other sites

Wow! A lot of info there. It may, of course, be the fault of my setup.

 

Your STL viewer behaves the same way on startup, and expanding it shows some strange 'smearing' of whatever is above the white box. While I'm at it, the arrow and information symbols in the TFXplorer scenario menu don't display properly either.wine_prob.png.d6f12b5d7e98c56d0befc122228fed0c.png

 

I like the idea of producing a minimal Windows program to show these effects, so that is what I may try to do next to see if I can control VS in any way.

Link to comment
Share on other sites

50 minutes ago, mikew said:

While I'm at it, the arrow and information symbols in the TFXplorer scenario menu don't display properly either.

Neither on Windows 7. MS seems to have made a fully Unicode-compatible font not before Windows 10 …

 

50 minutes ago, mikew said:

Your STL viewer behaves the same way on startup, and expanding it shows some strange 'smearing' of whatever is above the white box.

That’s really the standard Win32 controls (“Win32 Common Controls”); I didn’t change a single thing :D I must admit that this doesn’t have to be Wine’s fault (or your setup’s); there are problems on Windows as well. Rarely, but still too many. That’s a reason I decided against the Common Controls in TFXplorer – I wouldn’t mind the classic look if they worked perfectly, but they don’t …

  

50 minutes ago, mikew said:

I like the idea of producing a minimal Windows program to show these effects, so that is what I may try to do next to see if I can control VS in any way.

 

This tutorial looks like it could work: https://docs.microsoft.com/en-us/cpp/windows/walkthrough-creating-windows-desktop-applications-cpp

 

(Thanks for testing btw!)

Link to comment
Share on other sites

Yes, that tutorial seems to show this fine:

 

If I make these changes:

    HWND hWnd = CreateWindow(
        szWindowClass,
        szTitle,
        WS_OVERLAPPEDWINDOW,

        0x8000, 0x8000,  // Test 4
        CW_USEDEFAULT, CW_USEDEFAULT,

    //    0x8000, 0x8000,  // Test 3
    //    0x8000, 0x8000,

    //    CW_USEDEFAULT, CW_USEDEFAULT, //Test 2
    //    CW_USEDEFAULT, CW_USEDEFAULT,

    //    CW_USEDEFAULT, CW_USEDEFAULT,  // Test 1 Original code
    //    500, 100,
        NULL,
        NULL,
        hInstance,
        NULL
    );

...all 4 tests work fine in Win10, but only 1 and 2 in Wine. This is the same for x86 and x64

Tests 3 and 4 don't really start in Wine. It thinks about it, then gives up.

 

So, it maybe it's not the CW_USEDEFAULT is the problem, but how Wine interprets the 0x8000.

 

EDIT:
tests 3 and 4 actually hang in Wine, so I have to kill the processes manually.

 

I don't understand why test4 doesn't work if your interpretation of the Wine code is correct.

Link to comment
Share on other sites

1 hour ago, mikew said:

I don't understand why test4 doesn't work if your interpretation of the Wine code is correct.

 

Because I mixed up CW_USEDEFAULT and CW_USEDEFAULT16 🙄 Sorry!

 

So CW_USEDEFAULT16 is 0x8000 and CW_USEDEFAULT is 0x80000000. Dialog Templates use CW_USEDEFAULT16 because they are restricted to 16-bit numbers. The Wine code actually translates CW_USEDEFAULT16 to CW_USEDEFAULT, but only for x/y and not for cx/cy.

Link to comment
Share on other sites

Ah, yes . All 4 tests work on Wine now.

 

So I need to replace  HWND hWnd = CreateWindow(

with something like  HWND hWnd = CreateDialogWindow(

...hang on a few weeks while I work out how to do that. :)

Link to comment
Share on other sites

Correct.

First, you’d create a dialog box according to https://docs.microsoft.com/en-us/cpp/windows/creating-a-new-dialog-box 

 

That looks a bit dry without pictures, so I suppose you start at 1:41 here:

 

Skip all that button placement, I guess you don’t need anything besides an OK button. Also skip the Event Handler code etc.

 

In your main, you call DialogBoxParamW() with hInstance = NULL, lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1), parent=NULL, lpDialogFunc = &DefDlgProcW, dwInitParam = 0.

 

IDD_DIALOG1 is the name the resource editor gave to your dialog resource. The dialog should now open normally.

 

This is not fully TFXplorer-alike, but it’s a start. Now we need to get CW_USEDEFAULT16 into the template … let me think about that. If you have a way to enter a size, try entering 0x8000 or 32768. Else, maybe we need to open the .rc file with a text editor and type 32768 manually? I hate Microsoft toolchains so much :D

Link to comment
Share on other sites

I tried that yesterday with some other sample code where the 'About' box is a dialog window. I couldn't find a way to adjust the size by typing numbers into fields in the window properties. I'm sure it's there somewhere as you can't just size things using the mouse...

Anyway, I opened the resource file and the size can be changed using the marked values, in this case x=500, y=200. If I set those those values to 32768 and rebuild, the program doesn't start at all.

abt.png.f8fe366bb19c0c2639876bf98e7c151e.png

Link to comment
Share on other sites

Could you please try changing WS_POPUP to WS_OVERLAPPED in line 74?

 

Pop-up-Windows have some special properties, and CW_USEDEFAULT does not work for them. (I forgot the specific specialities and need to read up on it again when I do proper message boxes!)

 

Edit: This reads like WS_POPUP triggers some technical debt from 1991 :D

Quote

Pop-up windows must not be created with the CW_USEDEFAULT value for either the position or the size of the window. Pop-up windows that use CW_USEDEFAULT will exist but will have no size or no position or both.

 

And this does not sound better:

Quote

 it is a hint to the OS that the window is not likely to be long-lived and thus to save the display area under the window rather than require repainting when the window is dismissed. The window handled by the popup menu loop for example, or dialogs. This used to be a major performance benefit (particularly in the days of win16) when used appropriately


That’s the thing with Win32: There’s so much legacy APIs that you get lost really fast. On the other hand, this legacy code, when used correctly, is incredibly fast, stable, and memory-friendly.

Link to comment
Share on other sites

Yes, that does it.

If I just change to WS_OVERLAPPED I get a 500x200 window in both Win10 and Wine. If I then change the size parameters in that resource file to 32768, 32768, I get a big window in Win10 and a tiny box in Wine when I click the 'About ' button that triggers the dialog window.

 

I'm not sure where I got that tutorial from, although it's pretty basic.

Link to comment
Share on other sites

5 minutes ago, mikew said:

If I then change the size parameters in that resource file to 32768, 32768, I get a big window in Win10 and a tiny box in Wine

How big on windows? Actually 32768² units (~100k² pixels)? Or fitting to the screen?

Link to comment
Share on other sites

Hard to say in the VM world:

Here's a screenshot from Win 10. The dialog is the window with the OK button in it.

abt.png.e15c18d699efb10bb6d8eb2ed900fcff.png

The Win 10 window takes up about 2/3s of this 4k display that the host is using.

Link to comment
Share on other sites

That’s about the same size as TFXplorer and all my other programs normally start. It’s the placement I’d expect from CW_USEDEFAULT.

 

If this fails to display in a similar fashion in Wine, I’d say you have a pretty good isolated test case they should check out!

 

This feature may not be well-known or well-documented, they may say, but you obviously know at least three programs that rely on it and break with Wine ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...