Esempio n. 1
0
File: main.cpp Progetto: zie87/sds
//
//	Main window procedure - just used to host the CodeView and UniView windows
//
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int width  = LOWORD(lParam);
	int height = HIWORD(lParam);
	int height2;
	RECT rect;

	switch(msg)
	{
	case WM_CREATE:
		g_seq.init(INITIAL_TEXT, lstrlen(INITIAL_TEXT));
		hwndUniView	 = CreateUniView(hwnd, &g_seq);
		hwndSpanView = CreateSpanView(hwnd, &g_seq);
		return 0;

	case WM_CLOSE:
		DestroyWindow(hwnd);
		return 0;

	case WM_SIZE:
		GetWindowRect(hwndUniView, &rect);
		height2 =  rect.bottom-rect.top;
		MoveWindow(hwndUniView, 0, 0, width, height2, TRUE);
		MoveWindow(hwndSpanView, 0, height2+2, width, height-height2-2, TRUE);
		InvalidateRect(hwndSpanView, 0,0);
		return 0;

	case WM_USER:
		InvalidateRect(hwndSpanView, 0, 0);
		return 0;

	case WM_SETFOCUS:
		SetFocus(hwndUniView);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_COMMAND:

		switch(LOWORD(wParam))
		{
		case IDM_FILE_FONT:
			
			if(GetFont(hwnd, &g_LogFont))
			{
				DeleteObject(g_hFont);
				g_hFont = CreateFontIndirect(&g_LogFont);
				UpdateFont();

				InvalidateRect(hwndUniView, 0, 0);
				
				SetFocus(hwndMain);
				SetFocus(hwndUniView);
			}

			return 0;

		case IDM_FILE_ABOUT:

			MessageBox(hwnd, 
						_T("Piece Chain Demo\r\n\r\nCopyright(c) 2006 by Catch22 Productions.\r\nWritten by J Brown.\r\n\r\nHompage at www.catch22.net"), 
						_T("Piece Chain Demo"),
						MB_ICONINFORMATION);
			return 0;

		// Quit :)
		case IDM_FILE_EXIT:
			PostMessage(hwnd, WM_CLOSE, 0, 0);
			return 0;
		}
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}