Jump to content
  • Advertisement
Sign in to follow this  

Moving an external window

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello to all! I've got a program that every time i run it, it positiones itself in a very owful way. So i thought to create a little program, getting HWND of the windows and move it with SetWindowPos. I wrote this code with notepad.exe, to make some tries:
	HWND desktop = GetDesktopWindow();
	HWND childwindow;
	DWORD ProcessID;
	int x;
	int y;

	si.cb = sizeof(STARTUPINFO);

	childwindow = GetWindow(desktop,GW_CHILD);

	while (childwindow != NULL)

				if ( ProcessID == ProcInfo.dwProcessId )

			childwindow = GetWindow(childwindow,GW_HWNDNEXT);

	if (childwindow == NULL)
		return;				//Il software non è stato aperto. Non dovrebbe mai accadere.

	x = GetSystemMetrics(SM_CXSCREEN);
	y = GetSystemMetrics(SM_CYSCREEN);

	SetWindowText(childwindow,"Jada jada jada");

I'm able to find process, but the window looks like ignore SetWindowText and SetWindowPos, beyond ShowWindow. After SetWindowPos, if i open again notepad, appears also a little window in the top left of the screen, sometimes with my title, sometimes not. Is this the right way? Have you got other methods?

Share this post

Link to post
Share on other sites
I did a GetWindowText on childwindow, i received MSCTFIME UI and not the notepad titlebar text.


Share this post

Link to post
Share on other sites
An easier and more successful method would be to use FindWindow() or FindWindowEx() (assuming you know the window's caption or class). The window's class can be found using Spy++.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!