首页  编辑  

更改图标对话框

Tags: /超级猛料/VCL/Common.Dialog.通用对话框和控件/   Date Created:

SHChangeIconDialog(hwnd,filename,0,index);

function SHChangeIconDialog;external 'shell32.dll' index 62;

function SHChangeIconDialog(h:hwnd;filename:pchar; Reserved:integer;var index:integer):integer;stdcall;

{

procedure TForm1.Button1Click(Sender: TObject);

var

b:integer;

str:array[0..MAX_PATH] of char;

begin

b:=0;

if opendialog1.Execute then

begin

strpcopy(str,opendialog1.filename);

shChangeIconDialog(handle,str,0,b);

end;

showmessage(str);

end;

}

function SHChangeIconDialog(h:hwnd;filename:pchar; Reserved:integer;var index:integer):integer;stdcall;

---------------------------------------

在WIn9x和Win nt下通用的选择图标对话框

其实有很多API函数都有这种情况,这也是一个参考吧。

function ShowChangeIconDialogA(hWnd: HWND; Filename: pchar; uBuffSize: integer; var index: integer): integer; stdcall;

function ShowChangeIconDialogW(hWnd: HWND; Filename: pwidechar; uBuffSize: integer; var index: integer): integer; stdcall;

function ShowSelectIconDialog;

var

 BuffW: array[0..MAX_PATH] of Widechar;

 BuffA: array[0..MAX_PATH] of Char;

begin

 if Win32Platform = VER_PLATFORM_WIN32_NT then

 begin

   StringToWideChar(FileName, BuffW, SizeOf(BuffW));

   Result := ShowChangeIconDialogW(hWnd, BuffW, SizeOf(BuffW), Index);

   FileName := WideCharToString(BuffW);

 end

 else

 begin

   StrPCopy(BuffA,FileName);

   Result := ShowChangeIconDialogA(hWnd, BuffA, SizeOf(BuffA), Index);

   FileName := StrPas(BuffA);

 end;

end;