Solved

No Sysmenu

Posted on 1998-12-01
9
334 Views
Last Modified: 2013-12-03
Is it possible to create a WIN32 app with a window having a title bar and a [X] close button BUT NO system menu.
Or do I have to have a dialog box as my main.

Thanks,
0
Comment
Question by:okuru
[X]
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
  • 4
  • 3
  • 2
9 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1416532
Remove style WS_SYSMENU from CreateWindow
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416533
Just don't specify the WS_SYSMENU window style.  You probably want to specify WS_CAPTION WS_OVERLAPPED WS_THICKFRAME and maybe WS_MINIMIZE and WS_MAXIMIZE.

Let me know if you have questions.  (If that doesn't work, There is another way, but i think that will)
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1416534
Damn, I pressed comment iso answer
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:okuru
ID: 1416535
Does not work - I want a window with a title bar, a [X] close button but NO icon/sysmenu...

0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1416536
As I said, there was a possibility that that would not work, try it again with the same styles but also specify a WS_DLGFRAME.  (Ignore the documentation for WS_DLGFRAME that says you can't have a title with it.  You can.  That is left over from windows 3.1)
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416537
I create such a window in my programs.  The styles I use are

 WS_POPUPWINDOW | WS_DLGFRAME | WS_THICKFRAME | WS_OVERLAPPED | WS_CLIPSIBLINGS

You can remove the clip sibblings style.  My window has a caption although I didn not specify the WS_CAPTION style.  It does have a close box but does not have minimize and maximize buttons.  (these can be added with the WS_MINIMUZE and WS_MAXIMIZEstyles)  It has no system menu.  
0
 

Author Comment

by:okuru
ID: 1416538
With this I get a window with title bar no close button, if I add sysmenu I get an icon/menu ???


#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow) {

static char szAppName[] = "Test";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;

wndclass.cbSize            = sizeof(wndclass);
wndclass.style            = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc      = WndProc;
wndclass.cbClsExtra      = 0;
wndclass.cbWndExtra      = 0;
wndclass.hInstance      = hInstance;
wndclass.hIcon            = NULL;
wndclass.hCursor      = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground      = (HBRUSH) GetStockObject (LTGRAY_BRUSH);
wndclass.lpszMenuName      = NULL;
wndclass.lpszClassName      = szAppName;
wndclass.hIconSm      = NULL;

RegisterClassEx(&wndclass);

hwnd = CreateWindow(szAppName,
" Test",
WS_POPUPWINDOW |
WS_DLGFRAME |
WS_THICKFRAME |
WS_OVERLAPPED |
WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
150,
50,
NULL,
NULL,
hInstance,
NULL);

ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);

while (GetMessage(&msg, NULL, 0, 0)) {
      TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
      HDC                  hdc;
      PAINTSTRUCT      ps;
      switch (iMsg) {
            case WM_CREATE:
                  return 0;

        case WM_PAINT :
                  hdc = BeginPaint(hwnd, &ps);
                  EndPaint (hwnd, &ps);
            return 0;

            case WM_DESTROY:
                  PostQuitMessage (0);
            return 0 ;
      }
      return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

0
 
LVL 22

Expert Comment

by:nietod
ID: 1416539
I have a close button on mine.  However, I use CreateWindowEx() and specify two extended styles.  WS_EX_DLGMODALFRAME and WS_EX_WINDOWEDGE.

You might try that or you might try adding the WS_CAPTION style.  (Which probably should have been there, but actually isn't in my code.)
0
 

Author Comment

by:okuru
ID: 1416540
Thanks
CreateWindowEx() does it, CreateWindow() does not.
 
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Application vs Workbook.applicaiton 3 51
Issue testing the Class Library 4 68
windbg taking it's time 32 108
Question to Pivot table 1 75
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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