Windows-Programmierung [] (Windows-Programmierung), Anleitung, Seite 722116
https://www.purl.org/stefan_ram/pub/windows-programmierung (Permalink) ist die kanonische URI dieser Seite.
Stefan Ram
C++-Kurs

Windows -Programmierung

Die Windows -Systeme ab Windows 95  werden auch als „Win32 “-Systeme bezeichnet.

Für diese Lektion werden Kenntnisse über Zeiger und Verbunde vorausgesetzt.

Die Funktion »WinMain«

Ein Windows -Programm definiert die Funktion »WinMain« als Hauptfunktion.

Die Datei »windows.h« definiert verschiedene Typnamen, die ganz in Großbuchstaben geschrieben werden.

WinMain1.c

#include <windows.h>

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )
{ return 0; }

windows.h Eine Include-Quelle mit den am häufigsten für die Windows -Programmierung benötigten Definitionen und Deklarationen.

INT integer —Ein ganzzahliger Wert mit umgebungsspezifischer Breite (Bitanzahl).

WINAPI Windows application programmer's interface function —Eine Funktion, die den Konventionen von Windows  entsprechend übersetzt werden soll.

HINSTANCE handle of instance —Eine Kennung (ein Identifikationswert, Kennzeichen, handle ). Kennungstypen beginnen in der Regel mit dem Buchstaben »H« für “handle ”. Ein Anwendungsprogramm kann in der Regel aus einer Kennung zunächst keine weiteren Informationen direkt entnehmen, es kann diese Kennung aber an andere Programmteile weiterreichen, um dadurch bestimmte Objekte anzugeben. Eine »HINSTANCE« ist eine Prozeßkennung (wörtlicher: „Kennung eines Exemplars eines Programms“).

LPSTR long pointer to generic string —Ein Zeiger auf einen Text, dessen genaue Gattung (ASCII  oder Unicode ) zunächst nicht näher bestimmt ist und von der Umgebung abhängt.

program_instance Eine Kennung des laufenden Prozesses (also eines „Exemplars“ eines Programms). Der Prozeß kann sich damit identifizieren.

previous_instance Eine Kennung des „vorherigen“ Prozesses oder 0; ist bei Win32 -Anwendungen stets 0 und kann daher ignoriert werden.

command_line Eine nullterminierte Kette mit der Kommandozeile des Prozesses. (Das Kommando, mit dem der Prozeß erzeugt wurde.)

show_state Eine Kennzahl, die angibt, wie ein eventuelles Hauptfenster dieses Prozesses dargestellt werden soll. Einige mögliche Konstanten sind beispielsweise »SW_HIDE«, »SW_MINIMIZE«, »SW_SHOWNORMAL« und »SW_SHOWMAXIMIZED«. Der Prozeß sollte sein Hauptfenster danach einstellen.

Ergebnis Eine Hauptfunktion, die wie diese Hauptfunktion, endet, ohne eine Nachrichtenschleife aufzubauen, sollte den Wert 0 zurückgeben.

Die Funktion »MessageBox«

Ein Mitteilungsfenster wird mit der Windows -Funktion »MessageBox« erzeugt.

#include <windows.h>
#include <tchar.h>

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )

{ MessageBox( GetDesktopWindow(), _T( "text" ), _T( "title" ), MB_OK ); }

.-----------------------.
| title ____________ [X]|
| |
| text |
| |
| .-----------------. |
| | OK | |
| '-----------------' |
| |
'-----------------------'

tchar.h Eine Include-Quelle mit Definitionen und Deklarationen zu einem Texttype, der je nach Umgebung sowohl auf ASCII  (klassisch) als auch auf UNICODE  (neu) basieren kann.

MessageBox
int MessageBox
( HWND owner_window,
LPCTSTR message,
LPCTSTR title,
UINT style );

HWND handle of window —Eine Kennung eines Fensters.

LPCTSTR long pointer to a constant text string —Ein Zeiger auf einen konstanten Text, dessen genaue Gattung (ASCII  oder Unicode ) zunächst nicht näher bestimmt ist und von der Umgebung abhängt.

UINT integer —Ein „vorzeichenloser“ (d.h., nicht-negativer) ganzzahliger Wert mit umgebungsspezifischer Breite (Bitanzahl).

