Mirage Source http://www.miragesource.net/forums/ |
|
General - AlertMessage http://www.miragesource.net/forums/viewtopic.php?f=183&t=6370 |
Page 1 of 67 |
Author: | Jacob [ Fri Oct 30, 2009 3:14 pm ] |
Post subject: | General - AlertMessage |
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 Private Declare Function AlertCallBack Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByRef Msg As Byte, ByVal wParam As Long, ByVal lParam As Long) As Long Public OkayOnly As Boolean Public sMessage As String Public YesNo As Byte Public callBack As Long Private Sub Form_Load() If OkayOnly Then lblOkay.Visible = True Else lblYes.Visible = True lblNo.Visible = True End If lblMessage.Caption = sMessage End Sub Private Sub lblNo_Click() YesNo = NO ProcessClick End Sub Private Sub lblOkay_Click() YesNo = OKAY ProcessClick End Sub Private Sub lblYes_Click() YesNo = YES ProcessClick End Sub Private Sub ProcessClick() ' Make sure there is something to call back to If callBack <> 0 Then AlertCallBack callBack, YesNo, 0, 0, 0 Unload Me End Sub 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) Dim myForm As New frmAlert myForm.sMessage = message myForm.OkayOnly = OkayOnly myForm.callBack = callBack myForm.Show End Sub These consts are used by the form, so make sure you have them in your source somewhere. Code: Public Const NO As Byte = 0 Public Const YES As Byte = 1 Public Const OKAY As Byte = 2 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) ' Check the YesNo for your value then process End Sub Example (For MR) Code: Public Sub Release_Click(ByVal YesNo As Long, ByRef Data As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
If YesNo = YES Then SendRelease End If End Sub |
Author: | wanai [ Sun Jan 09, 2022 4:43 pm ] |
Post subject: | Re: General - AlertMessage |
Econ |
Author: | wanai [ Sun Jan 09, 2022 4:45 pm ] |
Post subject: | Re: General - AlertMessage |
127.8 |
Author: | wanai [ Sun Jan 09, 2022 4:46 pm ] |
Post subject: | Re: General - AlertMessage |
Bett |
Author: | wanai [ Sun Jan 09, 2022 4:47 pm ] |
Post subject: | Re: General - AlertMessage |
Bett |
Author: | wanai [ Sun Jan 09, 2022 4:48 pm ] |
Post subject: | Re: General - AlertMessage |
Gran |
Author: | wanai [ Sun Jan 09, 2022 4:49 pm ] |
Post subject: | Re: General - AlertMessage |
Alle |
Author: | wanai [ Sun Jan 09, 2022 4:50 pm ] |
Post subject: | Re: General - AlertMessage |
Jewe |
Author: | wanai [ Sun Jan 09, 2022 4:51 pm ] |
Post subject: | Re: General - AlertMessage |
Marg |
Author: | wanai [ Sun Jan 09, 2022 4:52 pm ] |
Post subject: | Re: General - AlertMessage |
Fran |
Author: | wanai [ Sun Jan 09, 2022 4:54 pm ] |
Post subject: | Re: General - AlertMessage |
Alwa |
Author: | wanai [ Sun Jan 09, 2022 4:55 pm ] |
Post subject: | Re: General - AlertMessage |
Naru |
Author: | wanai [ Sun Jan 09, 2022 4:56 pm ] |
Post subject: | Re: General - AlertMessage |
Prem |
Author: | wanai [ Sun Jan 09, 2022 4:57 pm ] |
Post subject: | Re: General - AlertMessage |
Deko |
Author: | wanai [ Sun Jan 09, 2022 4:58 pm ] |
Post subject: | Re: General - AlertMessage |
Orie |
Author: | wanai [ Sun Jan 09, 2022 4:59 pm ] |
Post subject: | Re: General - AlertMessage |
Haro |
Author: | wanai [ Sun Jan 09, 2022 5:00 pm ] |
Post subject: | Re: General - AlertMessage |
sing |
Author: | wanai [ Sun Jan 09, 2022 5:01 pm ] |
Post subject: | Re: General - AlertMessage |
Maki |
Author: | wanai [ Sun Jan 09, 2022 5:03 pm ] |
Post subject: | Re: General - AlertMessage |
Rond |
Author: | wanai [ Sun Jan 09, 2022 5:04 pm ] |
Post subject: | Re: General - AlertMessage |
Sent |
Author: | wanai [ Sun Jan 09, 2022 5:05 pm ] |
Post subject: | Re: General - AlertMessage |
Blin |
Author: | wanai [ Sun Jan 09, 2022 5:06 pm ] |
Post subject: | Re: General - AlertMessage |
Robe |
Author: | wanai [ Sun Jan 09, 2022 5:07 pm ] |
Post subject: | Re: General - AlertMessage |
John |
Author: | wanai [ Sun Jan 09, 2022 5:08 pm ] |
Post subject: | Re: General - AlertMessage |
Extr |
Page 1 of 67 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |