Delphi ÖÐ FindWindow ºÍ FindWindowEx µÄÓï·¨ºÍÓ÷¨
Delphi ÖÐ FindWindow ºÍ FindWindowEx µÄÓï·¨ºÍÓ÷¨
FindWindow(
lpClassName, {´°¿ÚµÄÀàÃû}
lpWindowName: PChar {´°¿ÚµÄ±êÌâ}
): HWND; {·µ»Ø´°¿ÚµÄ¾ä±ú; ʧ°Ü·µ»Ø 0}
//FindWindowEx ±È FindWindow ¶à³öÁ½¸ö¾ä±ú²ÎÊý:
FindWindowEx(
Parent: HWND; {Òª²éÕÒ×Ó´°¿ÚµÄ¸¸´°¿Ú¾ä±ú}
Child: HWND; {×Ó´°¿Ú¾ä±ú}
ClassName: PChar; {}
WindowName: PChar {}
): HWND;
{
Èç¹û Parent ÊÇ 0, Ôòº¯ÊýÒÔ×ÀÃæ´°¿ÚΪ¸¸´°¿Ú, ²éÕÒ×ÀÃæ´°¿ÚµÄËùÓÐ×Ó´°¿Ú;
Èç¹û ÊÇ HWND_MESSAGE, º¯Êý½ö²éÕÒËùÓÐÏûÏ¢´°¿Ú;
×Ó´°¿Ú±ØÐëÊÇ Parent ´°¿ÚµÄÖ±½Ó×Ó´°¿Ú;
Èç¹û Child ÊÇ 0, ²éÕÒ´Ó Parent µÄµÚÒ»¸ö×Ó´°¿Ú¿ªÊ¼;
Èç¹û Parent ºÍ Child ͬʱÊÇ 0, Ôòº¯Êý²éÕÒËùÓеĶ¥²ã´°¿Ú¼°ÏûÏ¢´°¿Ú.
}
//²âÊÔ1: ÊÔ×ÅÕÒÕÒн¨³ÌÐòÖ÷´°¿ÚµÄ¾ä±ú
var
h: HWND;
begin
{ÏÖÔÚÎÒÃÇÖªµÀ´°¿ÚµÄ±êÌâÊÇ: Form1¡¢´°¿ÚµÄÀàÃûÊÇ: TForm1}
h := FindWindow('TForm1', 'Form1');
ShowMessage(IntToStr(h)); {656180; ÕâÊÇËæ»ú, ÿ´ÎÆô¶¯´°¿Ú¿Ï¶¨²»Ò»Ñù}
{¼ÙÈç²»ÖªµÀÀàÃû}
h := FindWindow(nil, 'Form1');
ShowMessage(IntToStr(h)); {656180}
{¼ÙÈç²»ÖªµÀ±êÌâÃû}
h := FindWindow('TForm1', nil);
ShowMessage(IntToStr(h)); {656180}
{ÆäʵÕâ¸ö´°¿ÚµÄ¾ä±ú²»¾ÍÊÇ Self.Handle Âð}
ShowMessage(IntToStr(Handle)); {656180}
end;
//²âÊÔ2: ÕÒ¼ÆËãÆ÷´°¿ÚµÄ¾ä±ú(ÏÈ´ò¿ª¼ÆËãÆ÷)
var
h: HWND;
begin
{Èç¹û²»ÊǼòÌåÖÐÎÄϵͳ, ÕâÑù¿ÉÄܲ»Áé}
h := FindWindow(nil, '¼ÆËãÆ÷');
ShowMessage(IntToStr(h)); {1508334}
{×îºÃÕâÑù, µ«ÄãµÃÌáÇ°ÖªµÀ¼ÆËãÆ÷´°¿ÚµÄÀàÃûÊÇ: SciCalc}
h := FindWindow('SciCalc', nil);
ShowMessage(IntToStr(h)); {1508334}
end;
±¾Îijö×Ô 51CTO.COM¼¼Êõ²©¿Í
Ïà¹ØÎĵµ£º
²Î¿¼×ÊÁÏ
“dz̸Object PascalµÄÖ¸Õë”
“Delphi Ö¸ÕëÈëÃÅ”
»ù±¾ÖªÊ¶
Ö¸Õë
Ö¸ÕëÊÇÒ»¸öÌØÊâµÄ±äÁ¿£¬ËüÀïÃæ´æ´¢µÄÊýÖµ±»½âÊͳÉΪÄÚ´æÀïµÄÒ»¸öµØÖ·¡£
×¢Ò⣺
£¨1£©¡¢Ö¸Õë¶ÔÓ¦×ÅÒ»¸öÊý¾ÝÔÚÄÚ´æÖеĵØÖ·£¬µÃµ½ÁËÖ¸Õë¾Í¿ÉÒÔ×ÔÓɵØÐ޸ĸÃÊý¾Ý¡£
£¨2£©¡¢Ò»¸öÖ¸Õë±äÁ¿½ö½öÊÇ´æ´¢Ò ......
exit: Í˳öº¯ÊýÌå
abort: Óöµ½Òì³£,°²¾²´¦Àí,¾ÍÊDz»ÏÔʾ²»Ìáʾ
break: Í˳öµ±Ç°Ñ»·Ìå,°üÀ¨for ,while, repeatµÈÑ»·Ìå
continue: ½áÊøÑ»·Äڵı¾´Î´¦Àí,¼ÌÐø´ÓÑ»·ÌåµÄ¿ªÊ¼Î»ÖüÌÐøÖ´ÐÐ
Exit ÊÇÌø³öµ±Ç°´úÂë¿é£¬Ò²¾ÍÊǵ±Ç°º¯Êý£¬Ìø³öºóÊÇÒª¼ÌÐøÏòÏÂÖ´Ðеģ¨Èç¹ûÓкóÐø´úÂ룩¡£
Abort ÊÇ´Ó EAbort ¹ýÀ´µÄ£¬¿ÉÒÔ¼¤·¢ ex ......
procedure TForm2.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Screen.Cursor := -2;
end;
const
crDefault = TCursor(0);
crNone = TCursor(-1);
crArrow = TCursor(-2);
&n ......
Îҵİ취£¬Ôö¼ÓÒ»¸ötimer ÉèÖüä¸ô100ms£¬Í¨¹ýtimerµÄʹÄÜ·ñ£¬¿ØÖƱ¨¾¯ÉùÒô¿ª¹Ø
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Windows.Beep(1200+i_f,10+i_f);
if i_f<2000 then
begin
inc(i_f);
end
end;
== ......
¾àÀëÉÏһƪϵÁеÄÎÄÕÂÓÐÒ»¶Îʱ¼äÁË£¬¼ÙÖÕÓÚÊÇ·ÅÍêÁË£¡ÏÖÔÚÔÛ¼ÌÐøÔÚTEditÉÏ×öÎÄÕ£¬Í¬Ê±À´ÊìϤijЩWindowsµÄϵͳÏûÏ¢¡£ÏÖÔÚÎÒ½²µÄÊÇÈçºÎʵÏÖÒ»¸öÀàËÆQQ±à¼¿òµÄÑùʽ¡£
ÔÙ½²½â֮ǰ£¬ÏÈ»ØÀ¡Ç°¼¸ÆªÎÄÕÂÓÐЩÈËÌá³öµÄÎÊÌ⡣ͨ¹ýÇ°¼¸ÆªÎÄÕ£¬ÓкܶàÈ˹Ø×¢£¬Í¬Ê±Ò²ÓÐÈ˸øÁËһЩ½¨Òé¡£ËùÒÔÎÒÕâÀï˵Ã÷һϣ¬ÎÒÕâ¸ö×é¼ ......