I need to make some changes to TaskDialog before it is shown to the user. Simply use the Windows API calls to work with each of the controls in the dialog box. I need to be sure which button I found. I would expect to find a place where I could read the result that the button will give when clicked.
In other words, if I clicked on a button that would call a return value (in Delphi, it is called a modal result) at 100, I would expect that there would be an API call that I could call to find out that the "return value" button will be. I have not found such a call.
I do not want to rely on the button text.
Here is what I still have.
function EnumWindowsProcToFindDlgControls(hWindow: HWND; _param:LPARAM): BOOL; stdcall; var sClassName:string; hBMP:THandle; i:integer; begin SetLength(sClassName, MAX_PATH); GetClassName(hWindow, PChar(sClassName), MAX_PATH); SetLength(sClassName, StrLen(PChar(sClassName))); if sClassName='Button' then begin // always 0... i:=GetDlgCtrlID(hWindow); if (i=100) or (i=102) then begin hBmp := LoadImage(HInstance, 'DISA', IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE or LR_LOADTRANSPARENT ); SendMessage(hWindow, BM_SETIMAGE, WPARAM(IMAGE_BITMAP), LPARAM(hBmp)); end; end; // keep looking Result:=true; end; procedure TForm2.TaskDialog1DialogConstructed(Sender: TObject); begin EnumChildWindows(TaskDialog1.Handle, @EnumWindowsProcToFindDlgControls, 0); end;
I suspect that it is not entirely βrespectableβ to do such things with dialogue.
This is a Delphi 10 Win32 application using the Delphi VCL component TTaskDialog, which is a wrapper around the Windows task dialog. before it is shown, the OnConstructed event is fired, executing this code.
Thank you for your help!
X ray source share