Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MingW] error: 'WM_MOUSEHWHEEL' was not declared in this scope #1704

Closed
Oldes opened this issue Mar 28, 2018 · 6 comments
Closed

[MingW] error: 'WM_MOUSEHWHEEL' was not declared in this scope #1704

Oldes opened this issue Mar 28, 2018 · 6 comments

Comments

@Oldes
Copy link

Oldes commented Mar 28, 2018

Compiling directX demos using MingW failes on missing WM_MOUSEHWHEEL definition.

x:\mingw64\bin\g++.exe  imgui\examples\directx9_example\imgui_impl_dx9.cpp -c  -o imgui_impl_dx9.o -Iimgui  -ld3d9
imgui\examples\directx9_example\imgui_impl_dx9.cpp: In function 'LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM)':
imgui\examples\directx9_example\imgui_impl_dx9.cpp:256:10: error: 'WM_MOUSEHWHEEL' was not declared in this scope
     case WM_MOUSEHWHEEL:
          ^~~~~~~~~~~~~~

Possible fix is adding this code into header file:

#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL                  0x020E
#endif

With this code it is possible to compile the demo without any other problems.

ocornut added a commit that referenced this issue Mar 28, 2018
@ocornut
Copy link
Owner

ocornut commented Mar 28, 2018

Thank you @Oldes, this is now fixed in all examples.

I have a serious question even though it may look provocative or troll-ey, but why does ANYONE uses MingW? A good portion of the problems we have with building Windows examples are related to MingW, it's seems absurdly limited and stuck in the past. Is there any reason why a simple define that Microsoft added in 2007 wouldn't be supported by your version of MingW? Which version of MingW are you using? I am missing part of the picture here?

@ocornut ocornut closed this as completed Mar 28, 2018
@Oldes
Copy link
Author

Oldes commented Mar 29, 2018

Above was with this version:

g++.exe (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.

For me MingW is a cross-platform compiler, I can use it to compile Windows app from Linux.. for example.

I just searched MingW files for the WM_MOUSEWHEEL define, and it is included in winuser.h file, but under condition:

#if _WIN32_WINNT >= 0x0600
#define WM_MOUSEHWHEEL 0x020e
#endif

So it is quite possible that better fix would be to do the same check in imgui source (where it is used) and remove the proposed fix above as it is more as a hack now.

Oldes added a commit to Oldes/imgui that referenced this issue Mar 29, 2018
@Flix01
Copy link

Flix01 commented Mar 29, 2018

@Oldes: AFAIR that's just happening because WM_MOUSEWHEEL was introduced only after WindowsXP.

Usually when you program for Windows you specify your target version globally or in some kind of precompiled header through the two definitions WINVER and _WIN32_WINNT.

Please see: https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt.

If you #define WINVER 0x0501 (or bigger) globally, then WM_MOUSEWHEEL should be present.

P.S. Mingw can still be useful to cross-compile for Windows (64 or 32 bit) from other systems.

[Edit:] Probably now everybody knows this already...

@ocornut
Copy link
Owner

ocornut commented Mar 31, 2018

Probably now everybody knows this already...

Well I didn't (but I am not a MingW user) and apparently other people don't, so it's good you posted that because next that I'll have an answer. I am finding it a little silly that MINGW doesn't doesn't so the latest version it supports.

@Flix01
Copy link

Flix01 commented Mar 31, 2018

[Edit:] Probably now everybody knows this already...

@ocornut: I just meant the cross-compilation part, because I missed @Oldes's answer about that.
I didn't mean to be ironic in any way. Sorry.

I am finding it a little silly that MINGW doesn't set them to the latest version it supports.

Yes, but I'm not sure that all the older cl.exe compilers set these definitions in the correct way too.
I think that perhaps that used to be the default many years ago (when I still used Windows).

@ocornut
Copy link
Owner

ocornut commented Apr 2, 2018

The default value for e..g _WIN32_WINNT is set Microsoft's `<windows.h> to the latest supported SDK version, so it's surprising that MinGW doesn't do it.

In theory, we should be explicitly setting _WIN32_WINNT everywhere in the examples but this is just getting in the way of experimentation with modern stuff (e.g. DPI, DWM for viewport/docking).

The proposed change in #1708 is the theorical correct thing but in practice it seems that every portable application are defining chunks of windows header and use DLL loading themselves (as we are doing in the viewport branch) to allow compiling with older SDK (my current oldest target is VS2010) so it's fine to keep doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants