How to change the directory while a TOpenDialog is open (Views: 28)
Problem/Question/Abstract: I have created an extra TSpeedButton on my TOpenDialog and would like to change the active directory if the user clicks it. If I change the current directory, nothing happens. Answer: { ... } hDlg := GetForeGroundWindow; repeat {Sending the path. Try until the dialog has received it} SendDlgItemMessage(hDlg, 1152, WM_SETTEXT, 0, Integer(PChar(sDir))); L := SendDlgItemMessage(hDlg, 1152, WM_GETTEXTLENGTH, 0, 0); Application.ProcessMessages; if Application.Terminated then Exit; until L <> 0; {And now click OK} SendMessage(hDlg, WM_COMMAND, 1 + BN_CLICKED * $10000, GetDlgItem(hDlg, 1)); {Clear} SendDlgItemMessage(hDlg, 1152, WM_SETTEXT, 0, Integer(PChar(''))); { ... } |