테스크 바 버튼 숨기기

APP/UI 2013. 4. 16. 16:47 |
 

테스크 바 버튼 숨기기

// ******************************************************* //
// 델파이 2006 이하
// ******************************************************* //

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE) ;
  SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ;
  ShowWindow(Application.Handle, SW_SHOW) ;
end;


// ******************************************************* //
// 델파이 2007 이상
// ******************************************************* //

// Menu->Project->View Source
program Project1;

uses
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := False;   // False로 설정
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

// Unit1.pas
procedure TForm1.FormActivate(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE);
end;


Posted by ezmind
:

중복 실행 방지

APP 2012. 10. 23. 20:09 |
 

program Project1;

uses
  Forms,
  windows,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

var
  FMutexHandle: THandle;
  FMutexErrCode: integer;
begin
  FMutexHandle := CreateMutex(nil, TRUE, pchar('여기다 중복되지 않을 뮤텍스 이름을 지정한다') );
  FMutexErrCode := GetLastError;
  if FMutexHandle <> 0 then
  begin
    if FMutexErrCode = ERROR_ALREADY_EXISTS then
    begin
      CloseHandle(FMutexHandle);
      exit;
    end;
  end;

  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end;


'APP' 카테고리의 다른 글

Static 변수 사용하기  (0) 2012.10.23
TListView 스크롤바 없애기  (0) 2012.10.23
바탕화면, 즐겨찾기, 내 문서 등의 경로얻기  (0) 2012.10.23
GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
Posted by ezmind
:

Static 변수 사용하기

APP 2012. 10. 23. 20:08 |
 
procedure TForm1.Button1Click(Sender: TObject);
const
{$J+}
  aaa: integer = 1;
{$J-}

begin
  caption := inttostr(aaa);
  aaa := aaa + 1;
end;


'APP' 카테고리의 다른 글

중복 실행 방지  (0) 2012.10.23
TListView 스크롤바 없애기  (0) 2012.10.23
바탕화면, 즐겨찾기, 내 문서 등의 경로얻기  (0) 2012.10.23
GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
Posted by ezmind
:

TListView 스크롤바 없애기

APP 2012. 10. 23. 20:08 |
 
type
  TForm1 = class(TForm)
    ListView1: TListView;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    FListViewWndProc: TWndMethod;
    procedure ListViewWndProc(var Msg: TMessage);
  public
   { Private declarations }
    FShowHoriz: Boolean;
    FShowVert: Boolean;
  end;
  
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ListViewWndProc(var Msg: TMessage);
begin
  ShowScrollBar(ListView1.Handle, SB_HORZ, FShowHoriz);
  ShowScrollBar(ListView1.Handle, SB_VERT, FShowVert);
  FListViewWndProc(Msg); // process message
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FShowHoriz := True; // show the horiz scrollbar
  FShowVert := False; // hide vert scrollbar
  FListViewWndProc := ListView1.WindowProc; // save old window proc
  ListView1.WindowProc := ListViewWndProc; // subclass
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ListView1.WindowProc := FListViewWndProc; // restore window proc
  FListViewWndProc := nil;
end;


'APP' 카테고리의 다른 글

중복 실행 방지  (0) 2012.10.23
Static 변수 사용하기  (0) 2012.10.23
바탕화면, 즐겨찾기, 내 문서 등의 경로얻기  (0) 2012.10.23
GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
Posted by ezmind
:
 