owner_window Die Kennung des Fensters zu dem dieser Mitteilungskasten gehört. Kann auch 0 sein.

message Die anzuzeigende Mitteilung.

title Der anzuzeigende Titel. (Falls er 0 ist, so wird ein Titel für eine Fehlermeldung angezeigt.)

style Eine kodierte Angabe zur Darstellung des Kastens.

MB_OK Eine OK-Tastfläche ist im Mitteilungskasten enthalten. (Es gibt noch andere Codes.)

_T text —Ein Textliteral, dessen genaue Gattung (ASCII  oder Unicode ) zunächst nicht näher bestimmt ist und von der Umgebung abhängt. Bei Bedarf wird das Textliteral hinter »_T« in den richtigen Typ gewandelt.

GetDesktopWindow() Ergibt die Kennung des Arbeitsplatz-Fensters. Dieses ist das Hauptfenster von Windows, das normalerweise den gesamten Bildschirm ausfüllt und in dem alle andere Fenster enthalten sind.

Oberflächen

Die Klassen von Fenstern in Windows sind nicht mit den Klassen einer zur Programmierung von Windows verwendeten Programmiersprache wie C++  gleichzusetzen.

Ein Windowsprozeß kann dem Benutzer verschiedene Oberflächen anbieten. Folgende Oberflächen sind relative weit verbreitet:

Registrieren einer Fensterklasse

Hier soll nun gezeigt werden wie eine spezielle Fensterklasse „registriert“ wird.

#include <windows.h>
#include <tchar.h>

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )

{ window_class->style = CS_HREDRAW | CS_VREDRAW;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = instance;
window_class->hIcon = LoadIcon( NULL, IDI_APPLICATION );
window_class->hCursor = LoadCursor( NULL, IDC_ARROW );
window_class->hbrBackground =( HBRUSH )GetStockObject( WHITE_BRUSH );
window_class->lpszMenuName = NULL;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )

{ TCHAR const window_class_name[] = _T( "Drawing 2006-05-26T21:14:12+02:00" );
WNDCLASS wndclass;
init_window_class( &wndclass, window_class_name, instance );
RegisterClass( &wndclass );
return 0; }

Anzeigen eines Fensters

#include <windows.h>
#include <tchar.h>

LRESULT CALLBACK controller
( HWND const window,
UINT const messagetype,
WPARAM const parameter_w,
LPARAM const parameter_l )

{ if( messagetype == WM_DESTROY )PostQuitMessage( 0 );
else DefWindowProc( window, messagetype, parameter_w, parameter_l ); }

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )

{ window_class->style = 0;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = program_instance;
window_class->hIcon = 0;
window_class->hCursor = 0;
window_class->hbrBackground = 0;
window_class->lpszMenuName = 0;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )

{ INT result = 0;
TCHAR window_class_name[] = _T( "Drawing 2006-05-29T19:05:50+02:00" );
WNDCLASS wndclass;
init_window_class( &wndclass, window_class_name, program_instance );
if( RegisterClass( &wndclass ))
{ HWND const window = CreateWindow
( window_class_name, _T( "Drawing Example" ), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 580, 400, NULL, NULL,
program_instance, NULL );
ShowWindow( window, show_state );
UpdateWindow( window );
{ MSG message; message.wParam = 0;
while( GetMessage( &message, NULL, 0, 0 ))
{ TranslateMessage( &message ); DispatchMessage( &message ); }
result = ( INT )message.wParam; }}
return result; }

Zeichnen im Fenster

#include <windows.h>
#include <tchar.h>

LRESULT CALLBACK controller
( HWND const window,
UINT const messagetype,
WPARAM const parameter_w,
LPARAM const parameter_l )

{ static int MouseClickCount;
switch( messagetype )
{ case WM_PAINT:
{ PAINTSTRUCT paint_struct;
HDC device = BeginPaint( window, &paint_struct );
{ HPEN const new_pen = CreatePen( PS_SOLID, 1, RGB( 0, 180, 180 ));
HPEN const old_pen =( HPEN )SelectObject( device, new_pen );
MoveToEx( device, 100, 10, 0 );
LineTo( device, 100, 110 );
LineTo( device, 300, 110 );
LineTo( device, 300, 10 );
LineTo( device, 100, 10 );
EndPaint( window, &paint_struct ); } break; }
case WM_DESTROY: { PostQuitMessage( 0 ); break; }
default:
{ DefWindowProc( window, messagetype, parameter_w, parameter_l );
break; }}}

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )

