![]() |
General - AlertMessage - Printable Version +- Mirage Source (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: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51) +----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44) +------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13) +------ Thread: General - AlertMessage (/showthread.php?tid=3267) |
General - AlertMessage - Jacob - 30-10-2009 This tutorial is a form that will allow a Yes/No or Okay button to be displayed and allow the game to continue processing while waiting on a response. I would like to thank Robin for the base form that I used to create this. This works by passing in the memory address of a sub or function to run when the user clicks a button on the frmAlert. I use CallWindowProc to create a sort of call back function, just like the byte array packets. ![]() Adding to your project: Download the following form and add it to your project. http://www.deadnoggin.com/files/frmAlert.frm This is the code for the form (just in case anyone would like to see it) Code: Option Explicit Add the following code to modGameLogic: This code creates a new form for every alert message. This allows multiple AlertMessages at once. Code: Public Sub AlertMessage(ByVal message As String, Optional ByRef callBack As Long, Optional ByVal OkayOnly As Boolean = True) These consts are used by the form, so make sure you have them in your source somewhere. Code: Public Const NO As Byte = 0 How to use: To use this alertmessage feature, you call the sub as follows: Code: AlertMessage "Whatever you want to appear", AddressOf sub/function to run when clicked, only display Okay or Yes/No Example (For MR) Code: AlertMessage Name & " has offered to revive you. Do you accept?", AddressOf Revive_Click, False To handle the click event: All click events HAVE TO HAVE THESE EXACT PARAMETERS OR IT WILL NOT WORK! Code: Public Sub *_Click(ByVal YesNo As Long, ByRef Data As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Example (For MR) Code: Public Sub Release_Click(ByVal YesNo As Long, ByRef Data As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) |