Недавно добавленные исходники

•  Animation Loaders  807

•  DeLiKaTeS Tetris (Тетрис)  5 773

•  TDictionary Custom Sort  7 729

•  Fast Watermark Sources  7 408

•  3D Designer  10 630

•  Sik Screen Capture  7 943

•  Patch Maker  8 162

•  Айболит (remote control)  8 212

•  ListBox Drag & Drop  7 017

•  Доска для игры Реверси  100 389

•  Графические эффекты  8 286

•  Рисование по маске  7 661

•  Перетаскивание изображений  6 267

•  Canvas Drawing  6 641

•  Рисование Луны  6 564

•  Поворот изображения  5 721

•  Рисование стержней  4 659

•  Paint on Shape  3 362

•  Генератор кроссвордов  4 331

•  Головоломка Paletto  3 489

•  Теорема Монжа об окружностях  4 304

•  Пазл Numbrix  2 782

•  Заборы и коммивояжеры  3 711

•  Игра HIP  2 503

•  Игра Go (Го)  2 495

•  Симулятор лифта  2 890

•  Программа укладки плитки  2 323

•  Генератор лабиринта  3 049

•  Проверка числового ввода  2 554

•  HEX View  2 958

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Обновить иконки на экране



Оформил: DeeCo

{ 
  Microsoft's Tweak UI has a feature 'rebuild icon cache now'. 
  Windows then rebuilds its internal cache of icons. 
  Unfortunately, there is no single API to do this. 
}

 uses
   Registry;

 function RefreshScreenIcons : Boolean;
 const
   KEY_TYPE = HKEY_CURRENT_USER;
   KEY_NAME = 'Control Panel\Desktop\WindowMetrics';
   KEY_VALUE = 'Shell Icon Size';
 var
   Reg: TRegistry;
   strDataRet, strDataRet2: string;

  procedure BroadcastChanges;
  var
    success: DWORD;
  begin
    SendMessageTimeout(HWND_BROADCAST,
                       WM_SETTINGCHANGE,
                       SPI_SETNONCLIENTMETRICS,
                       0,
                       SMTO_ABORTIFHUNG,
                       10000,
                       success);
  end;


 begin
   Result := False;
   Reg := TRegistry.Create;
   try
     Reg.RootKey := KEY_TYPE;
     // 1. open HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics 
    if Reg.OpenKey(KEY_NAME, False) then
     begin
       // 2. Get the value for that key 
      strDataRet := Reg.ReadString(KEY_VALUE);
       Reg.CloseKey;
       if strDataRet <> '' then
       begin
         // 3. Convert sDataRet to a number and subtract 1, 
        //    convert back to a string, and write it to the registry 
        strDataRet2 := IntToStr(StrToInt(strDataRet) - 1);
         if Reg.OpenKey(KEY_NAME, False) then
         begin
           Reg.WriteString(KEY_VALUE, strDataRet2);
           Reg.CloseKey;
           // 4. because the registry was changed, broadcast 
          //    the fact passing SPI_SETNONCLIENTMETRICS, 
          //    with a timeout of 10000 milliseconds (10 seconds) 
          BroadcastChanges;
           // 5. the desktop will have refreshed with the 
          //    new (shrunken) icon size. Now restore things 
          //    back to the correct settings by again writing 
          //    to the registry and posing another message. 
          if Reg.OpenKey(KEY_NAME, False) then
           begin
             Reg.WriteString(KEY_VALUE, strDataRet);
             Reg.CloseKey;
             // 6.  broadcast the change again 
            BroadcastChanges;
             Result := True;
           end;
         end;
       end;
     end;
   finally
     Reg.Free;
   end;
 end;

 procedure TForm1.Button1Click(Sender: TObject);
 begin
   RefreshScreenIcons
 end;


 { 
  The result is Window's erasing all its icons, and recalculating them 
  based on the registry settings. 
  This means if you have changed a DefaultIcon key within the registry for 
  some application or file, Windows will display the new icon when the 
  refresh is completed. 

  Original source: 
  www.mvps.org/vbnet/index.html?code/reg/screenrefresh.htm 
  Translated from VB by Thomas Stutz 
}







Copyright © 2004-2026 "Delphi Sources" by «SiteAnalyzer». Delphi World FAQ

Группа ВКонтакте