Child Window

well... let's say there are 4 Child Control, all have the same name. I know how to send a message to the first one, but how can i send messages to the others?


Comments

  • : well... let's say there are 4 Child Control, all have the same name. I know how to send a message to the first one, but how can i send messages to the others?

    :



    // HOW CAN TWO CONTROLS HAVE THE SAME NAME ???



    unit Unit1;

    interface



    uses Forms, Classes, Controls, StdCtrls;



    type

    TForm1 = class(TForm)

    Button1: TButton;

    Button2: TButton;

    procedure Button1Click(Sender: TObject);

    end;



    var Form1: TForm1;



    implementation

    {$R *.DFM}



    procedure TForm1.Button1Click(Sender: TObject);

    begin

    //Error: "A component named Button1 already exists"

    Button2.Name:='Button1';

    end;



    end.




  • there is a hWnd object with 5 hild controls (5 buttons to be exactly). They all have the same class name [ZRollOverButton].


  • : there is a hWnd object with 5 hild controls (5 buttons to be exactly). They all have the same class name [ZRollOverButton].

    :



    // For this example, I just dropped a bunch of components on Panel1.

    // I still don't quite understand how these API "Callback" functions

    // work, but this fills ListBox1 with the Handles and ClassNames of

    // all the components on Panel1. Look at "EnumChildWindows" in the

    // Windows Help File for more info...





    // Be sure to declare "EnumChildProc" as "StdCall"

    // I ended up with a very nasty Access Violation without it!



    function EnumChildProc(Wnd:hWnd; LParam:Longint):BOOL; StdCall;

    var szClassName:Array[0..255] of char;

    begin

    GetClassName(Wnd,szClassName,SizeOf(szClassName));

    // Here you could check for StrPas(szClassName)='ZRollOverButton';

    TListBox(LParam).Items.Add(IntToStr(LongInt(Wnd))+':'+StrPas(szClassName));

    Result:=Wnd<>0;

    end;







    procedure TForm1.Button1Click(Sender: TObject);

    begin

    // You can use your own "hWnd" instead of Panel1.Handle here...

    EnumChildWindows(Panel1.Handle,@EnumChildProc,Longint(ListBox1));

    end;




  • Thanx man! Youre da bomb lol




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories