• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX:SE Using timers

Messages
531
Country
france
Hello experts,

For those of you who develop in C/C++ using the Windows API, I would like to share a problem I had.
I am developing a DLL module that is loaded when FSX starts, it gets the FSX window handle to get the messages such as key up/down events to manage them. In addition, I had to use a timer that I set with the SetTimer function, easy. Usually I use this function with the timer proc set to NULL, which means the timer sends a WM_TIMER event to the window at each timer period, something like:
Code:
SetTimer(hFSimWindow, 0, 50, (TIMERPROC)NULL);
It usually works fine, in this case the window receives a WM_TIMER event every 50 ms. But this time, it didn't and I can't understand why. I put a trace when the WM_TIMER event occurs, and it shows only one. Strange... I changed the timer creation in order to call a static function instead, something like:
Code:
SetTimer(hFSimWindow, 0, 50, (TIMERPROC)tick);
And it works this way, the "tick" function is called every 50 ms. I can consider the problem is solved but I am not very happy about this workaround. I'd rather manage the timer with a window event as I usually do.

Do you have any idea why one mode works and not the other? Did you ever have the same problem?

Thanks,
Eric
 
It was just because WINVER was not set with the correct value. Setting it to 0x601 solved the problem.
Windows development is painful sometimes...
 
Uh... so what do you do if another module wants to intercept the main window messaging? :)
 
Each time I create a new window proc to intercept the messages, I called the existing one at the end of my process. I have several modules that work this way with my FSX, it works perfect
 
But.. what if the other module wants control of the keys?

I guess my point is... a module shouldn't be "in control" at all times... it can mess with other addons with regards to keyboards, controllers, etc. Just my $0.02
 
Last edited:
I have several modules: 1 is a moving map and the only key used is F5 to show/hide the map, 1 is a camera that uses the mouse (and possibly 2 keys for up/down movement).
If another module wants to use keys, it will work if the keys used by all modules are different. In case of a problem, I can change the assignment.

But you are right, a conflit is possible and I should care about that.

Eric
 
Back
Top