Jump to content
The simFlight Network Forums

Module Code DLL / Window ............Source Code


Was this topic/post helpful??  

9 members have voted

You do not have permission to vote in this poll, or see the poll results. Please sign in or register to vote in this poll.

Recommended Posts

//INCLUDE OUR USUAL GAUGE HEADER FROM FLIGHT SIM SDK
#include "gauges.h"

//THIS WILL TELL FLIGHT SIM THAT WE ARE A COMPATIBLE MODULE/DLL
void FSAPI module_init(void){}
void FSAPI module_deinit(void) {}

GAUGESIMPORT ImportTable = {
    { 0x0000000F, (PPANELS)NULL },			
    { 0x00000000, NULL }				 
};

GAUGESLINKAGE Linkage = {
	0x00000001,
                module_init,
                module_deinit,
                0,
                0,
                0x900,
                NULL
};


//ENTRY POINT OF OUR DLL FILE.....
BOOL APIENTRY DllMain (HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {

 return TRUE;

}

The above code will work with flight sim & stop the "Unknown" module

from appearing when you start flight sim.......

Note this code will not get a handle on flight sim or anything like that...

Just enables flight sim to use this module and thats it...

Seems there is little help around for modules with flight sim and with

hunting around for code related for projects we are currently working on

i figured bout time someone started posting proper examples........

So the above is my first, later tonight or some time soon i will return & post more......

Just a hint for ppl wanting to work with modules.... Look inside of the "Gauge.h" include header as this is how it talks to flight sim...

Anyway wont explain much but this now..

Next lot will be examples and so on...

Note: I've been a self taught programmer for a few years and started C++ one week ago.... :(

So as i find out more i shall share...

If you have any questions.. Feel free to contact me.

******If any of the above code is wrong or something, please post so i can correct it*****

bare required.zip

Link to comment
Share on other sites

  • 2 weeks later...

Below is a another way to create a menu with in the the flight sim callback procedure......

Declare in header area....

HMENU hMenu, hMyMenu; 
#define MENU_ENTRY "MyMenuItem"

Place/Use in callback Procedure

 
case WM_NCPAINT: {
     if (!IsMenu(hMyMenu)) {
          hMenu = GetMenu(hwnd);
          hMyMenu = CreateMenu();
          AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hMyMenu, MENU_ENTRY);
     }
}

Attached is a copy of this code in use witha simple flight sim handle

simplemenu.zip

Link to comment
Share on other sites

With out ppl need or posting questions & code... Wont be able to have a challenge.... If you need help then please post a question & i will see if i can be of help......

Have'nt had the time i expected when comes to updating this page/post...

So when i can i shall post more here, Been thinking bout time tutorial was released in regards to FSUIPC & C++... ....

Anyway just saying if u want code produce, Produce some questions....

Link to comment
Share on other sites

Okay to display a window there a few steps you need todo,

Some/All of them may vary with how you want the window to work....

First of all you need an event to call / create the window...

Most examples of modules will generally be the "Menu Bar" option.

Example, FSUIPC from "modules".

Now the best method i have found for creating a window that will always stay ontop in fullscreen or windowed mode is using a WNDCLASS / WNDCLASSEX

WNDCLASSEX wc;
wc.cbSize        = sizeof(WNDCLASSEX);
wc.style         = CS_VREDRAW | CS_SAVEBITS | CS_OWNDC | CS_HREDRAW;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hMyWindow;
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(cBlackBrush);
wc.lpszMenuName  = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wc);

The above code will create a window class/pointer stye variable... wc

***Remember i've only just started c++ so dont know names of stuff***

Next we want to create a window with a handle using the above *wc*

if (!IsWindow(hWndDialog)) { 
   hWndDialog = CreateWindowEx(WS_EX_TOPMOST, "clsName", "My Window",  WS_VISIBLE | WS_POPUP, 30, 30, 233, 179, hFSimWindow, NULL, hMyWindow, NULL );
 ShowWindow(hWndDialog, SW_SHOW); 
}

The above code will create & show the window if it already has'nt been done so.

*****Above the first section of code you must also create a standalone void/function thingy to handle the window's messages.....*****

***So Insert The Code Below **Above** The Other Two Lots Of Code***

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
 switch(msg) {
  case WM_CLOSE: {
    DestroyWindow(hwnd);
  }
  case WM_DESTROY: {
     PostQuitMessage(0);
  }
  default:
  return DefWindowProc(hwnd, msg, wParam, lParam);
 }
 return 0;
}

