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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include <windows.h>
#include <string>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void CenterWindow(HWND);
ifstream in( "Resources.txt" );
struct data
{
string chapter_data;
string question_data;
string answer_data;
};
data problem;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Center" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0,IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Study Japanese"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 500, 300, 0, 0, hInstance, 0);
while( GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//Main-------------------------------------------------------------
//-----------------------------------------------------------------
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static HWND QuestionBox;
static HWND AnswerBox;
switch(msg)
{
case WM_CREATE:
{
CenterWindow(hwnd);
string line;
while( getline( in, line ) )
{
problem.chapter_data = line;
getline( in, line );
problem.question_data = line;
getline( in, line );
problem.answer_data = line;
}
TCHAR QuestionLine = problem.question_data;
/*for( unsigned i = 0; i < 100; ++i )
{
if( i < problem.question_data.length() )
QuestionLine[i] = problem.question_data[i];
else
QuestionLine[i] = ' ';
}*/
QuestionBox = CreateWindow( TEXT("STATIC"), QuestionLine,
WS_VISIBLE | WS_CHILD | WS_BORDER,
10, 10, 200, 100,
hwnd, (HMENU) 1, NULL, NULL);
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
void CenterWindow( HWND hwnd )
{
RECT rc ;
GetWindowRect ( hwnd, &rc ) ;
SetWindowPos( hwnd, 0,
(GetSystemMetrics(SM_CXSCREEN) - rc.right)/2,
(GetSystemMetrics(SM_CYSCREEN) - rc.bottom)/2,
0, 0, SWP_NOZORDER|SWP_NOSIZE );
}
|