1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
//header
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define WINDOW 1000
#define OUTPUT 1001
#define INPUT 1002
#define SEND 1003
#define WIDTH (470)
#define HEIGHT (350)
#define OUTW (WIDTH-48+10)
#define OUTH (HEIGHT-176+10)
#define INW (WIDTH-64+10)
#define INH (HEIGHT-272+10)
HWND outputbox,inputbox;
HDC hdc;
HFONT font=CreateFont(-17,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,"Courier New");
HINSTANCE hinstance;
LRESULT CALLBACK mainproc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
switch(msg){
case WM_CREATE:
outputbox=CreateWindow("static",">Please enter your username",WS_VISIBLE|WS_CHILD,16,16,OUTW,OUTH,hwnd,NULL,hinstance,NULL);
inputbox=CreateWindow("edit","",WS_VISIBLE|WS_CHILD|ES_MULTILINE|ES_AUTOVSCROLL,16,OUTH+32,INW,INH,hwnd,NULL,hinstance,NULL);
SendMessage(outputbox,WM_SETFONT,(WPARAM)font,MAKELPARAM(true,0));
SendMessage(inputbox,WM_SETFONT,(WPARAM)font,MAKELPARAM(true,0));
break;
case WM_CTLCOLORSTATIC:
SetTextColor((HDC)wparam,RGB(0,255,0));
SetBkMode((HDC)wparam,TRANSPARENT);
return (LRESULT)GetStockObject(BLACK_BRUSH);
case WM_CTLCOLOREDIT:
SetTextColor((HDC)wparam,RGB(0,255,0));
SetBkMode((HDC)wparam,TRANSPARENT);
return (LRESULT)GetStockObject(BLACK_BRUSH);}
return DefWindowProc(hwnd,msg,wparam,lparam);}
//main
#include "header.h"
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hprev,char* cmdparam,int cmdshow){
//variable declarations
HWND hwnd;
MSG messages;
WNDCLASSEX wndclass;
//register window class
wndclass.hInstance=hinst;
wndclass.lpszClassName="MyClass";
wndclass.lpfnWndProc=mainproc;
wndclass.style=CS_DBLCLKS;
wndclass.cbSize=sizeof(WNDCLASSEX);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.lpszMenuName=NULL;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
if(!RegisterClassEx(&wndclass)){
MessageBox(0,"ERROR: Failed to register window class","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 1;}
//create the window
hwnd=CreateWindowEx(0,"MyClass","MyApp",WS_OVERLAPPEDWINDOW&~WS_THICKFRAME,CW_USEDEFAULT,CW_USEDEFAULT,WIDTH,HEIGHT,HWND_DESKTOP,NULL,hinst,NULL);
if(!hwnd){
MessageBox(0,"ERROR: Failed to create window","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 2;}
ShowWindow(hwnd,cmdshow);
//enter main loop
while(GetMessage(&messages,NULL,0,0)){
TranslateMessage(&messages);
DispatchMessage(&messages);}
return messages.wParam;}
|