Posted: 22nd Mar 2007 17:56
####################
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
Posted: 22nd Mar 2007 18:03
If it does what you say it does, excellent work, this'll be an extremely useful tool for those that dont have the money to buy Blue GUI / skill to access windows dlls themselves.

Really good job for just starting out on the forums here.
Posted: 22nd Mar 2007 18:08
Thanks RUCCUS

But you cannot compare this with Blue GUI. Blue GUI support many more as my DLL.
Posted: 23rd Mar 2007 4:33
Nice work, I agree.
Your point is well taken, as BlueGUI differs in many respects from what you are doing so far in this code. However, I still agree with RUCCUS' assessment. Many people only need access to the common dialogs and BlueGUI is overkill for that, imo. (Still, as you pointed out, it is an outstanding product.)
Happy coding!
Posted: 23rd Mar 2007 12:25
Thanks jinzai

I also implement the choose color dialog into my DLL.
Posted: 5th Apr 2007 19:17
Hello @All,

I programmed some new function into my DLL. For example you can create a simple standard window menu with following items:
- File: Open, Save and Exit
- Session: New
- Help: Index and About.

I think, it is a good help for small projects.

daniel
Posted: 5th Apr 2007 20:15
Yes, it is a good project. I only have the one observation, which is those can be used without a plug-in. Write a function to create a window class, and a window. That is what alot of people want.

Does your menu function allow loading a menu resource? THAT WOULD BE USEFUL.

Another thing that you might want to pursue is using the .rc2 file. It is a way that UNICODE strings could be brought in, and also...try to add general UNICODE support. That is sorely needed by Easetern European and Asian coders.
Posted: 21st Jul 2007 22:23
Daniel, this is very good and useful! Great job!

My only concern is that I want the Open File Dialog and Save File Dialog to be able to open and save multiple file types.

Do you think you can do this?
Posted: 21st Jul 2007 23:27
Nice . BlueGUI has no inputbox function, and I'm glad I won't have to figure out how to call it from the Windows API. I've been planning to add an inputbox in my latest project, and this could save a lot of work.

Is there any chance you could add the "Make New Folder" button on the 'GetOpenDirectoryName(DBPro window handle)' box?

Thanks!

Edit: Er... why is the cancel button (on 'inputBox()') not in English for me (it says "Abbrechen")?

-Xol
Posted: 22nd Jul 2007 0:49
Many people only need access to the common dialogs and BlueGUI is overkill for that, imo.

have any of you checked out DBP_NETLIB? It's been around since 2004. Click the link in sig
Posted: 22nd Jul 2007 4:10
I found a great inputBox in your dbp_vb6lib.dll, CattleRustler .
Thanks.

-Xol
Posted: 22nd Jul 2007 5:03
no prob, thanks. the netlib plugin is way better tho, tons of functions for files, strings, dialogs, variable watching, all sorts of
Posted: 22nd Jul 2007 13:38
The GOGAS plug-in has all sorts of common GUI functions too, including message boxes, input boxes, colour boxes, etc.
Posted: 22nd Jul 2007 22:47
I've got netlib too, I just have trouble figuring out what commands are in what dlls . I've downloaded a few too many, I think. Gogas looks nice too.

-Xol