####################
Update: April 14/07
- you can set now default value for input box
####################
Update: April 05/07
- simple standard window menu (File, Session and Help)
####################
Update: March 23/07
- choose color dialog
####################
Hello @All,
I programmed a dll with some functions to create a simple standard window menu and to use a some common dialogs (for example MessageBox, InputBox ...).
PS: For simpler games it will be sufficient.
================================================================
Instructions
This DLL creates a simple standard window menu and allows to use some common dialogs. To use this DLL:
- Put the DLL DBProWinDlg.dll into
.../3d games creator/Compiler/plugins-user, than you can call the DLL directly from you code using dll function name.
- At the moment the DLL provide following 9 functions:
1)
GetActiveWindow() //This function get the DBPro window handle. The handle is needed for most window functions.
2)
GetOpenDirectoryName(DBPro window handle) // This function displays a dialog box enabling the user to select a folder.
3)
InputBox( Window handle, Message, Default value, Title) // The InputBox function displays a dialog box, where the user can write some input and/or click on a button.
4)
GetSaveFileName(Window handle, Title, Filter description, Filte extension) //This function creates a dialog box that lets the user specify the drive, directory, and name of a file to save.
5)
GetOpenFileName(Window handle, Title, Filter description, Filte extension) //This function creates a dialog box that lets the user specify the drive, directory, and name of a file to open.
6)
MsgBox(Message, Title , Icon, Buttons) //This function shows a simple message box and returns a button value.
Note: For Icondescription you can use all win-api icons (MB_ICONHAND, MB_ICONQUESTION, MB_ICONEXCLAMATION and MB_ICONINFO). For buttons you can use MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNO or MB_RETRYCANCEL. Return value are IDOK, IDCANCEL, IDYES, IDNO, IDABORT, IDRETRY or IDIGNORE.
7)
CreateDBProMenu(Window handle) //This function creates a simple standard window menu with following items: File => (Open, Save, Exit), Session => (New) and Help => (Index, About).
8)
GetMessage() //This function gives a selected menu item ID. Following items ID are existing: IDM_OPEN, IDM_SAVE, IDM_EXIT, IDM_NEW, IDM_INDEX and IDM_ABOUT.
9)
DestroyDBProMenu // The function destroys the specified menu and frees any memory that the menu occupies.
DBPro Sample for simple standard window menu
+ Code Snippet//Variables
HWND as dword
sMessage As String
sOpenFile As String
sSaveFile As String
//###############################################################
//Get active window handle (it's DBPro window handle)
HWND = GetActiveWindow()
//###############################################################
//Create Standard Menu
CreateDBProMenu HWND
DO
//Get the current window message
sMessage = GetMessage()
//Check the selected items ID
Select sMessage
Case "IDM_OPEN" //Open file dialog
sOpenFile = GetOpenFileName(HWND , "Open your level" , "Level file (*.txt)" , "txt")
print sOpenFile
Endcase
Case "IDM_SAVE" //Save file dialog
sSaveFile = GetSaveFileName(HWND , "Save your level" , "Level file (*.txt)" , "txt")
print sSaveFile
Endcase
Case "IDM_EXIT" //Exit application
Res$ = MsgBox("Do you want to exit?" , "Exit" , "MB_ICONQUESTION", "MB_YESNO")
If Res$ = "IDYES"
DestroyDBProMenu
exit
Endif
Endcase
Case "IDM_NEW" //Start a new game
Res$ = MsgBox("Do you want to start a new game?" , "New" , "MB_ICONQUESTION", "MB_YESNO")
Endcase
Case "IDM_INDEX" //Show documentation
Res$ = MsgBox("Documentation fpr this game is not available" , "Index" , "MB_ICONINFO", "MB_OK")
Endcase
Case "IDM_ABOUT" //About box
Res$ = MsgBox("This DLL was programmed by daniel_ch" , "About" , "MB_ICONINFO", "MB_OK")
Endcase
Endselect
LOOP
END
DBPro Sample for common dialogs
+ Code Snippet//Variables
HWND as dword
sOpenDir As String
sInputBox as String
sOpenFile As String
sMsgBox As String
sSaveFile As String
//###############################################################
//Get active window handle (it's DBPro window handle)
HWND = GetActiveWindow()
//###############################################################
//Get open directory
sOpenDir = GetOpenDirectoryName(HWND)
PRINT sOpenDir
WAIT KEY
//###############################################################
//Input box
sInputBox = InputBox( HWND,"Pleas put the number or string: " , "default value", "This is a input box")
PRINT sInputBox
WAIT KEY
//###############################################################
//Get save file name
sSaveFile = GetSaveFileName(HWND , "Save your level" , "Level file (*.txt)" , "txt")
PRINT sSaveFile
WAIT KEY
//###############################################################
//Get open file name
sOpenFile = GetOpenFileName(HWND , "Open your level" , "Level file (*.txt)" , "txt")
PRINT sOpenFile
WAIT KEY
//###############################################################
//Message box
sMsgBox = MsgBox("Do you want to save changes?" , "Save" , "MB_ICONQUESTION", "MB_YESNO")
PRINT sMsgBox
WAIT KEY
Documentation
Function: GetActiveWindow
Parameters: no
Parameter descriptions: no
Return value: Window handle As DWORD
Function: GetOpenDirectoryName
Parameters: current window handle As DWORD
Parameter description:
Return value: Selected Path As STRING
Function: InputBox
Parameters: Window handle As DWORD, Message As String, Default Value As String, Title As String
Parameter description: no
Return value: User input As STRING
Function: GetSaveFileName
Parameters: Window handle As DWORD, Title As String , Filter description As String , Filter extension As String
Parameter description: no
Return value: File path As STRING
Function: GetOpenFileName
Parameters: Window handle As DWORD, Title As String , Filter description As String , Filter extension As String
Parameter description: no
Return value: File path As STRING
Function: MsgBox
Parameters: Message As String, Title As String, Icon As String, Buttons As String
Parameter description: For Icons use: MB_ICONHAND, MB_ICONQUESTION, MB_ICONEXCLAMATION or MB_ICONINFO. For
Buttons use MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNO or MB_RETRYCANCEL
Return value: IDOK, IDCANCEL, IDYES, IDNO, IDABORT, IDRETRY or IDIGNORE As String
Function: CreateDBProMenu
Parameters: : Window handle As DWORD
Parameter description: no
Return value: Window standard menu
Function: GetMessage
Parameters: : no
Parameter description: no
Return value: Window message ID: : IDM_OPEN, IDM_SAVE, IDM_EXIT, IDM_NEW, IDM_INDEX and IDM_ABOUT.
Function: DestroyDBProMenu
Parameters: : no
Parameter description: no
Return value: Destroy window standard menu
Last update April 05
Daniel_ch