- Created windows have no title [closed]
- 1 Answer 1
- WinAPI: Create resizable window without title bar, but with minimize/maximize/close buttons (as Firefox/Chrome/Opera)
- 3 Answers 3
- Couldn’t find window with title #151
- Comments
- StanislauMinsk commented Sep 3, 2013
- JakeGinnivan commented Sep 3, 2013
- me-snail commented Sep 9, 2013
- JakeGinnivan commented Sep 11, 2013
- Wintitle from window with no title or class?
- How to hide the title bar for an Activity in XML with existing custom theme
- 37 Answers 37
Created windows have no title [closed]
Want to improve this question? Update the question so it’s on-topic for Stack Overflow.
Closed 4 years ago .
I am creating messages windows from my console application. The window class is registered correctly and the window is created correctly however it never has a title (while my createwindow function call does specify a title). Got me thinking, can console programs create windows with name? Googled it, found nothing. This is my code, kept to the minimum :
Checking with Nirsoft’s Winlister, the window exists, has the right class («EME.LauncherWnd»), but has no name. furthermore, adding these lines of code in the block :
And yet, the window still doesn’t have a title. If console program couldn’t have title I’d assume the SetWindowText call would return 0. What am I doing wrong ? Edit : Adding pWndProc as requested
Though after the comment pointing out the pWndProc (which body i thought was irrelevant to the construction of the window), it turns out inserting this code line as a default in the switch case
solves the problem.
1 Answer 1
I am posting the answer to the question as suggested by a comment : The answer is that for the window creation to complete, the pWndProc passed to RegisterClass WINAPI has to process default messages (in particular OS messages). During the execution of CreateWindow(after the call has started and before it has returned), the pWndProc function already receives messages that it has to process, in my case it didn’t process them. This is a standard pWndProc function:
A window procedure does not usually ignore a message. If it does not process a message, it must send the message back to the system for default processing. The window procedure does this by calling the DefWindowProc function, which performs a default action and returns a message result. The window procedure must then return this value as its own message result. Most window procedures process just a few messages and pass the others on to the system by calling DefWindowProc.
WinAPI: Create resizable window without title bar, but with minimize/maximize/close buttons (as Firefox/Chrome/Opera)
If you look at the windows of the browsers Firefox, Chrome or Opera, you’ll notice that their windows
- have minimize/maximize/close buttons
- are resizable
- but have no title bar
I’m interested: how can I create such a window?
What I have already tried:
I looked around on StackOverflow (and googled, too), and found this: opening a window that has no title bar with win32
Unluckily, this didn’t help completely:
The first step was to extend the solution proposed on opening a window that has no title bar with win32
Of course, this delivers no minimize/maximize buttons, but on the other hand, if I want minimize/maximize buttons, I have to do:
Why does this combination seem to be necessary? First I probably want WS_MAXIMIZEBOX | WS_MINIMIZEBOX since I want these buttons.
But http://msdn.microsoft.com/en-us/library/ms632600.aspx says that if I set one of WS_MAXIMIZEBOX and WS_MINIMIZEBOX , I also have to set WS_SYSMENU . And when I set WS_SYSMENU , I also have to set WS_CAPTION but this is not what I want, because I wanted to avoid the title bar (indeed: if WS_CAPTION is not set, no minimize/maximize buttons are shown).
So what is to do?
3 Answers 3
The programs remove the non-client area (the title bar) and have a bunch of custom handling for reproducing the window buttons, icons, system menu etc. The benefit of this is that they can draw to the new «title bar», which is actually part of the standard client area, adding tabs or other custom controls.
The following two articles will show you how to do this on Vista and above (using the DWM):
This is very complex to do and get right, so the above two articles are invaluable. The author must have put a lot of work into them! Both links have example code written in Delphi, but it should be easy enough to translate it to C++ — the concepts are identical, it’s just syntax.
You might also be interested in general resources on Glass and DWM, since it’s all closely related. You’ll spot the above two links included in that list 🙂
You can create a window with or without caption — whatever is more appropriate from the point of view of desired customization (that is «without» is you want to do it «without title bar» as you say), and the important wart is that you take over painting non-client area — this is the key thing.
At this point, there is no one to paint your mimimize/maximize buttons already. It does not however mean that you have to do the painting right from scratch and mimic standard UI. There is DrawFrameControl and friends API where you can use DFCS_CAPTIONMIN argument and have minimize button painted for you. You will also want to respond to other non-client area messages, e.g. handle WM_NCHITTEST to tell Windows where your new window buttons are.
You might also want to check Visual Styles Reference to leverage theme-enabled drawing API such as DrawThemeBackground .
A simple example of this activity is putting an additional button onto caption, such as described in detail here: CCaptionButton (buttons for the titlebar).
Couldn’t find window with title #151
Comments
StanislauMinsk commented Sep 3, 2013
Hello, I use your lib, but 1 have problem into this method
public Window GetWindow(string title)
<
return this.host.GetWindow(title, InitializeOption.NoCache);
>
I get error «Couldn’t find window with title **** in process 3752, after waiting for 5000 ms», please help me. Thank you.
The text was updated successfully, but these errors were encountered:
JakeGinnivan commented Sep 3, 2013
The exception has some additional properties on it with debug information including the windows on screen etc.
Basically the error is self describing. White cannot find the window with the title you have specified in that application. Without details like the info from uia verify, and the title you are trying to find i don’t have enough information to guess what your problem is.
When you do find the answer please share it or contribute to Whites doco 🙂
Sent from my Windows Phone
From: StanislauMinskmailto:notifications@github.com
Sent: ý03/ý09/ý2013 13:20
To: TestStack/Whitemailto:White@noreply.github.com
Subject: [White] Couldn’t find window with title (#151)
Hello, I use your lib, but 1 have problem into this method
public Window GetWindow(string title)
<
return this.host.GetWindow(title, InitializeOption.NoCache);
>
I get error «Couldn’t find window with title **** in process 3752, after waiting for 5000 ms», please help me. Thank you.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/151.
me-snail commented Sep 9, 2013
I also want to add one more problem regarding this GetWindow ()
I am trying to automate (winform) desktop application which has Facebook or Twitter connect options ,
While automating Sign in functionality for that ,
From main application window i am trying to get sign in window by following statement ,
var signTwit = _application.GetWindow(SearchCriteria.ByText(«Twitter Login»), InitializeOption.NoCache);
OR
private static TestStack.White.UIItems.WindowItems.Window _signWindow = null;
_signWindow = _application.GetWindow(SearchCriteria.ByAutomationId(«TwitterLogin»), InitializeOption.NoCache);
All the above approaches are failing , i am not able to get the sign in window ,
So i tried to list down all windows for the application as follows ,
List windows = _application.GetWindows();
System.Console.WriteLine(«*******» + windows.Count.ToString());
System.Console.WriteLine(«window-title» + windows[0].Title + » » + windows[1].Title + » » + windows[1].Visible);
and i am getting the twitter sign in window in list as windows[1].
but i am not able to get the exact problem in the first approach by using GetWindow() method.
I tried to get window ByAutomationId and ByText.
Also there is one problem using ByControlType ,
I am using Visual Studio 2013 preview on Windows 7 (64 bit) here , installed TestStack Version ‘TestStack.White 0.11.0.207’.
It is not recognising ControlType keyword .
JakeGinnivan commented Sep 11, 2013
What is the window name in visual uia?
Sent from my Windows Phone
From: amrutavmailto:notifications@github.com
Sent: ý09/ý09/ý2013 08:24
To: TestStack/Whitemailto:White@noreply.github.com
Cc: Jake Ginnivanmailto:Jake.Ginnivan@readify.net
Subject: Re: [White] Couldn’t find window with title (#151)
I also want to add one more problem regrading this GetWindow ()
I am trying to automate (winform) desktop application which has Facebook and Twitter connect ,
While automating Sign in functionality for that ,
From main application window i am trying to get sign in window by following statement which are failed ,
var signTwit = _application.GetWindow(SearchCriteria.ByText(«Twitter Login»), InitializeOption.NoCache);
OR
private static TestStack.White.UIItems.WindowItems.Window _signWindow = null;
_signWindow = _application.GetWindow(SearchCriteria.ByAutomationId(«TwitterLogin»), InitializeOption.NoCache);
here i am not able to get the sign in window ,
so i tried to list down all windows for the application as follows ,
List windows = _application.GetWindows();
System.Console.WriteLine(«*******» + windows.Count.ToString());
System.Console.WriteLine(«window-title» + windows[0].Title + » » + windows[1].Title + » » + windows[1].Visible);
and i am getting the twitter sign in window in list as windows[1] ,
but i am not able to get the exact problem in the first approach by using GetWindow() method.
I tried to get window ByAutomationId and ByText.
Also there is one problem using ByControlType ,
I am using Visual Studio 2013 preview on Windows 7 (64 bit) here,
so it is not recognising ControlType keyword .
Wintitle from window with no title or class?
I have a window that is not seen by Windowspy or Winspector as a title name: It comes up with:
>>>>>>>>>>( Window Title & Class ) >>>>>>>>>>>( Mouse Position ) >>>>>>>>( Now Under Mouse Cursor ) #1 — Posted 19 September 2006 — 05:23 PM
- Members
- 448 posts
Last active: Jan 15 2010 05:41 AM
- Joined: 30 Dec 2005
- Moderators
- 6850 posts
Last active: Jan 02 2012 10:09 PM
- Joined: 27 Dec 2005
With some code like that:
Except that the ahk_class of window is AutoHotkeyGUI and ClassNN is Static1, but these can be changed. And #32770 is a very common class, eg. look at a simple MsgBox.
The WinTitle can be empty or just a space as in my example. Why do you want it? No other way to control it?
PhiLho/KM64.png»/> vPhiLho := RegExReplace ( «Philippe Lhoste», «^(\w<3>)\w*\s+\b(\w<3>)\w*$», «$1$2» )
- Members
- 5519 posts
Last active: May 17 2015 06:39 AM
- Joined: 26 Oct 2012
- Members
- 448 posts
Last active: Jan 15 2010 05:41 AM
- Joined: 30 Dec 2005
- Guests
Last active:
- Joined: —
Thanks for the replies. I tried the suggestions but no go.
It’s a window from Dragon Naturally Speaking: I was hoping to be able to extract certain words from the window and make them out as other commands. It wasn’t a bad copy-paste job, that’s what it says when I click on the window.
I read in some forum searching that #32770 is a child window but I can’t find it’s father. I tried all the various dragon-related hidden windows but couldn’t get anything to work with the following format or with controlgettext-type equivalent:
SetTitleMatchMode, 2
SetTitleMatchMode, slow
DetectHiddenWindows, on
Q::
WinGetTitle, title, ahk_class #327701
msgbox, %title%
return
How to hide the title bar for an Activity in XML with existing custom theme
I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can’t simply set the theme to @android:style/Theme.NoTitleBar .
Using the NoTitleBar theme as a parent for my style would remove the title bar from all of my activities.
Can I set a no title style item somewhere?
37 Answers 37
Do this in your onCreate() method.
this refers to the Activity .
You can modify your AndroidManifest.xml :
or use android:theme=»@android:style/Theme.Black.NoTitleBar» if you don’t need a fullscreen Activity.
Note: If you’ve used a ‘default’ view before, you probably should also change the parent class from AppCompatActivity to Activity .
Now I can set this style to every Activity in which I want to hide the title bar overwriting the application wide style and inheriting all the other style informations, therefor no duplication in the style code.
To apply the style to a particular Activity, open AndroidManifest.xml and add the following attribute to the activity tag;
I don’t like the this.requestWindowFeature(Window.FEATURE_NO_TITLE); because the title bar appears briefly, then disappears.
I also don’t like the android:theme=»@android:style/Theme.NoTitleBar» because I lost all of the 3.0+ Holo changes that the users of the new devices have gotten used to. So I came across this solution.
In your res/values folder make a file called styles.xml (If it doesn’t already exist). In that file place the following code:
Next create a res/values-v11 with another styles.xml file (Once again this may already exist). In that file place the following code:
And if you are targeting 4.0+, create a res/values-v14 folder with yet another styles.xml file (Yes it may already be there). In that file place the following code:
Finally, with all of these files created, open your AndroidManifiest.xml file you can add the code:
to the activity tag of the activity you want no title for or the application tag if you want it to apply to the entire application.
Now your users will get the themes associated with their device version with the screen layout you desire.