<p>I'm developing an MFC application and I've recently been searching for a good method to remove the icon from a Windows title bar, but retain the close button. The two obvious candidate solutions are turning off the system menu style or using the tool window style, but I would prefer not to disable the system menu or use the shrunken tool window title bar. Many MFC applications have this functionality, so I wonder: am I missing some standard way of doing this?</p>

[{'answer_id': 10092, 'author': 'Keng', 'author_id': 730, 'author_profile': 'https://Stackoverflow.com/users/730', 'pm_score': 0, 'selected': False, 'text': '<p>what about getting rid of the system menu and then putting it back in another place yourseld (say next to the close button etc.)?</p>\n'}, {'answer_id': 10539, 'author': 'Aidan Ryan', 'author_id': 1042, 'author_profile': 'https://Stackoverflow.com/users/1042', 'pm_score': 0, 'selected': False, 'text': "<p>Without the icon, the only method I could imagine for users to access the system menu is via right-click of the titlebar.  </p>\n\n<p>If that's what you had in mind, you could handle WM_RBUTTONDOWN on your main frame and then calculate if the right-click was on the titlebar.</p>\n\n<pre><code>int clickX = GET_X_LPARAM(lParam);\nint clickY = GET_Y_LPARAM(lParam);\n\nCRect frameRect;\nmainFrame.GetWindowRect(&amp;frameRect);\n\nint titleBarHeight = GetSystemMetrics(SM_CYCAPTION);\n\nif (clickX &gt;= frameRect.left &amp;&amp;\n    clickX &lt;= frameRect.right &amp;&amp;\n    clickY &gt;= frameRect.top &amp;&amp;\n    clickY &lt;= frameRect.top + titleBarHeight)\n{\n   TrackPopupMenu(m_systemMenu);\n}\n</code></pre>\n"}, {'answer_id': 10555, 'author': 'Andrew Grant', 'author_id': 1043, 'author_profile': 'https://Stackoverflow.com/users/1043', 'pm_score': 3, 'selected': True, 'text': '<p>You can use <code>WM_NCRBUTTONDOWN</code> to detect if the user has right-clicked on your caption and then bring up the system menu.</p>\n'}, {'answer_id': 834720, 'author': 'ezolotko', 'author_id': 71689, 'author_profile': 'https://Stackoverflow.com/users/71689', 'pm_score': 2, 'selected': False, 'text': '<p>Set <code>WS_EX_DLGMODALFRAME</code> extended style.</p>\n'}, {'answer_id': 6245860, 'author': 'IronMensan', 'author_id': 637801, 'author_profile': 'https://Stackoverflow.com/users/637801', 'pm_score': 2, 'selected': False, 'text': '<p>You could use a fully transparent icon.</p>\n'}, {'answer_id': 43352493, 'author': 'Alex', 'author_id': 92713, 'author_profile': 'https://Stackoverflow.com/users/92713', 'pm_score': 0, 'selected': False, 'text': '<p>A sample code in Delphi which removes icon:</p>\n\n<pre><code>const\n  WM_ResetIcon = WM_APP - 1;\n\ntype\n  TForm1 = class(TForm)\n    procedure FormShow(Sender: TObject);\n  protected\n    procedure WMResetIcon(var Message: TMessage); message WM_ResetIcon;\n  end;\n\nimplementation\n\nprocedure TForm1.FormShow(Sender: TObject);\nbegin\n  PostMessage(Handle, WM_ResetIcon, 0, 0);\nend;\n\nprocedure TForm1.WMResetIcon(var Message: TMessage);\nconst\n  ICON_SMALL = 0;\n  ICON_BIG   = 1;\nbegin\n  DestroyIcon(SendMessage(Handle, WM_SETICON, ICON_BIG, 0));\n  DestroyIcon(SendMessage(Handle, WM_SETICON, ICON_SMALL, 0));\nend;\n</code></pre>\n\n<p>A similar code should work for MFC. Basically, you just need to WM_SETICON to NULL in the right place.</p>\n'}]
['https://Stackoverflow.com/questions/10059', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']