Link to home
Start Free TrialLog in
Avatar of PhilC
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.
Avatar of tflai
tflai

1)  extended style WS_EX_TOOLWINDOW
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.

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.
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.
Avatar of PhilC

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,MAKEINTRESOURCE(APP_ICON));
myclass.hCursor = NULL;
myclass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
myclass.lpszMenuName =  NULL;
myclass.lpszClassName = "My Class";
myclass.hIconSm = LoadIcon(hInstance,MAKEINTRESOURCE(APP_ICON));
RegisterClassEx(&myclass);

This is how I am creating the window:

MyWindow = CreateWindowEx(WS_EX_DLGMODALFRAME | 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,(HINSTANCE)GetWindowLong(MainWnd,GWL_HINSTANCE),NULL);


Avatar of PhilC

ASKER

I still get item in task bar, and can switch back and forth
ASKER CERTIFIED SOLUTION
Avatar of marvinm
marvinm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
MyWindow = CreateWindowEx(WS_EX_DLGMODALFRAME | 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)GetWindowLong(MainWnd,GWL_HINSTANCE),NULL);

Avatar of PhilC

ASKER

That did the trick. thanks