I know that in X window programming, if I know the ID of a particular window, I can manage it. For example, I can resize that window by using
XResizeWindow(display, win, 200, 300);

So my question is, how to get the window ID?

Particularly, when I know the PID of a program, how can I get the X window ID of the window in which it is running?

thanks in adv!