1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to make dll's

Discussion in 'Tools programming' started by mcq, 10/8/05.

  1. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    Hi there!

    I ever want to ask: how can I make myself a nice plugin-dll like FSUIPC, FSPassenger, your ActiGate & Co? Which language these programmers use and where can you get an SDK for these DLL's?

    I know, it has only a little bit in common with scenery design, but although I wanted to ask it here, because I know you, arno, made such a plugin-dll (ActiGate)!

    Yours,

    Marcel
  2. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    Hi Marcel,

    They are made in C. I have found a few example DLLs for FS on the internet and I used these as a basis for ActiGate.

    But I don't find myself a real expert on this yet. For example I am still trying to let the DLL read the FS memory directly. I lack a bit in C DLL programming experience :).
  3. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    Thanks....

    OK, that's a good answer; even if there seems to be NO SDK... ;)

    Marcel
  4. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    No, forgot to mention there. There is absolutely no SDK :D.
  5. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    But where can I generally find source code of such dll's? (Like you found)?

    Btw.: Your ActiGate is a nice and powerfull idea, even if it just works while the user has the dll installed; but I cannot find my Britten Norman Islander ;)
  6. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    Have a look at the names I mentioned in the ActiGate docs. I can't remember them now, but I think if you Google on them you should find something.

    About the Islander, well that is not really the type of aircraft you see often on civil airport (and certainly not near gates/docking systems). So therefore I did not add it. But if enough people start asking, it might end up in a future version :).
    Last edited: 15/8/05
  7. rhumbaflappy

    rhumbaflappy Moderator Staff Member Resource contributor

    Joined:
    2/6/04
    Messages:
    2,520
    Country:
    us-wisconsin
    Hi mcq.

    This is also posted at AVSIM.

    At the avsim library, Cyril Hruscak has some examples of modules. Using his fsmenu.zip as a basis, I come up with this:

    Code:
    #include <windows.h>
    #include "gauges.h"
    
    /* This is the module's import table.	*/	\
    GAUGESIMPORT	ImportTable =			\
    	{					\
    	{ 0x00000000, (PPANELS)NULL },		\
    	{ 0x00000000, NULL }			\
    	};	\
    		\
    		\
    
    void FSAPI module_init(void) {}
    void FSAPI module_deinit(void) {}
    
    /* This is the module's export table.	*/	\
    GAUGESLINKAGE	Linkage =			\
    	{					\
    	0x00000000,				\
    	module_init,				\
    	module_deinit,				\
    	0,					\
    	0,					\
    	GAUGE_HEADER_VERSION_FS900, {0}
    	};
    
    // The standard window procedure used by the flight simulator
    WNDPROC oldWndProc;
    
    // Flight simulator main window handle
    HWND hFSimWindow;
    
    #define	MENU_ENTRY	"My Mo&dule"
    #define	ID_MY_MENUITEM	40001
    
    /**
     * Main window procedure that is called by the flight simulator to process
     * incoming window messages.
     */
    LRESULT CALLBACK FSimWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg) {
    		case WM_NCPAINT:
    			{
    				HMENU hMenu, hMyMenu;
    
    				hMenu = GetMenu(hwnd);
    				if (hMenu != NULL) {
    					int i;
    					// Look for our menu entry in the main menu.
    					for (i = 0; i < GetMenuItemCount(hMenu); i++) {
    						char buf[128];
    						GetMenuString(hMenu, i, buf, 128, MF_BYPOSITION);
    						if (strcmp(buf, MENU_ENTRY) == 0) {
    							// It is already here, we do not need to add it again
    							break;
    						}
    					}
    					if (i < GetMenuItemCount(hMenu)) {
    						// It is already here, we do not need to add it again
    						break;
    					}
    					/* Create new menu. NOTE: It seems that this will be
    					 * reached more times, so we cannot save the handle, because
    					 * in such case it could be destroyed and we will not have
    					 * any access to it in the simulator.
    					 */
    					hMyMenu = CreateMenu();
    					AppendMenu(hMyMenu, MF_STRING | MF_ENABLED, ID_MY_MENUITEM, "My &First Menu Entry");
    					// add the created menu to the main menu
    					AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hMyMenu, MENU_ENTRY);
    				}
    			}
    			break;
    		case WM_COMMAND:
    			if (LOWORD(wParam) == ID_MY_MENUITEM) {
    				// Add your code here
    				MessageBox(hwnd, "It works!", "HURA", MB_OK | MB_ICONEXCLAMATION);
    				return 0;
    			}
    			break;
    	}
    	// Call the original window procedure to handle all other messages
    	return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
    }
    
    /**
     * Entry point of the DLL.
     */
    BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
    {
    	switch (fdwReason) {
    		case DLL_PROCESS_ATTACH:
    			hFSimWindow = FindWindow("FS98MAIN", NULL);
    			oldWndProc = (WNDPROC)SetWindowLong(hFSimWindow, GWL_WNDPROC, (LONG)FSimWindowProc);
    			break;
    	}
    	return TRUE;
    }
    

    This module uses only "windows.h" and the SDK's "gauges.h" for includes. I compiled this as a DLL, with the Visual C++ Express Edition beta, and it works as indicated.

    Cyril uses a "modules.h" for his code, but it is not needed in the above example.

    I converted this to use "gauges.h" because Module DLLs are basically a gauge, and I wanted to show this. By using gauges.h, many variables would now be available for the module, without needing to use an IPC ( such as FSUIPC ).

    ============================================

    Another source of module info can be found at:

    http://www.flightdecksoftware.com/downloads.php

    The "cvs" download can get you the code for their FDSConnection.dll... an ipc to the flight simulator. I used that code as a basis to compile a CFS2 version of FDSConnection... without problem.

    Dick
  8. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    Thanks Dick, this is interesting. Maybe I can drop the use of FSUIPC now as well. Will take a look at this :).
  9. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    Yes, that's really interesting!

    @arno: ok, islanders need no docking system, but they are NOT general aviation but airline aircrafts! :cool:
  10. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    HEY MAN! I CAN'T BELIEVE IT! I'VE COMPILED MY VERY VERY FIRST DLL FOR FS!!!!

    :rotfl: :rotfl: :rotfl: :rotfl: :rotfl: :rotfl:

    BUT (ok, that's normal that there must be a "but" ;) ):

    FS says that perhaps there is an uncompatible module instaled; should he load it?!?

    So, my first question: How can I say FS, that my module is definitive compatible? (Perhaps anywhere a version number or something like that?)

    But, that I must say: it is easier than I thought!!
    :teacher:
  11. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    An additional Question:

    I'm mainly interested in improving my scenery via dll's, so my question is:

    Does anybody know, how you can place any 3D object (e.g. from an mdl-library) with a dll, e.g. to place an airplane like FSTraffic or a car etc. like in EMMA Field?

    Or perhaps anybody know, how I can access to DirectSound to play a *.wav like in FSSoundScape?

    Or are these all questions nobody has an answer for? :(

    Marcel
  12. rhumbaflappy

    rhumbaflappy Moderator Staff Member Resource contributor

    Joined:
    2/6/04
    Messages:
    2,520
    Country:
    us-wisconsin
    Hi Marcel.

    I think there is a line you can add to FS9.cfg to make "incompatible" gauges work... search the AVSIM forums.

    For sound, check out Jose Oliviera's website:

    http://www.jcboliveira.flysplash.org

    As far as placing objects... who knows? ABACUS is supposed to be releasing a program that will allow adding objects and effects to program interactively, then create a BGL file for future use or distribution. But, it isn't released yet. When it is, it's probably one program I'll actually buy. :)

    http://www.abacuspub.com/catalog/s600.htm

    They say soon, but they have been saying that since April 9, 2005!

    Dick
  13. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    First of all: Thanks for the intersting sound-link (I mean José's link)!

    But I think, you misunderstood me a little bit:

    My dream is a module which places DYNAMICALLY 3D objects; just think of this: you've arrived with you aircraft on an airport and are parking anywhere; but the bus "sees" you and drives automatically to your parking position...!

    For this case, you need the possibility to place a 3D object instantly to a special point in the coordintates system...

    Marcel
  14. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    Hi Marcel,

    I have never seen a way to do that. It is possible, because LAGO is also doing it with their Enhancer. But I don't think it is easy. Somehow you need to add the objects to FS at runtime. I guess we would have to know a lot more about the FS structure to be able to do that, but without a nice SDK I expect it is hard to achieve.
  15. rhumbaflappy

    rhumbaflappy Moderator Staff Member Resource contributor

    Joined:
    2/6/04
    Messages:
    2,520
    Country:
    us-wisconsin
    Hi Marcel.

    I recall a trhead at AVSIM's "MSFS Aircraft and Panel Design Forum" that indicates this is possible using DirectX commands from within a gauge. You'll have to search for that. But, I also recall there is no example for it.

    Dick
  16. Horst18519

    Horst18519 Moderator Staff Member Resource contributor

    Joined:
    7/4/05
    Messages:
    2,183
    Country:
    germany
    Oliver Pabst has done this great job at his EDDW-airport. If I'd be a bit more experienced with C I'd love to try those things too. :eek:

    I think, the biggest problem with this matter is that you won't be able to synchronise AI and other dynamic objects in FS - at least not with FS9. :D
  17. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    EXACTLY that I meant! Does anybody know how he made his EDDW-scenery?

    :scratchch :scratchch :scratchch :scratchch :scratchch :scratchch :scratchch


    (I mean the dynamic objects, of course...)
  18. Horst18519

    Horst18519 Moderator Staff Member Resource contributor

    Joined:
    7/4/05
    Messages:
    2,183
    Country:
    germany
    I think there's only one who knows. :D ;)

    by the way: Your ostfriesland-scenery and the Britten Norman are awesome! :)
  19. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,300
    Country:
    netherlands
    Hi Marcel,

    I don't know exactly how he made the EDDW scenery (he never wanted to really tell that :)), but I am very sure that he is only using the section 15 dynamic scenery. No special DLL or what every is used. Just very smart checks within the dynamic scenery.
  20. mcq

    mcq

    Joined:
    7/4/05
    Messages:
    46
    Country:
    germany
    I've downloaded his scenery, but I found any dll, too, so I also believe that he just uses bgl's;

    Interesting is how he made the trucks coming to your aircraft; with many tiny check areas and many different paths for each possible position you could park?? But then he needs thousand of paths...

    :stirthepo

    BUT: He has a config-file which includes all aircraft types... the interesting question now is how he loads THIS file within bgl files...???

    I cannot understand why there are persons, who like it, that anybody want to know how they made this and that, but they won't tell...

    That's like if you're talking to a magician... :wizard: (he won't tell it, too! ;) )

Share This Page