Win32 Question: CreateWindow Function

alisajid

Member
Jun 29, 2001
194
0
0
I'm try to add a child window to a generic top level window in my application. I've 'written' the window class of the top level window. The window I'm trying to create is of window class type "ConsoleWindowClass".

I'm using the call below to create the child console:

hConsole = CreateWindow(_T("ConsoleWindowClass"), _T("Console"), WS_CHILD, 5, 5, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, NULL, hInst, NULL);

I thought this would do it, but what I get is a console class window not embedded in my wrapper window. That is, the console window is another top level overlapped window.

Being a noob at this stuff sucks. As such, any help would be appreciated.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
I have used the brute force method before. Someone else may jump in with a clean method.

I would create the window without any title bar and position it within the parent window. When the parent window received messages relating to movement, I would then move the child window accordingly.
 

alisajid

Member
Jun 29, 2001
194
0
0
I thought a window would be created without a title bar and min/max boxes by specifying it as WS_CHILD and then providing a HWND for the parent to CreateWindow? I guess I'm missing something blatant... so I'll ask: How do you create a window without any title bar?

TIA
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
The Window style allow a window to be created without a Caption.

Look at the dwStyle section in the CreateWindowEx API.
 

alisajid

Member
Jun 29, 2001
194
0
0
That made sense... I played around some more till I realized (correctly?) that "ConsoleWindowClass" is not a system global window class. Previously, I was using AllocConsole() to get a handle to the class, and in reviewing my code I had skipped that.

Basically, now that I have a window that I cannot directly create using CreateWindow, is there any way at run time I can strip away its border, title bar, system menu, and min/max boxes?

I checked MSDN and found many Console IO functions are exported by kernel32.lib / wincon.h. I checked all the exports, but I could not find any particular window class there.
 

rbayer

Member
Dec 22, 2002
69
0
0
Look into GetWindowLong/SetWindowLong. If I remember correctly, you can use these to get/set attributes of a window at runtime. Unfortunately, I don't remember all the details. Something about GWL_STYLE, though.