|
void __fastcall TForm1::ToolButton10Click(TObject *Sender)
{
HWND hdHandle;
RECT rtPosition;
hdHandle = FindWindow(NULL, "M_C"); // 위치를 알아내려하는 프로그램이름..
if(hdHandle)
{
GetWindowRect(hdHandle, &rtPosition);
int x = rtPosition.left; //현재 위치한 윈도우의 left 위치
int y = rtPosition.top;
SetWindowPos(hdHandle, ToolButton10->Down ? HWND_TOPMOST : HWND_NOTOPMOST, x, y, 0, 0, SWP_NOSIZE);
}
}
이렇게 코딩을 햇는데..프로그램이 죽어 버리네염..잘못 코딩한건가염...
유영인.Chris 님이 쓰신 글 :
: GetWindowRect 이라는 API 함수를 사용하시면 되실것 같네요.
: 아래는 버튼을 누르면 메모장의 위치를 표시해 주는 예제입니다.
:
:
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
:
: HWND hdHandle;
: RECT rtPosition;
:
:
: hdHandle = FindWindow(NULL, "메모장");
:
: if(hdHandle) {
: GetWindowRect(hdHandle, &rtPosition);
: ShowMessage("내 위치는 X - " + IntToStr(rtPosition.left) + ", Y - " + IntToStr (rtPosition.top) + " 입니다");
: }
:
: }
: //---------------------------------------------------------------------------
:
:
: 에궁... 님이 쓰신 글 :
: : MSN 메신저의 항상 위에 이 기능을 사용할려구 SetWindowPos API를 사용했습니다.
: :
: : SetWindowPos(Handle, ToolButton10->Down ? HWND_TOPMOST : HWND_NOTOPMOST,0, 0, 0, 0,WP_NOSIZE);
: :
: : 툴버튼에 넣고 원클릭이벤트에서 실행되게 햇는데. 문제는
: :
: : 이넘이 이벤트가 발생되면 왼쪽 상단부분에 붙어 버리더 군여...
: :
: : 저는 창이 위치한 곳이나 화면 중앙에 위치 시킬려구 하는데염..
: :
: : 이런 API 가 있는지 궁금해서염..API 쪽은 잘 몰라서염.
: :
|