Click to See Complete Forum and Search --> : Windows without title bar


Gyannea
December 31st, 2002, 06:04 PM
Can anyone tell me how to modify

hbutton = CreateWindow( /* Function returns the handle to the window */
// WS_EX_OVERLAPPEDWINDOW, /* Extended style options */
"BUTTON", /* String with the name of the window class */
"F2", /* title of window */
BS_PUSHBUTTON ||
BS_VCENTER ||
BS_CENTER ||
WS_DLGFRAME ||
BS_GROUPBOX, /* window style is normal */
CW_USEDEFAULT, /* x-coordinate of upper left corner - let windows decide */
CW_USEDEFAULT, /* y-coordinate of upper left corner - let windows decide */
CW_USEDEFAULT, /* width - let windows decide */
CW_USEDEFAULT, /* height - let windows decide */
hDSC.hwnd, /* No parent window (this window was created from the desktop) */
NULL, /* Handle to the main menu */
hThisInst, /* handle of the creator of this window (desktop or this instance) */
NULL); /* No additional arguements */

such that I get no title bar!

Thanks!!!

mdmd
January 1st, 2003, 12:59 AM
Not sure at all what kind of window you are trying to create.
BS_BUTTON or BS_GROUPBOX ?? Being a button I'm sure you wan't it to be a child ??
Also note that it should be ( WS_VISIBLE | WS_CHILD ) not ( WS_VISIBLE || WS_CHILD ). Here is a big fat ol' F2 button that is the child of a window this->m_hWnd.

Donno what you want so if this doesn't help you on your way then lemme know what you are trying to do.

HWND hbutton = CreateWindow( /* Function returns the handle to the window */
// WS_EX_OVERLAPPEDWINDOW, /* Extended style options */
"BUTTON", /* String with the name of the window class */
"F2", /* title of window */
WS_VISIBLE |
WS_CHILD |
BS_PUSHBUTTON |
BS_VCENTER |
BS_CENTER |
WS_DLGFRAME //|
,//BS_GROUPBOX, /* window style is normal */
40, /* x-coordinate of upper left corner - let windows decide */
40, /* y-coordinate of upper left corner - let windows decide */
100, /* width - let windows decide */
100, /* height - let windows decide */
m_hWnd, /* No parent window (this window was created from the desktop) */
NULL, /* Handle to the main menu */
AfxGetInstanceHandle( ), /* handle of the creator of this window (desktop or this instance) */
NULL); /* No additional arguements */

Gyannea
January 1st, 2003, 09:45 AM
Thanks for the help. Adding the 'WS_CHILD' parameter removed the title bar over the box. And removing the second bar in my 'OR' operator may explain why changing the options didn't do anything. I botch the 'logical' versus 'bitwise' operations too many times and it's not something a compiler can catch!

It seems that the WS_CHILD parameter is the only way I can create a window that DOESN'T have that title bar.

Would you know how to find the thickness of the window frame?

I would like to create a window which surrounds a radio scanner. The size of the window will depend upon the number of channels. Of course, that is the client area. When using the CreateWindow() API function, the coordinates are for the entire window, so I need to take that into consideration. Depending upon the number of channels, I can compute the size of the client area needed. But then I need to add something since the windows have borders. Got any hints how one gets at that information?

THanks for any help and Happy New Year.

mdmd
January 1st, 2003, 12:38 PM
Sure you can.

Just use the style here. You can use different ones, check out the styles available for CreateWindow to change the border style if you like.

hWnd = CreateWindow(szWindowClass, 0, WS_POPUP | WS_BORDER , 10, 10, 500, 500, NULL, NULL, hInstance, NULL);
This is a top level window with no caption, a small border and a menu. I forget how to move the window around with the mouse ( to mimick moving the window by the caption ) but if I remember I'll post it if you need. Don't do this and the window can't be moved around.
Here you also specify the initial size and position of the window. You can make your adjustments here if you know ahead of time the number of channels.

Or you can resize it later. SetWindowPos() and MoveWindow() can do this.

To calculate the size of the border(and other things ) for calculating the new window size check out GetSystemMetrics().

Gyannea
January 2nd, 2003, 09:32 AM
Thanks mdmd,

I think my biggest blunder in not being able to get things to works was my stupid use of the logical OR "||" operator instead of the bitwise operator. I was so concerned about my misuse and poor understanding of the WIndows black box API functions that I was looking there for goofs!

Now to get the sizing correct! I get the feeling that there is some function(s) that will do almost anything one could possibly want...you just have to find it.

