Title Bar Button in DirectX

I am going through a DirectX tutorial and my title bar buttons, namely Minimize, Maximize, and Close, are missing... Here is the code that I think it would be in:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      // Create the Window Class Structure
      WNDCLASSEX wc;
      
      // Fill the Struct with Info
      wc.cbSize        = sizeof(WNDCLASSEX);
      wc.style         = CS_HREDRAW | CS_VREDRAW;
      wc.lpfnWndProc   = (WNDPROC)WinProc;
      wc.cbClsExtra    = 0;
      wc.cbWndExtra    = 0;
      wc.hInstance     = hInstance;
      wc.hIcon          = NULL;
      wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
      wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
      wc.lpszMenuName  = NULL;
      wc.lpszClassName = APPTITLE;
      wc.hIconSm       = NULL;
      
      // Set Up the Window with the Class Info
      return RegisterClassEx(&wc);


None of the buttons are there. I would also like a '?' Button too so I can show an "About" messagebox. What do I need to do?
How are you calling CreateWindow?
You can specify those things in there: http://msdn.microsoft.com/en-us/library/ms632600%28VS.85%29.aspx
My CreateWindow() function looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
// Create a New Window
hWnd = CreateWindow(
	APPTITLE,
	APPTITLE,
	WS_OVERLAPPED,
	CW_USEDEFAULT,
	CW_USEDEFAULT,
	SCREEN_WIDTH,
	SCREEN_HEIGHT,
        NULL,
	NULL,
	hInstance,
	NULL);


I don't see any styles that specifies the close button being there, although I do see styles for the minimize and maximize buttons. Close is what I need the most. I would think the close button would show by default. Maybe it has something to do with DirectX...?
Last edited on
IIRC WS_SYSMENU means that 'X' button
if you change WS_OVERLAPPED to WS_OVERLAPPED_WINDOW you would have everything but the '?' button on your titlebar
It said undeclared identifier... but WS_OVERLAPPEDWINDOW (only 1 underscore) works, and it show max, min, and close... Thanks Bazzy!!

Now... I wonder how they do the '?' button...
Try with CreateWindowEx ( http://msdn.microsoft.com/en-us/library/ms632680%28VS.85%29.aspx ) you will have an extra parameter at the beginning which you can set to WS_EX_CONTEXTHELP. It should add that '?'
Hmm... yeah it looks like it would. Though it says you can't use WS_EX_CONTEXTHELP with the maximize and minimize buttons, so you can't use it with WS_OVERLAPPEDWINDOW... But even if I make the style WS_OVERLAPPED (with no buttons at all on the title bar) or even if I make the style NULL, it still does not show the '?' like it should; it just shows nothing on the title bar.



So here's what I did next... I looked at the WS_OVERLAPPEDWINDOW style and saw that it was nothing but a style made up of these other styles...

WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.



So instead of using WS_OVERLAPPED -or- WS_OVERLAPPEDWINDOW, I used the styles in WS_OVERLAPPEDWINDOW minus the min and max styles, so it looked like this...

WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME


This gave me a title bar with only a Close button... then I used CreateWindowEx and used WS_EX_CONTEXTHELP as the dwExStyle, and it worked!!


Now I have a '?' button and a 'X' button only, which is exactly what I wanted.


Thanks for pointing me in the right direction... I knew we would figure it out eventually.
Topic archived. No new replies allowed.