The main trick to all of this is that this will create a stand-alone window with it's own message loop as such.... i think... still learning the workings....

So now with a widow created within flightsim as part of it's own "Main Process" & has it's own handle.... "hWndDialog "

***The other thing todo is to declare all of the variable's / types, & includes....

If i have missed anything or anythign is incorrect the please msg/email me or post a reply with the problem/description & i will update this...

Reason i have not attached or given the "Complete Example Module" DLL Source code is because at this stage of coding i beleive if u cant create it with the above snippets of code then there is no point in reading or coding in this area of Flight Sim....... My own personal view.....Plus i am still playing around with this code.

Hopefully this can be of some more help....

Link to comment
Share on other sites

If i dont recieve any feedback then might as well cease this post......

Please don't be discouraged. I suspect most folks who visit here are looking for help with using software rather than writing it, and those who do try writing stuff for FS who come here seem to be mostly using Visual Basic or C# or similar. Those already committed to C/C++ (because they realise how much more powerful and efficient it can be) probably don't think of looking here.

There's an FS programmers Forum I saw over in AVSIM somewhere. Sorry, I've lost the link now, but you might find a more appropriate audience over there. Please do continue here as well, though, if it isn't too much troubleI suspect you have secret admirers who are simply too stunned or shy to comment -- yet! ;-)

Also, it is Summer in the Northern Hemisphere and I've always noticed that a lot of hobbyist programmers are Seasonal -- its a way of occupying the long nights of Winter. I myself suffer from the lack of long nights at present, as I am an "owl" in terms of programming work!

Regards

Pete

Link to comment
Share on other sites

Myself am also a night owl... Simply more quiet & allows more work to be done with less time... Tho dont help with full job during day.... Love the Coffee :shock:

Have looked around at other forums and think i know of the one that you mean.. Just this forum seems tobe better related to the projects i am currently invloved in.

I will continue to post code/work/examples up here along with anything else i think might be of use to people...

I just work better with a challenge... So if ppl request it, i get it done or else i never finish an example/project,,,,,

"True work of art is never complete"

Anyway back to the code.... Is where my mind belongs....

Thanks for you reply pete,

And more so thank you for this useful / time saver interface module

***Also Side/Bottom Note: ****

Anyone who is wanting help with visual basic also msg me if you like, Before my attempts at C++ i started with visual basic & was successful with various area's of thatSuch as GPS tracking via Lat/Long uploaded to a website & viewable by others...

Link to comment
Share on other sites

There's an FS programmers Forum I saw over in AVSIM somewhere. Sorry, I've lost the link now, but you might find a more appropriate audience over there. Please do continue here as well, though, if it isn't too much troubleI suspect you have secret admirers who are simply too stunned or shy to comment -- yet! ;-)

Perhaps I should take the time to "plug" my forum at http://flightsim.com here as well. 8)

The forum at avsim.com is well populated, but mostly by "XML Heads..." and it is also a "modeling forum" as well, which tends to dilute and complicate matters... ;)

So, I started a forum at http://flightsim.com specifically for non-XML folks. It is primarily intended for C++/GDI+ programming, but is also well suited for any projects utilizing anything other than XML. :lol:

The forum name is rather cleverly entitled "Panels and Gauges." Anything posted there that comprises a "tutorial series" will be anchored at the top where it may be found quickly without searching.

Link to comment
Share on other sites

So, I started a forum at http://flightsim.com specifically for non-XML folks. It is primarily intended for C++/GDI+ programming, but is also well suited for any projects utilizing anything other than XML. :lol:

The forum name is rather cleverly entitled "Panels and Gauges." Anything posted there that comprises a "tutorial series" will be anchored at the top where it may be found quickly without searching.

Thanks for the information! I may nip over there and take a look myself! ;-)

Regards,

Pete

Link to comment
Share on other sites

So, I started a forum at http://flightsim.com specifically for non-XML folks. It is primarily intended for C++/GDI+ programming, but is also well suited for any projects utilizing anything other than XML. :lol:

The forum name is rather cleverly entitled "Panels and Gauges." Anything posted there that comprises a "tutorial series" will be anchored at the top where it may be found quickly without searching.

Thanks for the information! I may nip over there and take a look myself! ;-)

Regards,

Pete