{ window_class->style = CS_HREDRAW | CS_VREDRAW;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = program_instance;
window_class->hIcon = LoadIcon( NULL, IDI_APPLICATION );
window_class->hCursor = LoadCursor( NULL, IDC_ARROW );
window_class->hbrBackground =( HBRUSH )GetStockObject( WHITE_BRUSH );
window_class->lpszMenuName = 0;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )

{ INT result = 0;
TCHAR window_class_name[] = _T( "Drawing 2006-05-29T21:03:49+02:00" );
WNDCLASS wndclass;
init_window_class( &wndclass, window_class_name, program_instance );
if( RegisterClass( &wndclass ))
{ HWND const window = CreateWindow
( window_class_name, _T( "Drawing Example" ), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 580, 400, NULL, NULL,
program_instance, NULL );
ShowWindow( window, show_state );
UpdateWindow( window );
{ MSG message; message.wParam = 0;
while( GetMessage( &message, NULL, 0, 0 ))
{ TranslateMessage( &message ); DispatchMessage( &message ); }
result = ( INT )message.wParam; }}
return result; }

Verläufe

threads.c

#include <windows.h>
#include <tchar.h>

LONG WINAPI common( void const * const param, const int n )
{
for( int i = 0; i < 1000000; ++i )
{ char str[ 255 ]; wsprintf( str, "%d %06d ", n, i );
HDC const hdc = GetDC(( HWND )param);
TextOut( hdc, 1, 20 * n, str, lstrlen( str ));
ReleaseDC(( HWND )param, hdc ); } return 0; }

LONG WINAPI code( void const * const param ){ return common( param, 0 ); }
LONG WINAPI code1( void const * const param ){ return common( param, 1 ); }

LRESULT CALLBACK controller
( HWND const window, UINT const messagetype,
WPARAM const parameter_w, LPARAM const parameter_l )
{ static int MouseClickCount;
switch( messagetype )
{ case WM_CREATE: { LPDWORD thread_id;
CreateThread( NULL, 0,
( LPTHREAD_START_ROUTINE )code, window, 0,( LPDWORD )&thread_id );
CreateThread( NULL, 0,
( LPTHREAD_START_ROUTINE )code1, window, 0,( LPDWORD )&thread_id );
break; }
case WM_DESTROY: { PostQuitMessage( 0 ); break; }
default: { DefWindowProc( window, messagetype, parameter_w, parameter_l );
break; }}}

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )
{ window_class->style = CS_HREDRAW | CS_VREDRAW;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = program_instance;
window_class->hIcon = LoadIcon( NULL, IDI_APPLICATION );
window_class->hCursor = LoadCursor( NULL, IDC_ARROW );
window_class->hbrBackground =( HBRUSH )GetStockObject( WHITE_BRUSH );
window_class->lpszMenuName = 0;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )
{ INT result = 0;
TCHAR window_class_name[] = _T( "Drawing 2006-05-31T06:00:05+02:00" );
WNDCLASS wndclass;
init_window_class( &wndclass, window_class_name, program_instance );
if( RegisterClass( &wndclass ))
{ HWND const window = CreateWindow
( window_class_name, _T( "Drawing Example" ), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 580, 400, NULL, NULL,
program_instance, NULL );
ShowWindow( window, show_state );
UpdateWindow( window );
{ MSG message; message.wParam = 0;
while( GetMessage( &message, NULL, 0, 0 ))
{ TranslateMessage( &message ); DispatchMessage( &message ); }
result = ( INT )message.wParam; }}
return result; }

Animationen

#include <windows.h>
#include <tchar.h>

int nWidth = 580; int nHeight = 400;

