codice:
#include <windows.h>
#include <string>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define Show(Window) RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
using namespace std;
MSG msg;
HINSTANCE hInst;
HWND form1,label21;
int i=0;
char buffer[50];
void procedura_thread();
void reg(UINT style,WNDPROC lpfnWndProc,int cbClsExtra,int cbWndExtra,HINSTANCE hInstance,HICON hIcon,HCURSOR hCursor,HBRUSH hbrBackground,LPCTSTR lpszMenuName,LPCTSTR lpszClassName);
LRESULT CALLBACK WinProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow)
{
hInst = hInstance;
reg(CS_HREDRAW | CS_VREDRAW | CS_OWNDC,WinProc,0,0,hInst,LoadIcon(NULL,IDI_WINLOGO),LoadCursor(NULL,IDC_ARROW),(HBRUSH)(COLOR_BTNFACE+1),NULL,"principale");
form1 = CreateWindow("principale","Finestra",WS_MINIMIZEBOX | WS_SIZEBOX | WS_CAPTION | WS_MAXIMIZEBOX | WS_POPUP | WS_SYSMENU,600,300,600,440,NULL,(HMENU)NULL,hInst,NULL);
label21 = CreateWindow("Edit","",WS_CHILD | ES_LEFT | WS_BORDER| WS_VSCROLL | WS_HSCROLL | WS_VISIBLE | ES_READONLY | EM_SCROLLCARET | ES_MULTILINE | ES_AUTOVSCROLL,1,1,583,403,form1,(HMENU)NULL,hInst,NULL);
Show(form1);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&procedura_thread,NULL,0,NULL);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg==WM_DESTROY)
{
UnregisterClass("principale",hInst);
PostQuitMessage(0);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
void procedura_thread()
{
char Text[50];
char buff[5000];
i=0;
while(i<=50)
{
sprintf(Text,"Prova prova prova prova%c%c",0x0D,0x0A);
strncat (buff, Text, 46);
SetWindowText(label21,buff);
Sleep(200);
Show(form1);
i++;
}
}
void reg(UINT style,WNDPROC lpfnWndProc,int cbClsExtra,int cbWndExtra,HINSTANCE hInstance,HICON hIcon,HCURSOR hCursor,HBRUSH hbrBackground,LPCTSTR lpszMenuName,LPCTSTR lpszClassName)
{
WNDCLASS wc;
wc.style = style;
wc.lpfnWndProc = lpfnWndProc;
wc.cbClsExtra = cbClsExtra;
wc.cbWndExtra = cbWndExtra;
wc.hInstance = hInstance;
wc.hIcon = hIcon;
wc.hCursor = hCursor;
wc.hbrBackground = hbrBackground;
wc.lpszMenuName = lpszMenuName;
wc.lpszClassName = lpszClassName;
RegisterClass(&wc);
}