CSIDL_ADMINTOOLS 
Version 5.0. File system directory that is used to store administrative tools for an individual user. 
The Microsoft Management Console will save customized consoles to this directory and it will roam with the user. 
CSIDL_ALTSTARTUP 
File system directory that corresponds to the user's nonlocalized Startup program group. 
CSIDL_APPDATA 
File system directory that serves as a common repository for application-specific data. 
A common path is C:\WINNT\Profiles\username\Application Data. 
CSIDL_BITBUCKET 
Virtual folder containing the objects in the user's Recycle Bin. 
CSIDL_COMMON_ADMINTOOLS 
Version 5.0. File system directory containing containing administrative tools for all users of the computer. 
CSIDL_COMMON_ALTSTARTUP 
File system directory that corresponds to the nonlocalized Startup program group for all users. 
Valid only for Windows NT® systems. 
CSIDL_COMMON_APPDATA 
Version 5.0. Application data for all users. A common path is C:\WINNT\Profiles\All Users\Application Data. 
CSIDL_COMMON_DESKTOPDIRECTORY 
File system directory that contains files and folders that appear on the desktop for all users. 
A common path is C:\WINNT\Profiles\All Users\Desktop. Valid only for Windows NT® systems. 
CSIDL_COMMON_DOCUMENTS 
File system directory that contains documents that are common to all users. 
A common path is C:\WINNT\Profiles\All Users\Documents. Valid only for Windows NT® systems. 
CSIDL_COMMON_FAVORITES 
File system directory that serves as a common repository for all users' favorite items. 
Valid only for Windows NT® systems. 
CSIDL_COMMON_PROGRAMS 
File system directory that contains the directories for the common program groups that appear on the 
Start menu for all users. A common path is c:\WINNT\Profiles\All Users\Start Menu\Programs. Valid only 
for Windows NT® systems. 
CSIDL_COMMON_STARTMENU 
File system directory that contains the programs and folders that appear on the Start menu for all users. 
A common path is C:\WINNT\Profiles\All Users\Start Menu. Valid only for Windows NT® systems. 
CSIDL_COMMON_STARTUP 
File system directory that contains the programs that appear in the Startup folder for all users. 
A common path is C:\WINNT\Profiles\All Users\Start Menu\Programs\Startup. Valid only for Windows NT® systems. 
CSIDL_COMMON_TEMPLATES 
File system directory that contains the templates that are available to all users. A common path 
is C:\WINNT\Profiles\All Users\Templates. Valid only for Windows NT® systems. 
CSIDL_CONTROLS 
Virtual folder containing icons for the Control Panel applications. 
CSIDL_COOKIES 
File system directory that serves as a common repository for Internet cookies. A common path is 
C:\WINNT\Profiles\username\Cookies. 
CSIDL_DESKTOP 
Windows Desktop?virtual folder that is the root of the namespace. 
CSIDL_DESKTOPDIRECTORY 
File system directory used to physically store file objects on the desktop (not to be confused 
with the desktop folder itself). A common path is C:\WINNT\Profiles\username\Desktop 
CSIDL_DRIVES 
My Computer?virtual folder containing everything on the local computer: storage devices, printers, 
and Control Panel. The folder may also contain mapped network drives. 
CSIDL_FAVORITES 
File system directory that serves as a common repository for the user's favorite items. A common 
path is C:\WINNT\Profiles\username\Favorites. 
CSIDL_FONTS 
Virtual folder containing fonts. A common path is C:\WINNT\Fonts. 
CSIDL_HISTORY 
File system directory that serves as a common repository for Internet history items. 
CSIDL_INTERNET 
Virtual folder representing the Internet. 
CSIDL_INTERNET_CACHE 
File system directory that serves as a common repository for temporary Internet files. A common 
path is C:\WINNT\Profiles\username\Temporary Internet Files. 
CSIDL_LOCAL_APPDATA 
Version 5.0. File system directory that serves as a data repository for local (non-roaming) 
applications. A common path is C:\WINNT\Profiles\username\Local Settings\Application Data. 
CSIDL_MYPICTURES 
Version 5.0. My Pictures folder. A common path is C:\WINNT\Profiles\username\My Documents\My Pictures. 
CSIDL_NETHOOD 
File system directory containing objects that appear in the network neighborhood. A common 
path is C:\WINNT\Profiles\username\NetHood. 
CSIDL_NETWORK 
Network Neighborhood?virtual folder representing the top level of the network hierarchy. 
CSIDL_PERSONAL 
File system directory that serves as a common repository for documents. A common path is 
C:\WINNT\Profiles\username\My Documents. 
CSIDL_PRINTERS 
Virtual folder containing installed printers. 
CSIDL_PRINTHOOD 
File system directory that serves as a common repository for printer links. A common path is 
C:\WINNT\Profiles\username\PrintHood. 
CSIDL_PROFILE 
Version 5.0. User's profile folder. 
CSIDL_PROGRAM_FILES 
Version 5.0. Program Files folder. A common path is C:\Program Files. 
CSIDL_PROGRAM_FILES_COMMON 
Version 5.0. Program Files folder that is common to all users. A common path is C:\Program Files\Common. 
Valid only for Windows NT® systems. 
CSIDL_PROGRAM_FILES_COMMONX86 
Version 5.0. Program Files folder that is common to all users for x86 applications on RISC systems. 
A common path is C:\Program Files (x86)\Common. 
CSIDL_PROGRAM_FILESX86 
Version 5.0. Program Files folder for x86 applications on RISC systems. Corresponds to 
the %PROGRAMFILES(X86)% environment variable. A common path is C:\Program Files (x86). 
CSIDL_PROGRAMS 
File system directory that contains the user's program groups (which are also file system 
directories). A common path is C:\WINNT\Profiles\username\Start Menu\Programs. 
CSIDL_RECENT 
File system directory that contains the user's most recently used documents. A common path 
is C:\WINNT\Profiles\username\Recent. To create a shortcut in this folder, use SHAddToRecentDocs. 
In addition to creating the shortcut, this function updates the shell's list of recent documents 
and adds the shortcut to the Documents submenu of the Start menu. 
CSIDL_SENDTO 
File system directory that contains Send To menu items. A common path is c:\WINNT\Profiles\username\SendTo. 
CSIDL_STARTMENU 
File system directory containing Start menu items. A common path is c:\WINNT\Profiles\username\Start Menu. 
CSIDL_STARTUP 
File system directory that corresponds to the user's Startup program group. The system starts these 
programs whenever any user logs onto Windows NT® or starts Windows® 95. A common path is 
C:\WINNT\Profiles\username\Start Menu\Programs\Startup. 
CSIDL_SYSTEM 
Version 5.0. System folder. A common path is C:\WINNT\SYSTEM32. 
CSIDL_SYSTEMX86 
Version 5.0. System folder for x86 applications on RISC systems. A common path is C:\WINNT\SYS32X86. 
CSIDL_TEMPLATES 
File system directory that serves as a common repository for document templates. 
CSIDL_WINDOWS 
Version 5.0. Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment 
variables. A common path is C:\WINNT.