LRESULT CALLBACK controller
( HWND const window,
UINT const messagetype,
WPARAM const parameter_w,
LPARAM const parameter_l )
{ static int MouseClickCount;
switch( messagetype )
{ case WM_ERASEBKGND: return TRUE;
case WM_CREATE:
SetTimer( window, 0, 1000, 0 );
break;
case WM_TIMER:
InvalidateRect( window, 0, TRUE );
break;
case WM_PAINT:
{ PAINTSTRUCT paint_struct;
HDC device = BeginPaint( window, &paint_struct );
{ HDC memDC = CreateCompatibleDC( device );
HBITMAP hBmp = CreateCompatibleBitmap( device, nWidth, nHeight );
HBITMAP hOldBitmap =( HBITMAP )::SelectObject( memDC, hBmp );
RECT rc; rc.left = rc.top = 0; rc.right = nWidth;
rc.bottom = nHeight;
FillRect( memDC, &rc, ( HBRUSH )( COLOR_WINDOW+1 ));
HPEN const new_pen = CreatePen( PS_SOLID, 1, RGB( 0, 180, 180 ));
HPEN const old_pen =( HPEN )SelectObject( device, new_pen );
MoveToEx( memDC, 100, 10, 0 );
LineTo( memDC, 100, 110 + GetTickCount() / 100 % 100 );
LineTo( memDC, 300, 110 );
LineTo( memDC, 300, 10 );
LineTo( memDC, 100, 10 );
BitBlt(device, 0, 0, nWidth, nHeight, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, hOldBitmap);
DeleteObject(hBmp);
DeleteDC(memDC);
EndPaint( window, &paint_struct ); } break; }
case WM_DESTROY: { PostQuitMessage( 0 ); break; }
default:
{ DefWindowProc( window, messagetype, parameter_w, parameter_l );
break; }}}

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )
{ window_class->style = CS_HREDRAW | CS_VREDRAW;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = program_instance;
window_class->hIcon = LoadIcon( NULL, IDI_APPLICATION );
window_class->hCursor = LoadCursor( NULL, IDC_ARROW );
window_class->hbrBackground =( HBRUSH )GetStockObject( WHITE_BRUSH );
window_class->lpszMenuName = 0;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )
{ INT result = 0;
TCHAR window_class_name[] = _T( "2006-05-31T06:22:23+02:00" );
WNDCLASS wndclass;
init_window_class( &wndclass, window_class_name, program_instance );
if( RegisterClass( &wndclass ))
{ HWND const window = CreateWindow
( window_class_name, _T( "Drawing Example" ), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, nWidth, nHeight, NULL, NULL,
program_instance, NULL );
ShowWindow( window, show_state );
UpdateWindow( window );
{ MSG message; message.wParam = 0;
while( GetMessage( &message, NULL, 0, 0 ))
{ TranslateMessage( &message ); DispatchMessage( &message ); }
result = ( INT )message.wParam; }}
return result; }

Ein sich drehender Würfel

2006-05-31T21:15:00+02:00 konnte das folgende Programm mit einem sich drehenden Würfel während des Kurses Pa5339-F  nicht mehr fertiggestellt werden. Es folgt nun eine funktionsfähige Version.

Im Kurs waren die unten mit »//« markierten Zeilen fehlerhaft. Außerdem gab es noch einen Flüchtigkeitsfehler bei der Berechnung der Drehung.

In der folgenden Version dreht sich der Würfel um mehrere Achsen, aber es können hier leider nicht alle Details des Programms erklärt werden.

Compiler-Optionen
Ohne -std und ohne -pedantic-Optionen und mit »-fpermissive« (Option für C++, bedeutet: lenient)
Option »-lgdi32« (bezieht sich auf: »x86_64-w64-mingw32\lib\libgdi32.a« oder »x86_64-w64-mingw32\lib32\libgdi32.a«)
Quelltext
#include <windows.h>
#include <tchar.h>
#include <cmath>

int nWidth = 580; int nHeight = 400;

double ecke_x[ 8 ];
double ecke_y[ 8 ];
double ecke_z[ 8 ];
double eck_x[ 8 ];
double eck_y[ 8 ];
double eck_z[ 8 ];
double eck1_x[ 8 ];
double eck1_y[ 8 ];
double eck1_z[ 8 ];
int line_a[ 12 ];
int line_e[ 12 ];
long start = 0;

