Are used ideas of program, found on vbnet.
This code demonstrates, how to center a dialog and to change all titles.
[This message has been edited by Semen Matusovski (edited June 08, 2000).]
This code demonstrates, how to center a dialog and to change all titles.
Code:
#Compile Exe #Dim All #Register None #Include "win32api.inc" #Include "comdlg32.inc" Global ofn As OPENFILENAME Function GetFileNameProc (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Local rc1 As Rect, rc2 As Rect, hWnd1 As Long, hWnd2 As Long Select Case wMsg Case %WM_SIZE hWnd1 = GetParent(hWnd) ' Center hWnd2 = ofn.hWndOwner: If hWnd2 = 0 Then hWnd2 = GetDesktopWindow GetWindowRect hWnd1, rc1: GetWindowRect hWnd2, rc2 SetWindowPos hWnd1, %HWND_TOPMOST, _ rc2.nLeft + ((rc2.nRight - rc2.nLeft) - (rc1.nRight - rc1.nLeft)) / 2, _ rc2.nTop + ((rc2.nBottom - rc2.nTop) - (rc1.nBottom - rc1.nTop)) / 2, _ 0, 0, %SWP_NOSIZE ' Set names SetWindowText hWnd1, "{Caption}" Dim TmpAsciiz As Asciiz * 255 TmpAsciiz = "{Look in}" : _ SendMessage hwnd1, %CDM_SETCONTROLTEXT, &H443, VarPtr(TmpAsciiz) TmpAsciiz = "{File&Name}": _ SendMessage hwnd1, %CDM_SETCONTROLTEXT, &H442, VarPtr(TmpAsciiz) TmpAsciiz = "{File&Type}": _ SendMessage hwnd1, %CDM_SETCONTROLTEXT, &H441, VarPtr(TmpAsciiz) TmpAsciiz = "{&Ok}" : SendMessage hwnd1, %CDM_SETCONTROLTEXT, _ %IDOK, VarPtr(TmpAsciiz) TmpAsciiz = "{&Cancel}" : SendMessage hwnd1, %CDM_SETCONTROLTEXT, _ %IDCANCEL, VarPtr(TmpAsciiz) End Select Function = DefWindowProc(hWnd, wMsg, wParam, lParam) End Function Function GetFileName(hWnd As Long) As String Static szCurDir1 As Asciiz * %MAX_PATH, szCurDir2 As Asciiz * %MAX_PATH Static szTitleName As Asciiz * %MAX_PATH, _ szFilter As Asciiz * %MAX_PATH If ofn.lStructSize = 0 Then ofn.lStructSize = SizeOf(ofn) ofn.hWndOwner = hWnd szFilter = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0) + _ "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) ofn.lpstrFilter = VarPtr(szFilter) ofn.lpstrFileTitle = VarPtr(szTitleName) ofn.nMaxFileTitle = SizeOf(szTitleName) ofn.lpfnHook = CodePtr(GetFileNameProc) ofn.Flags = %OFN_HIDEREADONLY Or %OFN_CREATEPROMPT Or %OFN_EXPLORER Or %OFN_ENABLEHOOK End If GetCurrentDirectory SizeOf(szCurDir1), szCurDir1 GetOpenFileName ofn GetCurrentDirectory SizeOf(szCurDir2), szCurDir2 If Right$(szCurDir2, 1) <> "\" Then szCurDir2 = szCurDir2 + "\" If szTitleName = "" Then Function = "" Else Function = szCurDir2 + szTitleName SetCurrentDirectory szCurDir1 End Function CallBack Function OkProc SetWindowText CbHndl, "Selected: " + GetFileName(GetDlgItem(CbHndl, 101)) End Function Function PbMain Local hDlg As Long Dialog New %HWND_DESKTOP, "OFN", , , 400, 200, %WS_CAPTION Or %WS_SYSMENU To hDlg Control Add TextBox, hDlg, 101, "", 5, 10, 300, 180 Control Add Button, hDlg, 102, "Open", 320, 10, 70, 15 Call OkProc Dialog Show Modal hDlg End Function