// 바탕화면의 패스얻기 

char pBuffer[MAX_PATH]; 

SHGetSpecialFolderPath(GetSafeHwnd(), pBuffer, CSIDL_DESKTOP, 0); 

AfxMessageBox(pBuffer); 


'APP' 카테고리의 다른 글

Static 변수 사용하기  (0) 2012.10.23
TListView 스크롤바 없애기  (0) 2012.10.23
GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
파일명으로 아이콘 구하기  (0) 2012.10.23
Posted by ezmind
:
 
uses 
ShlObj, ActiveX;

{ 
This code shows the SelectDirectory dialog with additional expansions: 
- an edit box, where the user can type the path name, 
- also files can appear in the list, 
- a button to create new directories. 


Dieser Code zeigt den SelectDirectory-Dialog mit zusatzlichen Erweiterungen: 
- eine Edit-Box, wo der Benutzer den Verzeichnisnamen eingeben kann, 
- auch Dateien konnen in der Liste angezeigt werden, 
- eine Schaltflache zum Erstellen neuer Verzeichnisse. 
} 

function AdvSelectDirectory(const Caption: string; const Root: WideString; 
var Directory: string; EditBox: Boolean = False; ShowFiles: Boolean = False; 
AllowCreateDirs: Boolean = True): Boolean; 
// callback function that is called when the dialog has been initialized 
//or a new directory has been selected 

// Callback-Funktion, die aufgerufen wird, wenn der Dialog initialisiert oder 
//ein neues Verzeichnis selektiert wurde 
  function SelectDirCB(Wnd: HWND; uMsg: UINT; lParam, lpData: lParam): Integer; stdcall;
  var
    PathName: array[0..MAX_PATH] of Char;
  begin 
    case uMsg of
      BFFM_INITIALIZED: SendMessage(Wnd, BFFM_SETSELECTION, Ord(True), Integer(lpData));
      // include the following comment into your code if you want to react on the
      //event that is called when a new directory has been selected
      // binde den folgenden Kommentar in deinen Code ein, wenn du auf das Ereignis
      //reagieren willst, das aufgerufen wird, wenn ein neues Verzeichnis selektiert wurde
      {BFFM_SELCHANGED:
      begin
      SHGetPathFromIDList(PItemIDList(lParam), @PathName);
      // the directory "PathName" has been selected
      // das Verzeichnis "PathName" wurde selektiert
      end;}
    end; 
    Result := 0;
  end;
var 
  WindowList: Pointer;
  BrowseInfo: TBrowseInfo;
  Buffer: PChar;
  RootItemIDList, ItemIDList: PItemIDList;
  ShellMalloc: IMalloc;
  IDesktopFolder: IShellFolder;
  Eaten, Flags: LongWord;