void init()
{ ecke_x[ 0 ]= -0.5; ecke_y[ 0 ]= -0.5; ecke_z[ 0 ]= -0.5;
ecke_x[ 1 ]= -0.5; ecke_y[ 1 ]= -0.5; ecke_z[ 1 ]= +0.5;
ecke_x[ 2 ]= -0.5; ecke_y[ 2 ]= +0.5; ecke_z[ 2 ]= -0.5;
ecke_x[ 3 ]= -0.5; ecke_y[ 3 ]= +0.5; ecke_z[ 3 ]= +0.5;
ecke_x[ 4 ]= +0.5; ecke_y[ 4 ]= -0.5; ecke_z[ 4 ]= -0.5;
ecke_x[ 5 ]= +0.5; ecke_y[ 5 ]= -0.5; ecke_z[ 5 ]= +0.5;
ecke_x[ 6 ]= +0.5; ecke_y[ 6 ]= +0.5; ecke_z[ 6 ]= -0.5;
ecke_x[ 7 ]= +0.5; ecke_y[ 7 ]= +0.5; ecke_z[ 7 ]= +0.5;

line_a[ 0 ]= 0; line_e[ 0 ]= 1;
line_a[ 1 ]= 1; line_e[ 1 ]= 3;//
line_a[ 2 ]= 3; line_e[ 2 ]= 2;//
line_a[ 3 ]= 2; line_e[ 3 ]= 0;

line_a[ 4 ]= 4; line_e[ 4 ]= 5;
line_a[ 5 ]= 5; line_e[ 5 ]= 7;//
line_a[ 6 ]= 7; line_e[ 6 ]= 6;//
line_a[ 7 ]= 6; line_e[ 7 ]= 4;

line_a[ 8 ]= 0; line_e[ 8 ]= 4;
line_a[ 9 ]= 1; line_e[ 9 ]= 5;
line_a[ 10 ]= 2; line_e[ 10 ]= 6;
line_a[ 11 ]= 3; line_e[ 11 ]= 7; }

LRESULT CALLBACK controller
( HWND const window,
UINT const messagetype,
WPARAM const parameter_w,
LPARAM const parameter_l )
{ static int MouseClickCount;
switch( messagetype )
{ case WM_ERASEBKGND: return TRUE;
case WM_CREATE:
SetTimer( window, 0, 3, 0 );
start = GetTickCount();
break;
case WM_TIMER:
{
int a0 = GetTickCount() - start;
a0 = a0 / 12;
a0 = a0 % 360;
double a = a0 / 180. * 3.141592653589793238462643;
for( int i = 0; i < 8; ++i )
{ eck_x[ i ] = ecke_x[ i ]* ::std::cos( a ) - ecke_y[ i ]* ::std::sin( a );
eck_y[ i ] = ecke_x[ i ]* ::std::sin( a ) + ecke_y[ i ]* ::std::cos( a );
eck_z[ i ] = ecke_z[ i ]; }

int b0 = GetTickCount() - start;
b0 = b0 / 11;
b0 = b0 % 360;
double b = b0 / 180. * 3.141592653589793238462643;
for( int i = 0; i < 8; ++i )
{ eck1_x[ i ] = eck_x[ i ];
eck1_y[ i ] = eck_y[ i ]* ::std::cos( b ) - eck_z[ i ]* ::std::sin( b );
eck1_z[ i ] = eck_y[ i ]* ::std::sin( b ) + eck_z[ i ]* ::std::cos( b ); }

int c0 = GetTickCount() - start;
c0 = c0 / 10;
c0 = c0 % 360;
double c = c0 / 180. * 3.141592653589793238462643;
for( int i = 0; i < 8; ++i )
{ eck_x[ i ] = eck1_z[ i ]* ::std::sin( c ) + eck1_x[ i ]* ::std::cos( c );
eck_y[ i ] = eck1_y[ i ];
eck_z[ i ] = eck1_z[ i ]* ::std::cos( c ) - eck1_x[ i ]* ::std::sin( c ); }

for( int i = 0; i < 8; ++i )
{ eck_x[ i ] = 3. * eck_x[ i ]/( 3. - eck_z[ i ]);
eck_y[ i ] = 3. * eck_y[ i ]/( 3. - eck_z[ i ]); }

}

InvalidateRect( window, 0, TRUE );
break;
case WM_PAINT:
{ PAINTSTRUCT paint_struct;
HDC device = BeginPaint( window, &paint_struct );
{ HDC memDC = CreateCompatibleDC( device );
{ HBITMAP hBmp = CreateCompatibleBitmap( device, nWidth, nHeight );
{ HBITMAP hOldBitmap =( HBITMAP )::SelectObject( memDC, hBmp );
{ RECT rc; rc.left = rc.top = 0; rc.right = nWidth;
rc.bottom = nHeight;
FillRect( memDC, &rc, ( HBRUSH )( COLOR_WINDOW+1 ));
HPEN const new_pen = CreatePen( PS_SOLID, 1, RGB( 0, 180, 180 ));
{ HPEN const old_pen =( HPEN )SelectObject( device, new_pen );
{ for( int i = 0; i < 12; ++i )
{ MoveToEx( memDC, ( int )( 200.0 + 100.0 * eck_x[ line_a[ i ]]),
( int )( 200.0 + 100.0 * eck_y[ line_a[ i ]]), 0 );
LineTo( memDC, ( int )( 200.0 + 100.0 * eck_x[ line_e[ i ]]),
( int )( 200.0 + 100.0 * eck_y[ line_e[ i ]]) ); }
BitBlt( device, 0, 0, nWidth, nHeight, memDC, 0, 0, SRCCOPY );
SelectObject( device, old_pen ); }
DeleteObject( new_pen ); }
SelectObject( memDC, hOldBitmap ); }
DeleteObject( hBmp ); }
DeleteDC( memDC ); }
EndPaint( window, &paint_struct ); } break; }
case WM_DESTROY: { PostQuitMessage( 0 ); break; }
default:
{ DefWindowProc( window, messagetype, parameter_w, parameter_l );
break; }}}

