WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Set the AskDirectory Dialog Box Size


Although Windows places the Askdirectory dialog box wherever it wants to, it is typically places it near the upper left corner of the screen, and usually is displayed rather small. Although we have no control over its position, we can control the size of the dialog box that Windows displays by setting the horizontal and vertical size (in pixels) in the Registry before calling it using the two lines of code below, where WindowWidth and WindowHeight are in pixels:
; RegSetDword (@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Width]", WindowWidth) 
; RegSetDword (@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Height]", WindowHeight)
EXAMPLE:
; To display the current settings that will be used for the Askdirectory 
; dialog box, query the following registry keys:
CurrentWidth = RegQueryDword (@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Width]")
CurrentHeight = RegQueryDword (@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Height]")

Pause("","Askdirectory window width will be = %CurrentWidth%%@crlf%Askdirectory window height will be = %Currentheight%")

; If desired, we can set the Askdirectory dialog box to be displayed as a percentage of the 
; current screen size. To do this, first we need to determine the current screen resolution:
ScreenWidth = WinMetrics (0)  ; Get screen width resolution in pixels
ScreenHeight = WinMetrics (1) ; Get screen height resolution in pixels


; Now we can set the Askdirectory dialog box to display as a percentage of the 
; current screen resolution. Horizontal and vertical sizes can be set independently.
WindowWidth = ScreenWidth * 0.6   ; Set the dialog box to open at 60 percent of screen
WindowHeight = ScreenHeight * 0.6 ; resolution both horizontally and vertically
WindowWidth = Int (windowWidth)   ; number must be an integer
WindowHeight = Int (windowHeight)

; Now set these values in the registry to set the size of the 
Askdirectory dialog box: ; Set Askdirectory window width:
RegSetDword (@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Width]", WindowWidth)
; Set Askdirectory window height:
RegSetDword (@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer[Browse For Folder Height]", WindowHeight)


; Create a long message to be displayed in the dialog box: 
Msg1 = "If you wish to have a larger askdirectory dialog box, you might want to have a message in " 
Msg2 = "it that is longer than 255 characters. That can easily be done using the Strcat command as "
Msg3 = "shown in this example. However, if the user resizes the dialog box, the text displayed might "
Msg4 = "become corrupted. Try resizing this dialog box and see what happens to this text."
Msg  = Strcat (msg1, msg2, msg3, msg4)

flags=4|8
Segpath=AskDirectory(Msg,"","c:\","",flags)

Article ID:   W16471
File Created: 2005:02:18:12:20:52
Last Updated: 2005:02:18:12:20:52