const
  // necessary for some of the additional expansions
  // notwendig fur einige der zusatzlichen Erweiterungen
  BIF_USENEWUI = $0040;
  BIF_NOCREATEDIRS = $0200;
begin 
  Result := False;
  if not DirectoryExists(Directory) then 
    Directory := '';

  FillChar(BrowseInfo, SizeOf(BrowseInfo), 0); 
  if (ShGetMalloc(ShellMalloc) = S_OK) and (ShellMalloc <> nil) then 
  begin
    Buffer := ShellMalloc.Alloc(MAX_PATH);
    try
      RootItemIDList := nil;
      if Root <> '' then 
      begin 
        SHGetDesktopFolder(IDesktopFolder);
        IDesktopFolder.ParseDisplayName(Application.Handle, nil,
        POleStr(Root), Eaten, RootItemIDList, Flags);
      end; 

      OleInitialize(nil);

      with BrowseInfo do 
      begin 
        hwndOwner := Application.Handle;
        pidlRoot := RootItemIDList;
        pszDisplayName := Buffer;
        lpszTitle := PChar(Caption);
        // defines how the dialog will appear:
        // legt fest, wie der Dialog erscheint:
        ulFlags := BIF_RETURNONLYFSDIRS or BIF_USENEWUI or
        BIF_EDITBOX * Ord(EditBox) or BIF_BROWSEINCLUDEFILES * Ord(ShowFiles) or
        BIF_NOCREATEDIRS * Ord(not AllowCreateDirs);
        lpfn := @SelectDirCB;
        if Directory <> '' then
          lParam := Integer(PChar(Directory));
      end;

      WindowList := DisableTaskWindows(0);
      try
        ItemIDList := ShBrowseForFolder(BrowseInfo);
      finally
        EnableTaskWindows(WindowList);
      end;

      Result := ItemIDList <> nil;

      if Result then
      begin
        ShGetPathFromIDList(ItemIDList, Buffer);
        ShellMalloc.Free(ItemIDList);
        Directory := Buffer;
      end;
    finally 
      ShellMalloc.Free(Buffer);
    end;
  end;
end; 


// Example: 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  dir: string;
begin
  AdvSelectDirectory('Caption', 'c:\', dir, False, False, True);
  Label1.Caption := dir;
end; 


'APP > 파일관련' 카테고리의 다른 글

SelectDirectory 원하는 위치에 띄우기  (0) 2012.10.23
폴더 복사,이동,삭제  (0) 2012.10.23
파일 버전 구하기  (0) 2012.10.23
부모풀더까지 한방에 만들기  (0) 2012.10.23
Posted by ezmind
:
 
uses Math, ShlObj, ActiveX;

function SelectDirectoryEx(const Caption: string; const Root: string;
  out Directory: string; AX, AY: Integer): Boolean;

  type
  PBFFRecord = ^TBFFRecord;

  TBFFRecord = record
  InitDir: PChar;
  X: Integer;
  Y: Integer;
  end;

var
  BFFR:TBFFRecord;
  IDList: PItemIDList;
  BrowseInfo: TBrowseInfo;
  Malloc:IMalloc;
  WindowList: Pointer;
  Buffer: PChar;


  function BrowseFolderProc(hWindow: HWND; uMsg: UINT; lParam: LPARAM;
    lpData: LPARAM): Integer; stdcall;
  var
    PathName: array[0..MAX_PATH] of Char;
    PBFFR:PBFFRecord;
    r: TRect;
    x, y, cx, cy, w, h: Integer;

  begin
    case uMsg of
      BFFM_INITIALIZED:
        begin
          PBFFR := Pointer(lpData);
          if lstrlen(PBFFR^.InitDir) > 1 then
            SendMessage(hWindow,BFFM_SETSELECTION, 1, Integer(PBFFR^.InitDir));

          cx := GetSystemMetrics(SM_CXSCREEN);
          cy := GetSystemMetrics(SM_CYSCREEN);
          GetWindowRect(hWindow, r);
          w := r.Right - r.Left;
          h := r.Bottom - r.Top;
          x := PBFFR^.X;
          y := PBFFR^.Y;

          if (x = 0) or (y = 0) then
          begin
            x := (cx - w) div 2;
            y := (cy - h) div 2;
          end;

          x := Max(Min(x, cx - w), 0);
          y := Max(Min(y, cy - h), 0);

          SetWindowPos(hWindow, 0, x, y, 0, 0, SWP_NOSIZE or SWP_NOZORDER);
        end;
      BFFM_SELCHANGED:
        begin
          SHGetPathFromIDList(PItemIDList(lParam), @PathName);
          SendMessage(hWindow, BFFM_SETSTATUSTEXT, 0, LongInt(PChar(@PathName)));
        end;
    end;
    Result := 0;
  end;
begin
  Result := False;
  Directory := '';
  BFFR.InitDir := PChar(Root);
  BFFR.X := AX;
  BFFR.Y := AY;
  FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);

  if (ShGetMalloc(Malloc) = S_OK) and (Malloc <> nil) then
  begin
  Buffer := Malloc.Alloc(MAX_PATH);
  try
    with BrowseInfo do
    begin
      hwndOwner := Application.Handle;
      pidlRoot := nil;
      pszDisplayName := Buffer;
      lpszTitle := PChar(Caption);
      ulFlags := BIF_STATUSTEXT or BIF_RETURNONLYFSDIRS;
      lpfn := @BrowseFolderProc;
      lParam := Integer(@BFFR);
    end;
    WindowList := DisableTaskWindows(0);
    try
      IDList := ShBrowseForFolder(BrowseInfo);
    finally
      EnableTaskWindows(WindowList);
    end;
    Result := IDList <> nil;
    if Result then
    begin
      ShGetPathFromIDList(IDList, Buffer);
      Malloc.Free(IDList);
      Directory := Buffer;
    end;
    finally
      Malloc.Free(Buffer);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