Thanks, Pete. It's not yet a year old, so it's still in the "growing stages." I probably need to spend some time updating some of the topics to make 'em easier to find... ;)

Link to comment
Share on other sites

  • 1 month later...

***Also Side/Bottom Note: ****

Anyone who is wanting help with visual basic also msg me if you like, Before my attempts at C++ i started with visual basic & was successful with various area's of thatSuch as GPS tracking via Lat/Long uploaded to a website & viewable by others...

Hello,

I'm currently trying to develop an addon for MFS and I would want to make it with a DLL. I'm using Visual Basic .net, not so difficult...

But when FS is loading it says me that there is an unknown modulo.

Your code is useful, but I'm using visual basic .net so my question is, is there a similar code for VB ?

So can we make FS to accept VB DLL as modulo ? Can we add a menu item with VB ? Can we draw a window who will be always on top whenever FS is in fullscreen or in windowed mode ?

Thank you for your help,

Link to comment
Share on other sites

As far as i have seen everywhere people are saying visual basic can not

be used to make dll files?? (But i do not know about vb.net)

I have not bothered with trying it yet, But have wondered how a C# / C++ wrapper dll would go with being a "Controller" for the visual basic dll.

Simply added/incuded (resource file) or linked to..

Would this not give the same effect as using a visual basic dll??

Could setup main interfaces & then just code the main engine / dll

and re-include it to the main project each time for testing?

I know is double handlering & slower but may be a quick fix for people

wanting to use visual basic with FS2004 Modules..

One other note, I fould C++ easy to create a window in FS2004 (fullscreen mode) that would would always stay on top, not stop

the sound & seems not to slow down the frame rate or speed

of the over all game..

Since the above code i have refined it down even more, quicker &

compatible..

I have been using visual basic 6 for about two years and could produce

a perfect window for FS2004 when in "Window Mode", fullscreen would

either disapear or flicker depending on the methods.

So just for the use of FS2004 i decided to learn how to code with

MS Visual C++ 6, Closest language i knew was PHP (bout 6 months)

Found the standard code out there that & started with the "Menu Bar"

items.

After a week had a window that would work in fullscreen, no flicker....

But was focus, sound, lag, redraw & other problems...

After about another week got all that sorted out & had a window

that would work without any problems... that i know of...

Few more days to figure out how to hide the blue "Title bar" & make

it moveable by the mouse. (Changed recently to calculate movements by the mouse cursor X, Y)

Anyway after reading around about vb/c#/c++/perl and so on i decided

to see how quick i could get it all going...

Everything i have learnt with coding has been in the last three years,

never done one course or trainning. Simply looking at referenced &

reading other peoples code.

I dont like to copy, so i learn quickly & re-produce it to my likings..

At least that way if i do plan on making it availiable to other people there

is no need to change the code. On this note i dont mind helping people who are willing to contact me via email with the question in greater detail.

I can not promise answer straight away, But i love a challenge. I am

willing to provide small example code that people are free to use how

they wish, just as long as they dont write it off as their own.

Link to comment
Share on other sites

As far as i have seen everywhere people are saying visual basic can not

be used to make dll files?? (But i do not know about vb.net)

I thought we could do that using class library...

So just for the use of FS2004 i decided to learn how to code with

MS Visual C++ 6

I think i will start learning it too, maybe it will be easier and better to make what i want to do.

