This code I wrote will hide or show windows that have a one-word title (such as the Run dialog), but it stops responding until I press Ctrl+C if I try to do a window with more than one word("My Documents"). Why is this happening? Here is the code:
Code:#include <windows.h> #include <iostream.h> int main() { char* winName = new char; cout<<"Type in the window name:"<<endl; cin>>winName; HWND h = FindWindow(NULL, winName); if (h == NULL) MessageBox(NULL, "Could not find window", "Error", MB_OK | MB_ICONERROR); else { if (ShowWindow(h, SW_HIDE) == 0) // window was hidden, show it ShowWindow(h, 1); else //window was visible, hide it ShowWindow(h, 0); } return 0; }




Reply With Quote