begin
  if SelectDirectoryEx('폴더를 선택해 주세요', 'C:\Windows', s, 300, 300) then
  Label1.Caption := s;

  if SelectDirectoryEx('화면의 한가운데', 'C:\Windows', s, 0, 0) then
  Label1.Caption := s;


end;


'APP > 파일관련' 카테고리의 다른 글

SelectDirectory 확장  (0) 2012.10.23
폴더 복사,이동,삭제  (0) 2012.10.23
파일 버전 구하기  (0) 2012.10.23
부모풀더까지 한방에 만들기  (0) 2012.10.23
Posted by ezmind
:

GUID 생성

APP 2012. 10. 23. 20:05 |
 
uses
  ComObj, ActiveX;

function CreateGuid: string;
var
  ID: TGUID;
begin
  Result := '';
  if CoCreateGuid(ID) = S_OK then
    Result := GUIDToString(ID);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := CreateGuid;
end;


Posted by ezmind
:
 
function EnumWindowProc( hWnd:HWND; lParam: LPARAM ):bool; stdcall;
var
  pid: DWORD;
  buf: string;
begin
  if (not IsWindow(hwnd)) or (not IsWindowVisible(hwnd)) then // || GetParent(hwnd)!=0)
  begin
    result := true;
    exit;
  end;

  GetWindowThreadProcessId(hwnd, @pid);
  if (pid = 0) then
  begin
    result := true;
    exit;
  end;

  SetLength( buf, 256 );
  GetWindowText(hwnd, pchar(buf), 256);
  if (buf = '') then
  begin
    result := true;
    exit;
  end;

  form1.Memo1.Lines.Add(buf)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  EnumDesktopWindows(HDESK(0),@EnumWindowProc, 0);
end;


'APP' 카테고리의 다른 글

바탕화면, 즐겨찾기, 내 문서 등의 경로얻기  (0) 2012.10.23
GUID 생성  (0) 2012.10.23
파일명으로 아이콘 구하기  (0) 2012.10.23
TEXT 파일 제어  (0) 2012.10.23
클립보드  (0) 2012.10.23
Posted by ezmind
:
 

function GetFileIcon( FileName: String ): HICON;
var
  SHFileInfo: TSHFileInfo;
begin
  ShGetFileInfo( PChar( FileName ), 0, SHFileInfo, SizeOf( TSHFileInfo ), 
  	SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_EXETYPE {or SHGFI_SMALLICON });
  Result := SHFileInfo.hIcon;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  AIcon: TIcon;
begin
  AIcon := TIcon.Create;
  try
    AIcon.Handle := GetFileIcon( 'C:\Program Files\Internet Explorer\iexplore.exe' );
    Image1.Picture.Assign( AIcon );
  finally
    AIcon.Free;
  end;
end;


'APP' 카테고리의 다른 글

GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
TEXT 파일 제어  (0) 2012.10.23
클립보드  (0) 2012.10.23
프린트 스크린 키 눌렸는지 확인  (0) 2012.10.23
Posted by ezmind
: