Mirage Engine
How to load GUI through code - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: How to load GUI through code (/showthread.php?tid=1463)



How to load GUI through code - Stomach Pulser - 15-12-2007

OK. This is a very simple tutorial. It will allow you to load a GUI when the form loads, so that you don't have to change it constantly at run time. To change a form's GUI, all you need to do is edit the GUI itself (outside mirage, such as in paint). And the changes will be made.

Difficulty 1/5 (C + P): My Second Tutorial

All Client Side
First off, we need to declare some variables.
Go into ModConstants and find
Code:
' Gfx Path and variables

Add this right below
Code:
Public Const GFX_GUI = GFX_PATH & "GUI\"

Now, go into modGameLogic and add this to the very bottom
Code:
Sub LoadGui(ByVal curForm As Form, ByVal locGUI As String)
    curForm.Picture = LoadPicture(App.Path & GFX_GUI & locGUI)
End Sub

OK. Now, for every form that you wish to add this GUI loader, call this in your Form_Load.
The final part it to open your GFX folder and add a new folder called "GUI". Inside there, put all of you GUI components.

An example from my frmMainMenu
Code:
Private Sub Form_Load()
    Call LoadGui(Me, "menu.bmp")
End Sub

It calls on Load_GUI and says that I am the current form (Me, means the object that the sub is placed in, which is, in this case the frmMainMenu). Then, I placed "menu.bmp" in there because that is what I want to load. You can change it to any name and any picture file type (such as .jpg, .gif, .png).

Challenge:
In Sub LoadGUI, use the Select Case function to load every forms graphics so that you can simply call the function and it will do everything else.


Re: How to load GUI through code - Robin - 15-12-2007

win32 ftw.