I think we can add modulo into FS using VB by coding an ActiveX and using something like FSINN (http://www.mcdu.com).

But we are dependant of FSINN to display and to use this modulo.

Thanks a lot for your answer,

Link to comment
Share on other sites

  • 3 weeks later...
Of course, people might also just be 'gobsmacked' that Mayhem came and posted on this forum at all after his attack on Pete's "rip-off" over on the FDS site........

Really? I suppose, then, it's a good job I don't browse other sites! :wink: (I don't like getting upset).

Regards,

Pete

Link to comment
Share on other sites

This Did Not Imply FSUIPC, There Are Plenty Of Modules Out There

http://forum.flightdecksoftware.com/viewtopic.php?t=287

First of all, Greate job with giving the fs community a "Non" rip of module for all our needs.... Compaired to other modules......

I said other module's, Did not give names.... Referring to other applications & modules out there i have seen that are not worth the time.

Link to comment
Share on other sites

Don't be disingenuous, Mayhem.

The post was in the FDSConnect forum on the Flight Deck Software site. FDSConnect was written solely as a replacement for FSUIPC, no "other module" has the same function as FSUIPC, and the entire Glass Flight Deck / Flight Deck Software site is just awash with references to Pete's decision to start having a registered version of FSUIPC being a "rip off".

There's no confusion in the mind of anyone reading the post what the "rip off" comment was meaning.

Richard

Link to comment
Share on other sites

I cam across FSDConnect before i found FSUIPC, I had heard the name FSUIPC mention around and did'nt look into it because at the time i was trying FSDConnect and had no need to look for other software...

The other modules i refer to have been other people's module made with either FSUIPC, FDSConnect or with there own methods of reading memory locations...

While FSDConnect & FSUIPC are in the same market / group as one another they are more or less the same just FSUIPC being more complete. People's choice to have their software available for free or paid download are entierly upto them.

When i refer to "Rip Off" i mean something that has been advertised for being able to complete or help in such task yet do not live upto there name...

I do not mention names because it is simply rude to slander people's software based apon your own use & view of the operatings...

I simply choose not use it & find something that fits my needs.

In the end it came down to developing our own software & then it came to FSDConnect & FSUIPC.

With out mention of what company & software packages i was refering to or what needs i had that needed to be filled, please dont assume that it was FSUIPC

Please also note i said "Modules" not "Module" refering to more then one that i had tried.

Since i have started using FSUIPC & from the "First" time i started using FSUIPC i have tried to help others where it is needed.

How others view the comment is upto them same as it is upto you how you have viewed / interpreted the comment. But if others have the same view they may tell me direct or comment for them self.

Tried to help people only to have them bring you down.

Link to comment
Share on other sites

How others view the comment is upto them same as it is upto you how you have viewed / interpreted the comment. But if others have the same view they may tell me direct or comment for them self.

Tried to help people only to have them bring you down.

Please don't get upset. I wouldn't have been particularly upset even if you had been referring to FSUIPC in any case. Folks are entitled to their point of view. In any case, a lot of the adverse initial reaction when I "went payware" was based on a complete misunderstanding. As far as the interfafe to FS was concerned it was and still is free for Freeware, and negotiated for Payware -- just as Adam Szofran's original FS6IPC module was, in fact.

The only thing I've been charging for, so that I could afford to carry on developing (and it IS a full time job) are the additional user facilities which user registration provides. Despite this being explained very carefully right at the start, many folks did decide to keep their blinkers on and only see that money was involved, now, whereas, as they thought, it wasn't before.

Regards,

Pete

Link to comment
Share on other sites

Not upset, Just like to explain myself...

When i speak / type i can some/most times no make sense as i think ahead & skip words & other things like that...

Have understood from the start when firsy saw FSUIPC that it was free & payware as such.. Example freeware applications supplied with out "Any" cost invloved...

Simply i do not keep using software i dislike.... Unless trapped by certain requirements... eg Windows... To me most MS Software is bugware... But thats another forum & story...

Just wanting to point out FSUIPC is not the package / module i was refering to as "Rip" off.

For FSUIPC i have always like & more so the idea that you are willing to supply the freeware keys for people willing to contiune the use of freeware... So between your's & their time i must thank you all

Anyway just to clear things up. Am not upset nor anything else about this matter... Just like to clear things up or explain things as much as i can..

Link to comment
Share on other sites

  • 4 weeks later...

Good day all,

I found this post browsing the web searching informations about the modules of FS...

In a first time, my purpose is to write a module in Delphi wich does... nothing, but be loaded by FS without problem. I have not been able to find any information in the FS SDK, or pehaps I was not at the right place.

Finding this post, I thought that perhaps I could be pointed in the right direction... What is the basic strucure of a module ? I suppose it does export some functions for initialize and close ? Where is it documented ?

Thanks by advance for any help,

Best regards,

Robert

Link to comment
Share on other sites

Here's a C++ project that will create an fs dll, add itself to the menu and open a blank dialog box in the fs window when selected.

In the "GAUGES linkage =", 0x900 needs to be added as stated in the 1st post here to avoid the incompatable dll warning in fs9.

I am fairly sure vb can't be used to make an fs module dll. A low level language like c is needed.

ModuleSource.zip

Link to comment
Share on other sites

Thanks for this answer and the attached file but... I cannot dowload it... none of the lines are "clickable". Is there something special to do for unlock the downloading ?

Regards

Robert.

PS: I use Delphi wich can build DLL, but don't know yet if it as all the capabilities for this kind of DLL...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.