Got any hints on color selection? I tried to color my button by using "GetClassInfoEx()" and setting the class name to BUTTON1 and changing the background brush, registering the window and Creating it. But I didn't change the color. If I tried to change the color of the BUTTON class, I got an error. The system obviously didn't want me to do it!

I also was trying to see if I could place a bitmap or icon onto the button face (without using the Toolbar approach) but I couldn't really see how to do that either unless I just 'bitblt()' the bitmap onto the button after it is created. I suppose I would then have to 'bitblt()' the button with its bitmap into the virtual window for repaints. And I bet the button push will look ugly since the icon on top of it will not follow the push. It will probably get deleted!

THe Dialog box approach seemed better but I couldn't find out how to connect a button to an icon or a bitmap (even though the BS_ICON option exists). So there must be a correct set of procedures to do this!

I need a real good book which details all these APIs and options and RC file options! Got any suggestions?

From a snowy NH, Gyannea

mdmd
January 2nd, 2003, 10:55 AM
CodeGuru articles are full of stuff you could look at,
http://www.codeguru.com/buttonctrl/index.shtml

Colored buttons ? Here's a nice article http://www.codeguru.com/buttonctrl/color_button.shtml

Most of the stuff is MFC. But from what you are asking it looks like you want just the api ? If you are then you will need to make changes. A good source for info is the MSDN do a search for
WM_CTLCOLORBTN
or
Control-Color Messages
This should give you plenty of docs to look at regarding coloring of controls using just the api.

As for sizing.
GetWindowRect() will give you the area of a window.
GetSystemMetrics() will give you sizes like border, just check out the meaning of the constants you provide.
SetWindowPos() or MoveWindow() will resize the window.

That should be a good start I think ? If you need help, just let me know it you are able to use MFC or not, kinda makes a big difference.

mdmd
January 2nd, 2003, 11:00 AM
Oh, and about the books.
My choice for WIN32 programming book is
"Win32 programming" by Grent Rector and Joseph Newcomer
My choice for MFC would be
"Programming MFC" by Jeff Prosise
although I heard the Professional VC++ book from Wrox press is the best. Donno.
There are also online tutorials too, just do a google search; you'll hit someones home page of WIN32 programming things

tobeyu
January 2nd, 2003, 02:16 PM
don't forget the "Bible" of Win32 programming...

Programming Windows by Charles Petzold

Gyannea
January 3rd, 2003, 08:40 AM
Mdmd,

My (WATCOM) compiler doesn't support the MFC library. I might eventually buy one that does but my understanding is that MFC buries a lot of functionality (WIndows already has an incredible amount of black boxes) and that one will get a better understanding of how things work by not using MFC. I am also concerned that the real time nature of this program makes the application, as a whole, Windows unfriendly, and that I am going to have to 'tweak' a lot of the standard routines to make things work.

I have already written a fully function version of this program in extended DOS, but I used my own menuing software and graphics packages. With the direct hardware and timing control I needed, it was getting very difficult to run under Windows. Funny thing is that it was NOT the timing/serial port hardware accesses that finally killed things, but the inability to run graphics!

I have to admit, Windows makes programming the user interface 500 times easier and a lot more flexible (try programming the details of a nice graphical inputing of a list of numbers...aarrggg!!!). The only cost is finding which function to call and what parameters to give them, but it seems that no matter what you want to do, there is some way to do it! Whereas I spent a more than a decade developing my menuing/graphics software, I have only been on this about a month and am almost as far. Color control is difficult though. I never liked the approach of setting a color via one function and then drawing with another. I tended to pass the color information as one of the parameters of the drawing functions. I think XWINDOWS uses that approach, but I am not sure.

By the way, I was looking at the colored button class articles and it looks like the action of the class is to essentially draw the button yourself! All the lines of the bevel and everything. Looks quite familiar... It seems too bad that one cannot make use of code already available in the operating system for something so trivial as a color change (without changing the system colors which will effect every other application). It seems bizzare that one can't change the button color by copying the button winclass structure, giving it a new name, change the background color, registering it, and creating it! There is obviously more than meets the eye in all this!

Another foot of snow on the way.

Gyannea

mdmd
January 3rd, 2003, 11:58 AM
Oh OK. You have the MSDN or at least the online MSDN ?
For the button color and do a search for WM_CTLCOLOR.

I think the only MFC thing I mentioned was Prosise's book, everything else should be available on you watcom compiler. Are they still around ?

Anyhoo, good luck.

Gyannea
January 3rd, 2003, 12:26 PM
Yes, the WATCOM compiler is still around and it has now been opened and is free (I have the last commericial version). There is an OPen Watcom project and several newsgroups which represent it. Its a good compiler though its hard to imagine how it can compete with Microsoft for Windows development...the latter have a distinct inside advantage.