Windows

Creating Window Basics

Getting to know Windows – Part 7
Volume – Windows User Interface

Introduction
This is part 7 of my series, Getting to know Windows. I assume you have read all the previous tutorials before this one. You should be reading the tutorials in the order given. In this part of the series we look at creating window basics.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

Creating a Window
An application typically creates the main window as its first window before it can go on to create other windows. You create a window using the CreateWindowEx function. Before creating a window, you have to register the class of the window first, and then provide a window procedure for the class; then you can create the window.

A class has the characteristics of a window. Some of these characteristics can be given when creating the window in the CreateWindowEx function. If you do not give the characteristic in the CreateWindowEx function, make sure you give it in the class description (see details later), unless the characteristic is optional.

The CreateWindowEx Function
There is a predefined function called CreateWindowEx, which is used to create a window. Two other functions are normally used with the CreateWindowEx function. The functions are ShowWindow and UpdateWindow. Example code of the use of these functions is:

HINSTANCE hinst;
HWND hwndMain;
 
hwndMain = CreateWindowEx(0, “MainWClass”, “Main Window”, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND) NULL, (HMENU) NULL, hinst, NULL);                 
 
if (!hwndMain)
    return FALSE;
 
ShowWindow(hwndMain, SW_SHOWDEFAULT);
UpdateWindow(hwndMain);

The first thing in the code is the declaration of an identifier that will hold the instance handle of the class. Next you have the declaration of the identifier that will hold the handle of the window created. The CreateWindowEx function returns the handle of the window it has created. This will be held by hwndMain.

The CreateWindowEx function has many arguments. The second argument is the name of the class; it is a string in double quotes. The third argument is the name of the window, which will be displayed in the title bar of the window. It is a string in double quotes and it can have spaces. One of the arguments is the identifier for the class instance handle.

There is an if-statement. This if-statement checks if the window was successfully created. If it was not successfully created, the if-statement returns FALSE to the calling environment (operating system). The condition, (!hwndMain) will result in False if the window was not created (successfully). Note the NOT (!) inside the condition.

When the window is created by the CreateWindowEx function it is not displayed. The ShowWindow predefined function displays the window. It first argument is the handle of the window. We shall talk about its second argument later. As the window is just displayed, it does not have a color. The UpdateWindow predefined function paints the window’s client area. Its argument is the window handle. The uses of the last two functions do not look logical; but that is how things are with Windows.

Destroying a Window
Closing a window does not destroy the window. Destroying a window means the window has to save its system data and then free the memory that the window was using and free any resources that were allocated to the window, so that other applications can use the resources (and memory). We shall see more about this, as we go along.
 
The Windows API Volumes
Those of us who write (publish) for the Internet, write for money. We get our earnings through the advertisements you see on our web pages like this one. So please, do click the advertisements on my pages to know what my partners are advertising. In that way they pay me on your behalf, for advertising their products. If you do not click the advertisements of the Internet articles, they will not pay us. I know you are getting the stuff free, but do click the advertisements to enable us continue to write. Thanks.

We can stop here. We continue in the next part of the series.

Chrys

To arrive at any of the parts of this series, just type the corresponding title below in the Search Box of this page and click Search (use menu if available):

Getting to know Windows
What is a Microsoft Window?
Basics of Window Classes
Window Procedure Basics
Message Basics for Window Class Procedure
Basics of Message Handling in Windows
Creating Window Basics
Basic Coding of Window Class Procedure
Your first Window

Written by Chrys

Keyboard Shortcuts For Windows 7

Windows + + (in addition key)
Windows + – (minus important)

Pressing the Windows and plus or minus keys activates the Magnifier, which lets you zoom in on the total desktop or open a rectangular magnifying lens to zoom in and out of elements of your screen. You can customize the Magnifier alternatives to comply with your mouse pointer or keyboard cursor. Preserve in mind that so far, the Magnifier only operates when Aero desktop is enabled.

Windows + Up
Windows + Down

If a window is not maximized, pressing Windows + Up will fill it to your screen. Windows + Down will decrease that active window. Regrettably, pressing Windows + Up again even though a window is minimized won’t return it to its previous state.

Windows + Shift + Up

Similar to the shortcut over, hitting these a few keys while a window is energetic will stretch it vertically to the highest desktop peak. The width of the window will however remain the same. Pressing Windows + Down will restore it to its earlier measurement.

Windows + Left
Windows + Appropriate

1 of the new attributes of Windows 7 is the capacity to immediately make a window fill up 50 % of your display by dragging to the left or right. This pair of shortcuts performs the same function without your mouse. Once a window is fixed to 1 facet of the display, you can repeat the shortcut to flip it to the other facet. This is valuable if you are extending a desktop across several monitors, which stops you from executing this trick with a mouse.

Windows + House

This shortcut performs a similar function to hovering about a window’s peek menu thumbnail in the Taskbar. The energetic window will stay on your desktop although every other open software is minimized. Pressing this shortcut yet again will restore all the other windows.

Windows + E

Automatically opens up a new Explorer window to display your Libraries folder.

Windows + P

Deal with your many-keep track of more effectively with this useful shortcut. Windows + P opens up a small overlay that lets you configure a second show or projector. You can change from a single check to dual-display in possibly mirror or lengthen desktop mode.

Windows + Shift + Left
Windows + Shift + Correct

If you are employing two or a lot more shows (and who is not, these days?), memorize this shortcut to quickly move a window from one particular display screen to the other. The window retains its measurement and relative place on the new screen, which his valuable when working with several documents. Utilize that true estate!

Windows + [Number]

Applications (and new circumstances) pinned to your Taskbar can be launched by hitting Windows and the range corresponding to its placement on the Taskbar. Windows + one, for illustration, launches the very first software, while Windows + four will kick off the fourth. We understand that this is truly one particular important-press far more than just clicking the icon with your mouse, but it saves your hand the problems of leaving the ease and comfort of the keyboard.

Windows + T

Like Alt + Tab (nevertheless our all time preferred Windows certain shortcut), Windows + T cycles via your open programs via the Taskbar’s peek menu.

Windows + Area

This combo performs the identical function as shifting your mouse to the bottom right of the Taskbar. It can make each lively window transparent so you can look at your desktop. The windows only continue being transparent as prolonged as you’re keeping down the Windows important.

Ctrl + Shift + Click on

Maintain down Ctrl and Shift although launching an software from the Taskbar or start menu to kick off it with complete administrative rights.

Ctrl + Click on

Maintain down Ctrl while repeatedly clicking a software icon in the Taskbar will toggle among the cases of that software, like numerous Firefox windows (though not browser tabs).

Composed by Pungky DC