PhilC
asked on
Act like CreateDialog()
Not using MFC.
I would like to know what style(s) to register a window class with, and what style(s) to create a window with so that it will act like a window created with CreateDialog().
That is:
1) Will not create an item in the taskbar.
2) Will remain on top of my application.
3) Will allow focus to be transferred to my application.
Any help would be appreciated.
I would like to know what style(s) to register a window class with, and what style(s) to create a window with so that it will act like a window created with CreateDialog().
That is:
1) Will not create an item in the taskbar.
2) Will remain on top of my application.
3) Will allow focus to be transferred to my application.
Any help would be appreciated.
You don't want the WS_EX_TOOLWINDOW style. That will produce a smaller caption.
I use
WS_POPUPWINDOW | WS_DLGFRAME | WS_THICKFRAME | WS_OVERLAPPED | WS_CLIPSIBLINGS,
and for extended styles.
WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
You can always use Spy++ to see what a :"real" dialog uses.
I use
WS_POPUPWINDOW | WS_DLGFRAME | WS_THICKFRAME | WS_OVERLAPPED | WS_CLIPSIBLINGS,
and for extended styles.
WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
You can always use Spy++ to see what a :"real" dialog uses.
Yeh, nietod is right. Since the dialog box is not your main application window, it won't show up on the taskbar even without WS_EX_TOOLWINDOW. That's only if you want your main window not to show up on the taskbar.
ASKER
This is how I'm registering my window class:
myclass.cbSize = sizeof(menwndclass);
myclass.style = CS_HREDRAW | CS_VREDRAW;
myclass.lpfnWndProc = MyProc;
myclass.cbClsExtra =0;
myclass.cbWndExtra = 0;
myclass.hInstance = hInstance;
myclass.hIcon = LoadIcon(hInstance,MAKEINT RESOURCE(A PP_ICON));
myclass.hCursor = NULL;
myclass.hbrBackground = (HBRUSH)GetStockObject(LTG RAY_BRUSH) ;
myclass.lpszMenuName = NULL;
myclass.lpszClassName = "My Class";
myclass.hIconSm = LoadIcon(hInstance,MAKEINT RESOURCE(A PP_ICON));
RegisterClassEx(&myclass);
This is how I am creating the window:
MyWindow = CreateWindowEx(WS_EX_DLGMO DALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT,"My Class","MY Title",
WS_POPUPWINDOW | WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CLIPSIBLINGS | WS_VSCROLL | WS_DLGFRAME | DS_MODALFRAME,
0,0,0,0,NULL,NULL,(HINSTAN CE)GetWind owLong(Mai nWnd,GWL_H INSTANCE), NULL);
myclass.cbSize = sizeof(menwndclass);
myclass.style = CS_HREDRAW | CS_VREDRAW;
myclass.lpfnWndProc = MyProc;
myclass.cbClsExtra =0;
myclass.cbWndExtra = 0;
myclass.hInstance = hInstance;
myclass.hIcon = LoadIcon(hInstance,MAKEINT
myclass.hCursor = NULL;
myclass.hbrBackground = (HBRUSH)GetStockObject(LTG
myclass.lpszMenuName = NULL;
myclass.lpszClassName = "My Class";
myclass.hIconSm = LoadIcon(hInstance,MAKEINT
RegisterClassEx(&myclass);
This is how I am creating the window:
MyWindow = CreateWindowEx(WS_EX_DLGMO
WS_POPUPWINDOW | WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CLIPSIBLINGS | WS_VSCROLL | WS_DLGFRAME | DS_MODALFRAME,
0,0,0,0,NULL,NULL,(HINSTAN
ASKER
I still get item in task bar, and can switch back and forth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
MyWindow = CreateWindowEx(WS_EX_DLGMO DALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT,"My Class","MY Title",
WS_POPUPWINDOW | WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CLIPSIBLINGS | WS_VSCROLL | WS_DLGFRAME | DS_MODALFRAME,
0,0,0,0,
/** parent window goes here **/NULL
,NULL,(HINSTANCE)GetWindow Long(MainW nd,GWL_HIN STANCE),NU LL);
WS_POPUPWINDOW | WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CLIPSIBLINGS | WS_VSCROLL | WS_DLGFRAME | DS_MODALFRAME,
0,0,0,0,
/** parent window goes here **/NULL
,NULL,(HINSTANCE)GetWindow
ASKER
That did the trick. thanks
2) WS_POPUP (don't forget the styles for title bar, system menu, minimize/maximize, ....)
Look at the property dialog box for a dialog box resource in MSVC's resource editor. And take a look at help for CreateWindow() and CreateWindowEx() API's.