I have an Excel COM add-in written with the pascal object. In a DLL there is a form.
I have a question: how to make the DLL form's appear on top when the main excel window have focus,
and when the main excel window loses focus the DLL form is hidden?
Know that Excel application's window inheritance is hierarchical as follows: XLMain -> XLDesk -> EXCEL7 [Book1] (I've used uuSpy)
How to identify Handle, ThreadId, ProcessId of each Window?
Please give me some advise!
Thanks first!
Help - Excel - VCL form
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Re: Help - Excel - VCL form
Firstly;
-CreateToolHelp32SnapShot and Process32First
You should take a snapshot of the system with its commands. The ThreadId information of the application you want will be included in the image you receive.
-GetWindowThreadProcessID
It will give the window handle of the ThreadId information.
And with the EnumChildWindows command you will get the handles of other child windows. Respects.
-CreateToolHelp32SnapShot and Process32First
You should take a snapshot of the system with its commands. The ThreadId information of the application you want will be included in the image you receive.
-GetWindowThreadProcessID
It will give the window handle of the ThreadId information.
And with the EnumChildWindows command you will get the handles of other child windows. Respects.
Kalk ve işe yarar bir şey yap! Çünkü Allah (c.c.) yeniden başlayanların yardımcısıdır.
-
- Üye
- Mesajlar: 17
- Kayıt: 09 Eyl 2016 11:57
Re: Help - Excel - VCL form
Nazik Loaded rehberlik için teşekkürler. Değerli zamanınızı bir örnek yaparak geçirebilir misiniz? Proje dosyam ektedir. Ama nasıl daha profesyonel hale getireceğimi bilmiyorum
- Dosya ekleri
-
- ExcelHWND.zip
- (53.34 KiB) 57 kere indirildi
Re: Help - Excel - VCL form
Konu ile ilgili daha önce yaptığım bir çalışma (Lazarus kullanılarak yapılmıştır.) işimi görmüştü. İncelemenizde yarar var diye düşünüyorum.
O zaman yararlandığım bir kaynak ; http://aziga.x10.mx/delphi/index.php?op ... &Itemid=11
O zaman yararlandığım bir kaynak ; http://aziga.x10.mx/delphi/index.php?op ... &Itemid=11
- Dosya ekleri
-
- PidConvertoHandle.rar
- (126.15 KiB) 52 kere indirildi
Kalk ve işe yarar bir şey yap! Çünkü Allah (c.c.) yeniden başlayanların yardımcısıdır.
-
- Üye
- Mesajlar: 17
- Kayıt: 09 Eyl 2016 11:57
Re: Help - Excel - VCL form
Teşekkürler Pro,
Delphi'ye geçtim ve uydum ama hiç yanıt vermedi ve tek bir mesaj görünmedi. Neden? Niye?
Note: add unit Winapi.Messages in Uses clause
Delphi'ye geçtim ve uydum ama hiç yanıt vermedi ve tek bir mesaj görünmedi. Neden? Niye?
Note: add unit Winapi.Messages in Uses clause
- Dosya ekleri
-
- PidConvertoHandle.zip
- (142.57 KiB) 63 kere indirildi
Re: Help - Excel - VCL form
Lazarus kullanıyorum, delphi kullanmıyorum. O yüzden delphi için biraz değişiklik yapmanız gerekebilir.
En basit şekliyle ;
Unit1.pas içerisindeki kodları inceleyerek, ilgilendiğiniz Uygulamaya ve içerisindeki handle verisi olan kontrollere erişebilirsiniz. Bence, işin en önemli kısmı EnumChildWindows. İlgili kullanımı ise ;
En basit şekliyle ;
Unit1.pas içerisindeki kodları inceleyerek, ilgilendiğiniz Uygulamaya ve içerisindeki handle verisi olan kontrollere erişebilirsiniz. Bence, işin en önemli kısmı EnumChildWindows. İlgili kullanımı ise ;
Kod: Tümünü seç
function blah( HWnd : Cardinal; Param : longint):bool;stdcall;
function GetWindowContents(WindowHandle: Integer): string;
var
Buffer: String;
BufLen: Integer;
begin
BufLen := SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0);
SetLength(Buffer, BufLen + 1);
SendMessage(WindowHandle, WM_GETTEXT, BufLen + 1, LParam(PChar(Buffer)));
result:=buffer;
end;
var
a: pchar;
New: String;
begin
a:= stralloc(256);
getclassname(hwnd, a, 255);
with Form1.TreeView1.Items do
begin
AddChild(MyTreeNode1,
inttostr(HWnd)+' '+
IntToHex(HWnd,8)+' '+
//a+' ' +
GetWindowContents(HWnd)
);
end;
strdispose(a);
Result := true;
end;
procedure Fenum(fhandle:integer);
begin
if EnumChildWindows(fhandle, @blah, 0) then
begin
end
else
begin
end;
end;
Kalk ve işe yarar bir şey yap! Çünkü Allah (c.c.) yeniden başlayanların yardımcısıdır.