C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[18842] Re:[질문] 바탕화면의 아이콘들의 좌표를 어디서 수정하나요?
유영인.Chris [cuperido] 1590 읽음    2002-05-24 13:05
이미 뉴스그룹에 답변과 소스가 올라와 있네요.


I wrote a program like what your talking about. I wanted something to
restore all my icons to their positions after a game running DirectX crashed
and would mess up the resolution and all the icons positions.

You need to check out the List View Control Message in the Windows SDK. The
windows desktop icons are stored in a listview. The example below just
shows how to find the list view control that has the icons in them, find out
how many icons there are, and then get their X, Y position on the screen. I
used SendMessage and Memory mapped files instead of stuff like
ListView_GetItemPosition, because the call would require pointers being
passed between different process space, and that just won't work.

You can restore the desktop with the coordinates you get, but not all the
icons will go into the right place. You may also need the names of the
icons to make sure they get back in the right place. Check out the message
LVM_GETITEMTEXT for that, the example below only gets their position since
that is what you asked for.

And I have only tried this on Win98 with BCB 5.

// Header stuff
struct ICON_DATA_STRUCT
{
   int IconIndex;
   POINT IconPosition;
};

typedef ICON_DATA_STRUCT IconData;
IconData Icons[1000];

   HWND hDesktop;
   int iIconCount;
// end header stuff

void TForm1::GetDesktopIconPositionXY()
{
   hDesktop = NULL;
   iIconCount = 0;

// Find the List View where the Desktop Icon info is stored.
   hDesktop = FindWindow("ProgMan",NULL);
   if(hDesktop == NULL)
   {
      ShowMessage("ProgMan Window Not Found.");
      return;
   }

   hDesktop = FindWindowEx(hDesktop,0,"ShellDll_DefView", NULL);
   if(hDesktop == NULL)
   {
      ShowMessage("ShellDll_DefView Window Not Found.");
      return;
   }

   hDesktop = FindWindowEx(hDesktop,0,"SysListView32",NULL);
   if(hDesktop == NULL)
   {
      ShowMessage("SysListView32 Window Not Found.");
      return;
   }

// Get the number of icons on the desktop
   iIconCount = SendMessage(hDesktop, LVM_GETITEMCOUNT,0,0);

   if(iIconCount == 0)
      return;

   Memo1->Lines->Add("Icon Count: "+IntToStr(iIconCount));

   HANDLE hFile = NULL;
   AnsiString sFileName;
   sFileName = ExtractFilePath(Application->ExeName)+"temp.ppp";
   hFile = CreateFile(sFileName.c_str(),GENERIC_READ|GENERIC_WRITE,
      0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

   HANDLE hMappedFile = NULL;
   hMappedFile = CreateFileMapping(hFile,NULL,PAGE_READWRITE,
      0,16,"MyMapping");

   long pFileMap;
   pFileMap = (long)MapViewOfFile(hMappedFile,FILE_MAP_WRITE,0,0,0);
   POINT p;
   // Get each icons X,Y coordinates
   for(int i=0; i<iIconCount-1; i++)
   {
      SendMessage(hDesktop,LVM_GETITEMPOSITION,i,pFileMap);
      CopyMemory(&p,(void*)pFileMap,8);
      Memo1->Lines->Add("x: "+IntToStr(p.x)+" y: "+IntToStr(p.y));
      Icons[i].IconIndex = i;
      Icons[i].IconPosition = p;
   }

   FlushViewOfFile((void*)pFileMap,8);
   UnmapViewOfFile((void*)pFileMap);
   CloseHandle(hMappedFile);
   CloseHandle(hFile);
}

Hope that helps.

Later,
Clayton
claytontodd@hotmail.com



이상우 님이 쓰신 글 :
: 안녕하세요.
: 바탕화면의 아이콘들이 있잖아요.
: 그 위치를 수동(마우스로 드레그)하는거 말고 위치를 바꾸고 싶은데...
: 레지스트리 뒤져도 못찾겠고..어디에 저장되어있나요..
: 위치(좌표)가....아시는분 가르쳐주세요~~~^^;;
: 어딘가에 저장이 되어있을텐데....못찾고 있습니다..
:

+ -

관련 글 리스트
18813 [질문] 바탕화면의 아이콘들의 좌표를 어디서 수정하나요? 이상우 1115 2002/05/24
18842     Re:[질문] 바탕화면의 아이콘들의 좌표를 어디서 수정하나요? 유영인.Chris 1590 2002/05/24
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.