Results 1 to 11 of 11

Thread: DialogBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253

    DialogBox

    Anyone know the VB declaration of DialogBox?

    here it is in C++

    INT_PTR DialogBox(
    HINSTANCE hInstance, // handle to module
    LPCTSTR lpTemplate, // dialog box template
    HWND hWndParent, // handle to owner window
    DLGPROC lpDialogFunc // dialog box procedure
    );
    Always looking for a better and faster way!

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Depends on which one:
    • Declare Function ChooseColor Lib "comdlg32.dll" alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
    • Declare Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As CHOOSEFONT) As Long
    • Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
    • Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
    • Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
    • Declare Function PrintDialog Lib "comdlg32.dll" Alias "PrintDlgA" (pPrintdlg As PRINTDLG_TYPE) As Long
    Last edited by alex_read; Dec 7th, 2001 at 04:21 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    In addition to the ones Alex mentioned, there is
    VB Code:
    1. Private Declare Function CreateMenu Lib "user32" Alias "CreateMenu" () As Long
    2. Private Declare Function CreatePopupMenu Lib "user32" Alias "CreatePopupMenu" () As Long
    3. Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
    4. Private Declare Function PrinterProperties Lib "winspool.drv" Alias "PrinterProperties" (ByVal hwnd As Long, ByVal hPrinter As Long) As Long
    5. Private Declare Function SetTimer Lib "user32" Alias "SetTimer" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    to name just a few. As Alex said, "Depends on which one"

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253
    Thats not quite what i was looking for I am trying to create a Modal window on top of another window and reactivate the old window when the modal window is detroyed. Here is how i do that:

    mlngMain is the main window
    VB Code:
    1. Option Explicit
    2.  
    3. Private mlngSetup As Long
    4.  
    5. Public Sub ShowSetup()
    6. Dim typClass As WNDCLASSEX
    7. Dim typMessage As MSG
    8.  
    9. With typClass
    10.     .cbSize = Len(typClass)
    11.     .lpfnWndProc = GetWndProc(AddressOf SetupProc)
    12.     .hInstance = glngApp
    13.     .hIcon = LoadIcon(0&, IDI_APPLICATION)
    14.     .hCursor = LoadCursor(0, IDC_ARROW)
    15.     .hbrBackground = COLOR_BTNFACE + 1
    16.     .lpszMenuName = ""
    17.     .lpszClassName = "Setup"
    18.     .hIconSm = LoadImage(glngApp, "", IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), _
    19.         GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR)
    20. End With
    21. RegisterClassEx typClass
    22.  
    23. mlngSetup = CreateWindowEx(0, "Setup", "Setup", WS_VISIBLE Or WS_OVERLAPPEDWINDOW Or DS_MODALFRAME Or WS_CLIPCHILDREN _
    24.     Or WS_CLIPSIBLINGS, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, glngMain, _
    25.     0&, glngApp, 0&)
    26.  
    27. Do While GetMessage(typMessage, 0, 0, 0) <> 0
    28.     TranslateMessage typMessage
    29.     DispatchMessage typMessage
    30. Loop
    31. End Sub
    32.  
    33. Private Function SetupProc(ByVal hwnd As Long, ByVal message As Long, ByVal wParam As Long, _
    34.     ByVal lParam As Long) As Long
    35. Select Case message
    36.     Case WM_CREATE
    37.         EnableWindow glngMain, False
    38.     Case WM_CLOSE
    39.         EnableWindow glngMain, True
    40.     Case WM_DESTROY
    41.         DestroyWindow mlngSetup
    42.         PostQuitMessage 0
    43. End Select
    44.  
    45. SetupProc = DefWindowProc(hwnd, message, wParam, lParam)
    46. End Function

    I know there is a function that does all of this called DialogBox. I just am not sure of the declaration.

    Thanks
    Always looking for a better and faster way!

  5. #5
    jim mcnamara
    Guest
    Some of the paramters to DialogBox are not exactly easy to come by in VB.

    Do you know about:

    Private Declare Function DialogBoxIndirectParam Lib "user32" Alias "DialogBoxIndirectParamA" (ByVal hInstance As Long, _
    hDialogTemplate As DLGTEMPLATE, ByVal hWndParent As Long, _
    ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Long

    Private Declare Sub DialogBoxParam Lib "user32.dll" Alias "DialogBoxParamA" (ByVal hInstance As Long, ByVal _
    lpTemplateName As String, ByVal hWndParent As Long, ByVal _
    lpDialogFunc As Long, ByVal dwInitParam As Long)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253
    Oh ya, now we are getting somewhere. Do you have any examples of how to use those functions?
    Always looking for a better and faster way!

  7. #7
    jim mcnamara
    Guest
    PS: VB scripting (includes FSO) provides the InputBox function - a modal dialog box.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Jim: I found DialogBoxIndirectParam in the VB Api Viewer (neither of the ones you mentioned are in the API Viewer from http://www.allapi.net), but DialogBoxParam isn't there. Where did you dig these bad boys up? They sound interesting.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253
    Hack: Check these pages out

    http://msdn.microsoft.com/library/de...irectparam.asp

    http://msdn.microsoft.com/library/de...ogboxparam.asp

    Those are some crazy, but awsome functions.
    Always looking for a better and faster way!

  10. #10
    jim mcnamara
    Guest
    I have a CD with 5400+ api's on it. I code in C with them all the time. About 900 are translated into VB.

    I went to www.allapi.net - got their viewer. Guess what? The newest version has those functions. The ultimate viewer is MSDN.

    www.planetsourcecode.com has code that translates C++ declarations into VB. Might be useful.

    All I MAY have somewhere is C++ versions of those calls.

    Here is a translation of DialogBox, I don't know the library off the top of my head, probably COMCTL32.dll.

    INT_PTR DialogBox(
    pointer to an integer (long) -- why VB cannot deal with this, VB expects functions to return ByVal in a register --EAX.
    HINSTANCE hInstance, // handle to module
    ByVal hInstance as long
    LPCTSTR lpTemplate, // dialog box template
    ByRef LPCSTR as String
    HWND hWndParent, // handle to owner window
    ByVal HWND as Long
    DLGPROC lpDialogFunc // dialog box procedure
    ByVal lpDialogFunc as Function Pointer (addressof) - really as Long
    );

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Thanks miben, I will definately check those links.

    Jim: Where did you get a CD with 900 VB declarations on it. I do nothing with C, but I'd like to check out those 900 VB declares. Got a website I can order that from?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width