Beispiel #1
0
        void NWindow::Draw(HDC hDc)
        {
            GUARD_SCOPE(false, _T("NWindow Draw takes too long"));
            Base::NRect clientRect;
            ::GetClientRect(window_, clientRect);
            render_->Init(hDc, clientRect);

            Base::NRect clipRect;
            int nResult = GetClipBox(hDc, clipRect);
            if(nResult == NULLREGION)
                ::GetClientRect(window_, clipRect);
            OnDraw(render_, clipRect);

            render_->DrawBack(IsLayered());
        }
Beispiel #2
0
//
//  関数: WndProc(HWND, unsigned, WORD, LONG)
//
//  用途: メイン ウィンドウのメッセージを処理します。
//
//  WM_COMMAND	- アプリケーション メニューの処理
//  WM_PAINT	- メイン ウィンドウの描画
//  WM_DESTROY	- 終了メッセージの通知とリターン
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int ret;
	char szMsg[512];
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szHello[MAX_LOADSTRING];
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

	switch (message) {
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		// メニュー選択の解析:
		switch (wmId) {
		case IDM_ABOUT:
			DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case IDM_TEST_ISLAYERED:
			try
			{
				wsprintf(szMsg, "IsLayered = %d", IsLayered(hWnd));
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			catch(DWORD e)
			{
				wsprintf(szMsg, "IsLayered error %d", e);
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;
		case IDM_TEST_SETLAYERED_A:
			ret = SetLayered(hWnd, true);
			if (ret != 0) {
				wsprintf(szMsg, "SetLayered(true) error %d", ret);
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;
		case IDM_TEST_SETLAYERED_B:
			ret = SetLayered(hWnd, false);
			if (ret != 0) {
				wsprintf(szMsg, "SetLayered(false) error %d", ret);
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;
		case IDM_TEST_OPACITY50:
			ret = SetOpacity(hWnd, 0.5);
			if (ret != 0) {
				wsprintf(szMsg, "SetOpacity error %d", ret);
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;
		case IDM_TEST_OPACITY100:
			ret = SetOpacity(hWnd, 1.0);
			if (ret != 0) {
				wsprintf(szMsg, "SetOpacity error %d", ret);
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;
		case IDM_TEST_REPLACE1:
			{
				char* pszSrc = "c:\\表示\\データ.txt";
				std::string ret = ReplaceStr(pszSrc, "\\", "");
				if (!ret.empty()) {
					wsprintf(szMsg, "%s => %s", pszSrc, ret.c_str());
				} else {
					wsprintf(szMsg, "エラー");
				}
				MessageBox(hWnd, szMsg, NULL, MB_OK);
			}
			break;

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;

	case WM_PAINT:
		hdc = BeginPaint (hWnd, &ps);
		// TODO: この位置に描画用のコードを追加してください...
		RECT rt;
		GetClientRect(hWnd, &rt);
		DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
		EndPaint(hWnd, &ps);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
   }

   return 0;
}