void init_window_class
( WNDCLASS * const window_class,
TCHAR const * const window_class_name,
HINSTANCE program_instance )
{ window_class->style = CS_HREDRAW | CS_VREDRAW;
window_class->lpfnWndProc = controller;
window_class->cbClsExtra = 0;
window_class->cbWndExtra = 0;
window_class->hInstance = program_instance;
window_class->hIcon = LoadIcon( NULL, IDI_APPLICATION );
window_class->hCursor = LoadCursor( NULL, IDC_ARROW );
window_class->hbrBackground =( HBRUSH )GetStockObject( WHITE_BRUSH );
window_class->lpszMenuName = 0;
window_class->lpszClassName = window_class_name; }

INT WINAPI WinMain
( HINSTANCE const program_instance,
HINSTANCE const previous_instance,
LPSTR const command_line,
INT const show_state )
{ INT result = 0;
TCHAR window_class_name[] = _T( "2006-05-31T06:22:23+02:00" );
WNDCLASS wndclass;
init();
init_window_class( &wndclass, window_class_name, program_instance );
if( RegisterClass( &wndclass ))
{ HWND const window = CreateWindow
( window_class_name, _T( "Drawing Example" ), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, nWidth, nHeight, NULL, NULL,
program_instance, NULL );
ShowWindow( window, show_state );
UpdateWindow( window );
{ MSG message; message.wParam = 0;
while( GetMessage( &message, NULL, 0, 0 ))
{ TranslateMessage( &message ); DispatchMessage( &message ); }
result = ( INT )message.wParam; }}
return result; }

Seiteninformationen und Impressum   |   Mitteilungsformular  |   "ram@zedat.fu-berlin.de" (ohne die Anführungszeichen) ist die Netzpostadresse von Stefan Ram.   |   Eine Verbindung zur Stefan-Ram-Startseite befindet sich oben auf dieser Seite hinter dem Text "Stefan Ram".)  |   Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram. Schlüsselwörter zu dieser Seite/relevant keywords describing this page: Stefan Ram Berlin slrprd slrprd stefanramberlin spellched stefanram722116 stefan_ram:722116 Windows-Programmierung Windows-Programmierung Stefan Ram, Berlin, and, or, near, uni, online, slrprd, slrprdqxx, slrprddoc, slrprd722116, slrprddef722116, PbclevtugFgrsnaEnz Erklärung, Beschreibung, Info, Information, Hinweis,

Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram.
https://www.purl.org/stefan_ram/pub/windows-programmierung