U
Sehr geil.
Es funktioniert.
Ich bedanke mich sehr bei euch!
#define STATIC
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
BOOL CALLBACK DialogProc( HWND, UINT, WPARAM, LPARAM );
const char szWndName[] = "Test";
const char szDialogName[] = "Dialog";
static INT_PTR iptDialog;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iShowCmd )
{
HWND hWnd;
MSG msg;
WNDCLASS ws;
ws.cbClsExtra = 0;
ws.cbWndExtra = 0;
ws.hbrBackground = ( HBRUSH )CreateSolidBrush( RGB( 240, 240, 240 ) );
ws.hCursor = LoadCursor( NULL, IDC_ARROW );
ws.hIcon = LoadIcon( NULL, IDI_APPLICATION );
ws.hInstance = hInstance;
ws.lpfnWndProc = WndProc;
ws.lpszClassName = szWndName;
ws.lpszMenuName = NULL;
ws.style = CS_VREDRAW | CS_HREDRAW;
RegisterClass( &ws );
hWnd = CreateWindow( szWndName,
szWndName,
WS_OVERLAPPED | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 100,
NULL,
NULL,
hInstance,
NULL );
ShowWindow( hWnd, iShowCmd );
UpdateWindow( hWnd );
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
};
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static RECT clientRect;
static HWND hButton;
static HWND hChild;
static char szText[100];
const char szT1[] = "Noch nicht...";
const char szT2[] = "Jetzt aber !!";
switch( uMsg )
{
case WM_SIZE:
{
GetClientRect( hWnd, &clientRect );
MoveWindow( hButton, 10, 10, clientRect.right - 20, 25, true );
return 0;
}
case WM_CREATE:
{
hButton = CreateWindow( "button",
"W E I T E R",
WS_CHILD | WS_VISIBLE,
0, 0,
0, 0,
hWnd,
NULL,
( ( LPCREATESTRUCT )lParam )->hInstance,
NULL );
memcpy( szText, szT1, lstrlen( szT1 ) );
return 0;
}
case WM_COMMAND:
{
if( lParam == ( LPARAM )hButton )
{
if( HIWORD( wParam ) == BN_CLICKED )
{
iptDialog = DialogBox( NULL,
MAKEINTRESOURCE( IDD_INFO ),
hWnd,
DialogProc );
memcpy( szText, szT2, lstrlen( szT2 ) );
InvalidateRect( hWnd, NULL, true );
return 0;
}
}
return 0;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDc;
SIZE size;
hDc = BeginPaint( hWnd, &ps );
{
GetTextExtentPoint32( hDc, szText, lstrlen( szText ), &size );
SetBkColor( hDc, RGB( 240, 240, 240 ) );
TextOut( hDc, clientRect.right / 2 - size.cx / 2, clientRect.bottom - 15 - size.cy / 2, szText, lstrlen( szText ) );
}
EndPaint( hWnd, &ps );
return 0;
}
case WM_DESTROY:
{
PostQuitMessage( 0 );
return 0;
}
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
};
BOOL CALLBACK DialogProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_COMMAND:
{
switch( wParam )
{
case IDC_CONTINUE:
EndDialog( hWnd, 0 );
break;
}
return true;
}
}
return false;
};