Dinux
Gebruiker
- Lid geworden
- 20 jan 2010
- Berichten
- 420
Hallo iedereen,
Ik ben een server aan het maken en nu is de bedoeling dat de output van de functie in een soort van zelfgemaakte console komt. Hieronder staat de code tot nu toe. Ik heb alleen een paar problemen. Hoe kan ik er voor zorgen dat na elke actie een output in de edit box komt? De edit box moet ook read-only worden alleen kom ik hier niet echt uit omdat me tekst opmaak dan weer verdwijnd. Kan iemand deze code aanpassen of mij een beetje helpen?
Ik ben een server aan het maken en nu is de bedoeling dat de output van de functie in een soort van zelfgemaakte console komt. Hieronder staat de code tot nu toe. Ik heb alleen een paar problemen. Hoe kan ik er voor zorgen dat na elke actie een output in de edit box komt? De edit box moet ook read-only worden alleen kom ik hier niet echt uit omdat me tekst opmaak dan weer verdwijnd. Kan iemand deze code aanpassen of mij een beetje helpen?
Code:
#include <iostream>
#include <winsock2.h>
#include <time.h>
#include <windows.h>
#include <string.h>
using namespace std;
//
static char szClassName[ ] = "ClassMainApp";
static HINSTANCE g_hInst;
//prototypes
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
void StartServer(HWND hEdit);
//void BuildGUI(HWND hwnd);
//int window()
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
Console",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
650,
400,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
ShowWindow (hwnd, nCmdShow);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_CREATE:
CreateWindow(
"EDIT",
"",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwnd,
(HMENU)1001,
g_hInst,
NULL
);
SendDlgItemMessage(hwnd, 1001, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
StartServer(GetDlgItem(hwnd, 1001));
break;
case WM_SIZE:
if(wParam != SIZE_MINIMIZED)
{
MoveWindow(GetDlgItem(hwnd, 1001 ), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
}
break;
case WM_CTLCOLOREDIT:
{
HDC hEdit = (HDC)wParam;
SetTextColor( hEdit, RGB(0, 255,0) );
SetBkColor ( hEdit, RGB(0, 0, 0) );
return (INT_PTR)GetStockObject( BLACK_BRUSH );
}
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
void StartServer(HWND hEdit)
{
char *pszText;
DWORD dwTextLength;
SetWindowText(hEdit, "starting Server...\r\n");
//actie
//laat output op scherm zien
//actie
//laat output op scherm zien
//actie
//laat output op scherm zien
}