mozna w jakis sposob nie pozwolic (ew. wylaczyc) windowsowi na automatyczne przestawianie ikon na pulpicie przy zmianie rozdzielczosci na mniejsza?
//Ha! Za rozwiązanie stawiam browca - Marooned
mozna w jakis sposob nie pozwolic (ew. wylaczyc) windowsowi na automatyczne przestawianie ikon na pulpicie przy zmianie rozdzielczosci na mniejsza?
//Ha! Za rozwiązanie stawiam browca - Marooned
odpowiedź teoretycznie prosta: zapisać położenie ikon, a potem odtworzyć...
i tu już komplikacje nieziemskie, ale Ja znalazłem odpowiedź... długa jak jasny gwint, a do tego po angielsku...
// "hook.dpr" - DLL project
library hook;
uses windows, messages, commctrl;
{$ifndef ver120} type cardinal = integer; {$endif}
function HookMessageProc(code, wParam, lParam: integer) : integer; stdcall;
begin
result:=0;
end;
exports HookMessageProc;
type TDesktopItems = record
itemCount : integer;
items : array [0..$FFFE] of record
pos : TPoint;
name : array [0..MAX_PATH] of char;
end;
end;
TPDesktopItems = ^TDesktopItems;
var fm : cardinal;
pdi : TPDesktopItems;
lv : cardinal;
i1 : integer;
lvi : TLVItem;
ev : cardinal;
begin
lv:=FindWindowEx(FindWindowEx(FindWindow('Progman','Program Manager'),0,'SHELLDLL_DefView',''),0,'SysListView32','');
if (lv<>0) and (GetCurrentThreadID=GetWindowThreadProcessID(lv,nil)) then begin
fm:=OpenFileMapping(FILE_MAP_ALL_ACCESS,false,'mappedMemoryForDesktopIcons');
if fm<>0 then
try
pdi:=MapViewOfFile(fm,FILE_MAP_ALL_ACCESS,0,0,0);
if pdi<>nil then
try
with pdi^ do begin
i1:=SendMessage(lv,LVM_GETITEMCOUNT,0,0);
if i1<itemCount then itemCount:=i1;
zeroMemory(@lvi,sizeOf(TLVItem));
for i1:=0 to itemCount-1 do begin
SendMessage(lv,LVM_GETITEMPOSITION,i1,integer(@items[i1].pos));
with lvi do begin mask:=LVIF_TEXT; iSubItem:=0; pszText:=items[i1].name; cchTextMax:=MAX_PATH end;
items[i1].name[SendMessage(lv,LVM_GETITEMTEXT,i1,integer(@lvi))]:=#0;
end;
end;
finally UnMapViewOfFile(pdi) end;
finally CloseHandle(fm) end;
ev:=OpenEvent(EVENT_ALL_ACCESS,false,'eventForDesktopIcons');
if ev<>0 then
try
SetEvent(ev);
finally CloseHandle(ev) end;
end;
end.
// "desktopItems.pas" - the main unit
unit desktopItems;
interface
uses Windows, Messages, SysUtils, CommCtrl;
type IDesktopItems = interface ['{AD828DE0-3570-11D3-A52D-00005A180D69}']
function ItemCount : integer;
function GetPosition (index: integer) : TPoint;
property Position [index: integer] : TPoint read GetPosition;
function GetName (index: integer) : string;
property Name [index: integer] : string read GetName;
procedure Refresh;
end;
function GetDesktopItems : IDesktopItems;
implementation
{$ifndef ver120} type cardinal = integer; {$endif}
type TDesktopItem = record
pos : TPoint;
name : array [0..MAX_PATH] of char;
end;
TDesktopItems = record
itemCount : integer;
items : array [0..$FFFE] of TDesktopItem;
end;
TPDesktopItems = ^TDesktopItems;
TIDesktopItems = class (TInterfacedObject, IDesktopItems)
private
FFileMapping : cardinal;
FPDesktopItems : TPDesktopItems;
constructor Create;
destructor Destroy; override;
function ItemCount : integer;
function GetPosition (index: integer) : TPoint;
function GetName (index: integer) : string;
procedure Refresh;
end;
constructor TIDesktopItems.Create;
begin
inherited;
Refresh;
end;
destructor TIDesktopItems.Destroy;
begin
if FPDesktopItems<>nil then UnMapViewOfFile(FPDesktopItems);
if FFileMapping <>0 then CloseHandle (FFileMapping );
inherited;
end;
function TIDesktopItems.ItemCount : integer;
begin
result:=FPDesktopItems^.itemCount;
end;
function TIDesktopItems.GetPosition(index: integer) : TPoint;
begin
if (index<0) or (index>=FPDesktopItems^.itemCount) then
raise Exception.Create('Index out of range.');
result:=FPDesktopItems^.items[index].pos;
end;
function TIDesktopItems.GetName(index: integer) : string;
begin
if (index<0) or (index>=FPDesktopItems^.itemCount) then
raise Exception.Create('Index out of range.');
result:=FPDesktopItems^.items[index].name;
end;
procedure TIDesktopItems.Refresh;
var lv : cardinal;
ic : integer;
dll : cardinal;
hook : cardinal;
ev : cardinal;
begin
if FPDesktopItems<>nil then UnMapViewOfFile(FPDesktopItems);
if FFileMapping <>0 then CloseHandle (FFileMapping );
lv:=FindWindowEx(FindWindowEx(FindWindow('Progman','Program Manager'),0,'SHELLDLL_DefView',''),0,'SysListView32','');
if lv<>0 then ic:=SendMessage(lv,LVM_GETITEMCOUNT,0,0) else ic:=0;
FFileMapping:=CreateFileMapping(cardinal(-1),nil,PAGE_READWRITE,0,4+ic*sizeOf(TDesktopItem),'mappedMemoryForDesktopIcons');
if FFileMapping<>0 then begin
FPDesktopItems:=MapViewOfFile(FFileMapping,FILE_MAP_ALL_ACCESS,0,0,0);
FPDesktopItems^.itemCount:=ic;
dll:=LoadLibrary(pchar(ExtractFilePath(ParamStr(0))+'hook.dll'));
if dll<>0 then
try
ev:=CreateEvent(nil,true,false,'eventForDesktopIcons');
if ev<>0 then
try
hook:=SetWindowsHookEx(WH_GETMESSAGE,GetProcAddress(dll,'HookMessageProc'),dll,GetWindowThreadProcessID(lv,nil));
if hook<>0 then
try
PostThreadMessage(GetWindowThreadProcessID(lv,nil),WM_NULL,0,0);
WaitForSingleObject(ev,2000);
finally UnhookWindowsHookEx(hook) end;
finally CloseHandle(ev) end;
finally FreeLibrary(dll) end;
end else FPDesktopItems:=nil;
end;
function GetDesktopItems : IDesktopItems;
begin
result:=TIDesktopItems.Create;
end;
end.
// "testDesktopItems.dpr" - application test project
program testDesktopItems;
uses Windows,
SysUtils,
desktopItems in 'desktopItems.pas';
procedure testDesktopItemsUnit;
var i1 : integer;
s1 : string;
begin
with GetDesktopItems do
for i1:=0 to ItemCount-1 do
s1:=s1+IntToStr(Position[i1].x)+'/'+IntToStr(Position[i1].y)+': "'+Name[i1]+'"'#$D#$A;
MessageBox(0,pchar(s1),'Desktop Icons',0);
end;
begin
testDesktopItemsUnit;
end.
//ps. jak się komuś chce to moze poprawić formatowanie, bo ja nie mam czasu
taaa, juz to widzialem, ale w moim przypadku to jest bezuzyteczne bo po ponownym uruchomieniu komputera w nizszej rozdzielczosci i tak mi rozwali ikony. chodzi o to, ze mam 2 uzytkownikow. jeden ma nizsza rozdzielczosc i jak po nim zaloguje sie czlowiek z wyzsza, to ustawienia tamtego mu rozwalaja pulpit, bo durny windows najpierw ustaiwa ikony a potem rozdzielczosc. pisalem juz program, ktory mial zmieniac rozdzielczosc przed ladowaniem ikon (ustawiony w runonce - uruchamial sie jako pierwszy) ale wtedy windows nie pozwala na zmiane rozdzielczosci [glowa] sam juz nie wiem...
Okręźną drogą go! Niech programik siedzi w traju. gdy chcesz się wylogować dajesz źeby zapisał położenie, a jak się wlogujesz to żeby przywrócił. co za problem?
ups, mój błąd... tu nie ma ustawiania. ale co za problem dorobić?
no wlasnie nie bo jak komputer sie zawiesi albo ktos terminuje ten programik to i tak dupa... potrzbuje czegos uzytkowniko-odpornego
no wlasnie nie bo jak komputer sie zawiesi albo ktos terminuje ten programik to i tak dupa... potrzbuje czegos uzytkowniko-odpornego
Odpowiedź z innej beczki:
Kup sobie kartę graficzną Matroxa :-P - jej sterowniki robią takie coś, nawet jak nagle wciśniesz reset. One chyba co jakiś czas zapisują ustawienie ikon i po powstaniu systemu odtwarzają ich położenie :-)
a jak moge zapisac te polozenia na dysk?