How I can delete window title from my application?

Posted on 2009-07-05
Last Modified: 2012-05-07
I'm new to C++ and programming, I've background for php and perl but started to write some C++ codes. I'm trying to make a window title become untitle i mean window icon should stay there but window name must be deleted.
I need it to because I'm injecting a dll to one of old game and need to delete its window title.
Justin Uberti
Question by:juberti
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 24779910
Give some spaces in the title property. It will appear as if no title is there.

Accepted Solution

Erbureth earned 500 total points
ID: 24779911
If you are using plain Windows API, you need to obtain handle of the window you want to edit, then you can call SetWindowText, which is in user32.dll (you can use #include <Windows.h>)
here is the function prototype

BOOL SetWindowText (
  HWND hWnd; // handle of a window
  LPCTSTR lpString // new text in a window

See MSDN for more info

Author Comment

ID: 24780019
Erbureth , thanks i done it after looking it.
Now my only problem is getting parentwindows hwnd i can make it if parent windows title is static thanks for your help and if you know how can i get parent window's hwnd ill be appreciated.
I tried getparentwindow but couldnt succeeded :)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 24780024
macksm, ty for your reply too but it wasn't the thing i was seeking
LVL 86

Expert Comment

ID: 24780025
In order to set/erase any window's text, you first need the window handle. Since you are injecting a DLL, you don't have that one, but only a process handle, ut that's a start. You could basically do the following:
HWND  g_hwnd;
int  g_nFound;
HWND GetHwndFromPID ( DWORD dwProcessId)
 g_hwnd = NULL;
 g_nFound = 0;
 EnumWindows (  FindHwndFromPID,    ( LPARAM) dwProcessId));
 if ( g_hwnd)  // we found one...
      return ( g_hwnd);
 // nothing found :-(
 return (NULL);
    DWORD   dwPID2Find  =   ( DWORD) lParam;
    DWORD   dwPID       =   0;
    if  (   GetWindowThreadProcessId    (   hwnd,   &dwPID))
            if  (   dwPID   ==  dwPID2Find)
                    g_hwnd  =   hwnd;
                    return  (   FALSE);
    return  (   TRUE);
// ...
// ...
// in your DLL:
HWND hWnd = GetHwndFromPID(GetCurrentProcessId());
SetWindowTexy(hWnd,_T("")); // or just "" if compiling ANSI

Open in new window


Author Comment

ID: 24780064
Hello jkr, ty for your example, i do nearly same for static window title name with putting NULL with your example i can do it for parent window title.
Now the main purpose of i'm doing it i need to hide that window from enumwindows but as i noticed now if user searchs for null window title he can attach its program to mine. Now i think i need to seek another thing for doing this.
Between is there a way for completely removing title/window from enumwindows or hiding it?

Author Comment

ID: 24780161
Ah my bad sorry, i checked handle of injection it finds explorer.exe and injects ty now the thing does the job i wanted.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 70
best sources to up-to-date in C++? 8 104
Precision Problem in C++ 7 52
c++  placing data into a form and an editbox 5 25
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question