C
Rabbit 007 schrieb:
Das bringt das System nur zum Stillstand. Schade
Junge, lern WinAPI, am besten von Anfang an!
#include <windows.h>
#define BTN_CREATE_EDIT_BOX (4001)
#define EBX_SHOW_SOME_INFO (4002)
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Klassenname");
HWND hwnd;
MSG msg;
WNDCLASSEX wndclassex = {0};
wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = WndProc;
wndclassex.cbClsExtra = 0;
wndclassex.cbWndExtra = 0;
wndclassex.hInstance = hInstance;
wndclassex.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclassex.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclassex.lpszMenuName = NULL;
wndclassex.lpszClassName = szAppName;
wndclassex.hIconSm = wndclassex.hIcon;
if (!RegisterClassEx (&wndclassex))
{
MessageBox (NULL, TEXT ("RegisterClassEx fehlgeschlagen!"),
szAppName, MB_ICONERROR);
return (0);
}
hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil
szAppName, // Name der Fensterklasse
TEXT ("Fenstertitel"), // Fenstertitel
WS_OVERLAPPEDWINDOW, // Fensterstil
CW_USEDEFAULT, // X-Position des Fensters
CW_USEDEFAULT, // Y-Position des Fensters
400, // Fensterbreite
400, // Fensterhöhe
NULL, // übergeordnetes Fenster
NULL, // Menü
hInstance, // Programm-Kopiezähler (Programm-ID)
NULL); // zusätzliche Parameter
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
// Die Hauptnachrichtenschleife
LRESULT CALLBACK WndProc (HWND hwnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
static HWND hebxShow,
hbtCreate;
switch (uiMessage)
{
case WM_CREATE:
hbtCreate = CreateWindowEx(0L, TEXT("BUTTON"), TEXT("Erstelle das Editfeld!"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, (400 - 100) / 2, (400 - 20) / 2, 100, 20, hwnd, reinterpret_cast<HMENU>(BTN_CREATE_EDIT_BOX),
reinterpret_cast<LPCREATESTRUCT>(lParam)->hInstance, NULL);
return (0L);
case WM_COMMAND:
if(LOWORD(wParam) == BTN_CREATE_EDIT_BOX)
{
ShowWindow(hbtCreate, SW_HIDE);
hebxShow = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("Das ist wirklich nicht schwer!"),
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 400, 400, hwnd, reinterpret_cast<HMENU>(EBX_SHOW_SOME_INFO), reinterpret_cast<LPCREATESTRUCT>(lParam)->hInstance,
NULL);
}
return (0L);
case WM_DESTROY:
PostQuitMessage(0);
return (0L);
}
return (DefWindowProc(hwnd, uiMessage, wParam, lParam));
}
EDIT: Hab das NICHT getestet....Dazu kb mehr gehabt... .