當前位置: 首頁>>代碼示例>>C++>>正文


C++ BeginPaint函數代碼示例

本文整理匯總了C++中BeginPaint函數的典型用法代碼示例。如果您正苦於以下問題:C++ BeginPaint函數的具體用法?C++ BeginPaint怎麽用?C++ BeginPaint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BeginPaint函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: MyWinFunc

/* Window message handle function */
LRESULT CALLBACK MyWinFunc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
  INT i;
  HDC hDC;
  PAINTSTRUCT ps;
  static INT w, h;
  static BITMAP bm;
  static HBITMAP hBm, hBmLogo;
  static HDC hMemDC, hMemDCLogo;

  switch (Msg)
  {
  case WM_CREATE:
    SetTimer(hWnd, 30, 10, NULL);
    hBmLogo = LoadImage(NULL, "GLOBE.BMP", IMAGE_BITMAP, 0, 0,
        LR_LOADFROMFILE);
    GetObject(hBmLogo, sizeof(bm), &bm);
    hDC = GetDC(hWnd);
    hMemDC = CreateCompatibleDC(hDC);
    hMemDCLogo = CreateCompatibleDC(hDC);
    SelectObject(hMemDCLogo, hBmLogo);
    ReleaseDC(hWnd, hDC);
    return 0;
  case WM_SIZE:
    w = LOWORD(lParam);
    h = HIWORD(lParam);
    if (hBm != NULL)
      DeleteObject(hBm);
    hDC = GetDC(hWnd);
    hBm = CreateCompatibleBitmap(hDC, w, h);
    ReleaseDC(hWnd, hDC);
    SelectObject(hMemDC, hBm);
    SendMessage(hWnd, WM_TIMER, 0, 0);
    return 0;
  case WM_TIMER:
    Rectangle(hMemDC, 0, 0, w + 1, h + 1);
    /*
    BitBlt(hMemDC, 0, 0, bm.bmWidth, bm.bmHeight,
      hMemDCLogo, 0, 0, SRCCOPY);
    */
    SetStretchBltMode(hMemDC, COLORONCOLOR);
    StretchBlt(hMemDC, 0, 0, w, h,
      hMemDCLogo, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
    DrawEye(hWnd, hMemDC, 100, 100, 50, 15);
    DrawEye(hWnd, hMemDC, 300, 200, 150, 30);
    DrawEye(hWnd, hMemDC, 100, 200, 50, 30);
    DrawEye(hWnd, hMemDC, 400, 200, 130, 30);
    DrawEye(hWnd, hMemDC, w / 2, h / 2, 80, 15);

    srand(59);
    for (i = 0; i < 30; i++)
      DrawEye(hWnd, hMemDC, rand() % 800, rand() % 700, 30, 8);

    SetBkMode(hMemDC, TRANSPARENT);
    SetTextColor(hMemDC, RGB(255, 0, 0));
    TextOut(hMemDC, 30, 30, "30!", 3);
    InvalidateRect(hWnd, NULL, FALSE);
    return 0;
  case WM_PAINT:
    hDC = BeginPaint(hWnd, &ps);
    BitBlt(hDC, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY);
    EndPaint(hWnd, &ps);
    return 0;
  case WM_DESTROY:
    KillTimer(hWnd, 30);
    DeleteDC(hMemDC);
    DeleteObject(hBm);
    PostQuitMessage(0);
    return 0;
  }
  return DefWindowProc(hWnd, Msg, wParam, lParam);
} /* End of 'MyWinFunc' function */
開發者ID:CGSG,項目名稱:SUM2016,代碼行數:73,代碼來源:T02EYES.C

示例2: WndProc


//.........這裏部分代碼省略.........
                    FocusedConsole = SearchConsole(LastConsole);
                    if (FocusedConsole != NULL &&
                        FocusedConsole->hConsole != NULL) {
                        FocusedConsole->Enable = FALSE;
                        EnableWindow(FocusedConsole->hWndCon,FALSE);
                        gfDoNotKillFocus = TRUE;
                    }
                }
                else{
                    DWORD i;
                    LockConsoleTable();
                    for ( i = 1; i < NumberOfConsoleTable; i ++){
                        FocusedConsole = ConsoleTable[i];
                        if (FocusedConsole != NULL)
                        {
                            if ((FocusedConsole->hConsole != NULL)&&
                                (!FocusedConsole->Enable)&&
                                (!IsWindowEnabled(FocusedConsole->hWndCon))){
                                EnableWindow(FocusedConsole->hWndCon,TRUE);
                                FocusedConsole->Enable = TRUE;
                                if (!FocusedConsole->LateRemove)
                                    SetForegroundWindow(FocusedConsole->hWndCon);
                            }
                        }
                    }
                    UnlockConsoleTable();
                }
                return DefWindowProc(hWnd, Message, wParam, lParam);
                break;
            }

#ifdef DEBUG_MODE
            case WM_SETFOCUS:
                CreateCaret( hWnd,
                             NULL,
                             IsUnicodeFullWidth( ConvertLine[xPos] ) ?
                             CaretWidth*2 : CaretWidth,
                             (UINT)cyMetrics );
                SetCaretPos( xPos * cxMetrics, 0 );
                ShowCaret( hWnd );
                break;

            case WM_KILLFOCUS:
                HideCaret( hWnd );
                DestroyCaret();
                break;

            case WM_PAINT:
                {
                    PAINTSTRUCT pstruc;
                    HDC  hDC;
                    hDC = BeginPaint(hWnd,&pstruc);
                    ReDraw(hWnd);
                    EndPaint(hWnd,&pstruc);
                    break;
                }
#endif

            case WM_QUERYENDSESSION:
#ifdef HIRSHI_DEBUG
                /*
                 * If specified ntsd debugger on this process,
                 * then never catch WM_QUERYENDSESSION when logoff/shutdown because
                 * this process will terminate when ntsd process terminated.
                 */
                {
                    int i;
                    i = MessageBox(hWnd,TEXT("Could you approve exit session?"), TEXT("Console IME"),
                                   MB_ICONSTOP | MB_YESNO);
                    return (i == IDYES ? TRUE : FALSE);
                }
#endif
                return TRUE;           // Logoff or shutdown time.

            case WM_ENDSESSION:
                DBGPRINT(("CONIME:Recieve WM_ENDSESSION\n"));
                ExitList(hWnd);
                return 0;

            default:          // Passes it on if unproccessed
                return DefWindowProc(hWnd, Message, wParam, lParam);
        }

    } except (InputExceptionFilter(GetExceptionInformation())) {

        if (dwConsoleThreadId)
        {
            DBGPRINT(("CONIME: Exception on WndProc!!\n"));
            UnregisterConsoleIME();
            dwConsoleThreadId = 0;

            DestroyWindow(hWnd);
            return 0;
        }

    }


    return TRUE;
}
開發者ID:conioh,項目名稱:os-design,代碼行數:101,代碼來源:conime.c

示例3: switch

LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	// handle a few messages
	switch (message)
	{
	// paint: draw bezels as necessary
	case WM_PAINT:
		{
			PAINTSTRUCT pstruct;
			HDC dc = BeginPaint(m_wnd, &pstruct);
			draw_contents(dc);
			EndPaint(m_wnd, &pstruct);
			break;
		}

	// keydown: handle debugger keys
	case WM_KEYDOWN:
		if (handle_key(wparam, lparam))
			set_ignore_char_lparam(lparam);
		break;

	// char: ignore chars associated with keys we've handled
	case WM_CHAR:
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
				return DefWindowProc(m_wnd, message, wparam, lparam);
		}
		break;

	// activate: set the focus
	case WM_ACTIVATE:
		if (wparam != WA_INACTIVE)
			set_default_focus();
		break;

	// get min/max info: set the minimum window size
	case WM_GETMINMAXINFO:
		{
			MINMAXINFO *minmax = (MINMAXINFO *)lparam;
			minmax->ptMinTrackSize.x = m_minwidth;
			minmax->ptMinTrackSize.y = m_minheight;
			minmax->ptMaxSize.x = minmax->ptMaxTrackSize.x = m_maxwidth;
			minmax->ptMaxSize.y = minmax->ptMaxTrackSize.y = m_maxheight;
			break;
		}

	// sizing: recompute child window locations
	case WM_SIZE:
	case WM_SIZING:
		recompute_children();
		InvalidateRect(m_wnd, NULL, FALSE);
		break;

	// mouse wheel: forward to the first view
	case WM_MOUSEWHEEL:
		{
			static int units_carryover = 0;

			UINT lines_per_click;
			if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_click, 0))
				lines_per_click = 3;

			int const units = GET_WHEEL_DELTA_WPARAM(wparam) + units_carryover;
			int const clicks = units / WHEEL_DELTA;
			units_carryover = units % WHEEL_DELTA;

			int const delta = clicks * lines_per_click;
			int viewnum = 0;
			POINT point;

			// figure out which view we are hovering over
			GetCursorPos(&point);
			ScreenToClient(m_wnd, &point);
			HWND const child = ChildWindowFromPoint(m_wnd, point);
			if (child)
			{
				for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++)
				{
					if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child))
						break;
				}
				if (viewnum == MAX_VIEWS)
					break;
			}

			// send the appropriate message to this view's scrollbar
			if (m_views[viewnum] != NULL)
				m_views[viewnum]->send_vscroll(delta);

			break;
		}

	// activate: set the focus
	case WM_INITMENU:
		update_menu();
		break;

	// command: handle a comment
	case WM_COMMAND:
//.........這裏部分代碼省略.........
開發者ID:robsonfr,項目名稱:mame,代碼行數:101,代碼來源:debugwininfo.cpp

示例4: WinProc

LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) {
    PAINTSTRUCT Ps;
	switch(msg) {
    case WM_CREATE: {

		    /**
		    * Create AddFood Button
            */
            HFONT hFont = CreateFont(30,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                CLIP_DEFAULT_PRECIS,NULL, VARIABLE_PITCH,TEXT("Impact"));

            HWND hButtonAddFood = CreateWindowEx(NULL,
                "BUTTON",
                "ADD FOOD",
                WS_TABSTOP|WS_VISIBLE|
                WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP,
                10,
                150,
                100,
                25,
                hWnd,
                (HMENU)BUTTON_ADD_FOOD,
                GetModuleHandle(NULL),
                NULL);

            /**
            * Create button ShowFoodNumber
            */
            HWND hShowFoodNumber = CreateWindowEx(NULL,
                "BUTTON",
                "Funny",
                WS_TABSTOP|WS_VISIBLE|
                WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP,
                10,
                180,
                300,
                40,
                hWnd,
                (HMENU)BUTTON_DISPLAY_FOOD_NR,
                GetModuleHandle(NULL),
                NULL);
            SendMessage (hShowFoodNumber, WM_SETFONT, WPARAM (hFont), TRUE);

            /**
            * Draw Food List (In a input box)
            */


            hFoodList = CreateWindowEx(WS_EX_CLIENTEDGE,
                "EDIT",
                "",
                WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_READONLY|
                ES_MULTILINE,
                10,
                40,
                300,
                100,
                hWnd,
                (HMENU)INPUT_TEXT_SHOW_FOOD,
                GetModuleHandle(NULL),
                NULL);


            /**
            * Draw main Input food field
            */

            hInputFood = CreateWindowEx(
                (DWORD)NULL,
                TEXT("edit"),
                "",
                WS_VISIBLE | WS_CHILD | WS_BORDER,
                120,
                150,
                190,
                25,
                hWnd,
                (HMENU)INPUT_TEXT_ADD_FOOD,
                GetModuleHandle(NULL),
                NULL);
        }
        break;

		case WM_PAINT: {
            HDC hdc = BeginPaint(hWnd, &Ps);
            RECT rect;
            /**
            * Draw Text
            */

            // Second Text
            char foodNrMessage[256] = "Number : ";
            char nr[50];
            strcat(foodNrMessage, itoa(foodNumber, nr, 10));
            SetBkMode(hdc, TRANSPARENT);
            SetRect(&updateRect, 210, 10, 300, 30);
            DrawText( hdc, foodNrMessage, -1, &updateRect, DT_SINGLELINE | DT_NOCLIP  ) ;

            // First Text
            HFONT hFont = CreateFont(25,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
//.........這裏部分代碼省略.........
開發者ID:TUM-FAF,項目名稱:WP-FAF-111-Terman-Sergiu,代碼行數:101,代碼來源:main.cpp

示例5: WndProc

// Processes messages for main Window
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    PTOUCHINPUT pInputs;
    TOUCHINPUT tInput;
    HTOUCHINPUT hInput;
    int iNumContacts;
    POINT ptInputs;
    PAINTSTRUCT ps;

    // Handle each type of inData and based on which event we handle continue processing
    // the inData for manipulations by calling the ComTouchDriver
    
    switch (msg)
    {
    case WM_TOUCH:

        iNumContacts = LOWORD(wParam);
        hInput = (HTOUCHINPUT)lParam;

        pInputs = new (std::nothrow) TOUCHINPUT[iNumContacts];
       
        // Get each touch input info and feed each TOUCHINPUT into the process input handler

        if(pInputs != NULL)
        {
            if(GetTouchInputInfo(hInput, iNumContacts, pInputs, sizeof(TOUCHINPUT)))
            {
               for(int i = 0; i < iNumContacts; i++)
               {
                   // Bring touch input info into client coordinates

                   ptInputs.x = pInputs[i].x/100;	
                   ptInputs.y = pInputs[i].y/100;
                   ScreenToClient(g_hWnd, &ptInputs);
                   pInputs[i].x = ptInputs.x;
                   pInputs[i].y = ptInputs.y;
                   g_ctDriver->ProcessInputEvent(&pInputs[i]);
               }
               g_ctDriver->ProcessChanges();
            }
        }
        
        delete [] pInputs;
        CloseTouchInputHandle(hInput);
        break;
    
    // For each Mouse event build a TOUCHINPUT struct and feed into the process input handler

    case WM_LBUTTONDOWN:

        FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_DOWN, (DWORD)GetMessageTime(),LOWORD(lParam),HIWORD(lParam));
        g_ctDriver->ProcessInputEvent(&tInput);        
        break;

    case WM_MOUSEMOVE:

        if(LOWORD(wParam) == MK_LBUTTON)
        {
            FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_MOVE, (DWORD)GetMessageTime(),LOWORD(lParam), HIWORD(lParam));
            g_ctDriver->ProcessInputEvent(&tInput);      
            g_ctDriver->ProcessChanges();
        }
      
        break;

    case WM_LBUTTONUP:

        FillInputData(&tInput, MOUSE_CURSOR_ID, TOUCHEVENTF_UP, (DWORD)GetMessageTime(),LOWORD(lParam), HIWORD(lParam));
        g_ctDriver->ProcessInputEvent(&tInput);
        
        break;

    case WM_DESTROY:
        
        if(g_ctDriver)
        {
            delete g_ctDriver;
        }
        PostQuitMessage(0);
        return 1;

    case WM_SIZE:

        g_iCWidth = LOWORD(lParam);
        g_iCHeight = HIWORD(lParam);
        break;

    case WM_PAINT:
        
        BeginPaint(g_hWnd, &ps);
        g_ctDriver->RenderInitialState(g_iCWidth, g_iCHeight);
        EndPaint(g_hWnd, &ps);
        break;

    case WM_TIMER:
        g_ctDriver->ProcessChanges();
        break;
      
    default:
//.........這裏部分代碼省略.........
開發者ID:FrankAlbis,項目名稱:Win7_SDK_Samples,代碼行數:101,代碼來源:ManipulationSample.cpp

示例6: WndProc


//.........這裏部分代碼省略.........

          if (wmId == ID_WARN_DOWNLOADCOMPLETE)
            ss << L"downloaded successfully.";
          else
            ss << L"failed to download.";

          MessageBox(hWnd, ss.str().c_str(), L"File Download",
              MB_OK | MB_ICONINFORMATION);
        }
        return 0;
#ifdef SHOW_TOOLBAR_UI
      case IDC_NAV_BACK:   // Back button
        if (browser.get())
          browser->GoBack();
        return 0;
      case IDC_NAV_FORWARD:  // Forward button
        if (browser.get())
          browser->GoForward();
        return 0;
      case IDC_NAV_RELOAD:  // Reload button
        if (browser.get())
          browser->Reload();
        return 0;
      case IDC_NAV_STOP:  // Stop button
        if (browser.get())
          browser->StopLoad();
        return 0;
#endif // SHOW_TOOLBAR_UI
      }
      break;
    }

    case WM_PAINT:
      hdc = BeginPaint(hWnd, &ps);
      EndPaint(hWnd, &ps);
      return 0;

    case WM_SETFOCUS:
      if (g_handler.get() && g_handler->GetBrowser()) {
        // Pass focus to the browser window
        CefWindowHandle hwnd =
            g_handler->GetBrowser()->GetHost()->GetWindowHandle();
        if (hwnd)
          PostMessage(hwnd, WM_SETFOCUS, wParam, NULL);
      }
      return 0;

    case WM_SIZE:
      // Minimizing resizes the window to 0x0 which causes our layout to go all
      // screwy, so we just ignore it.
      if (wParam != SIZE_MINIMIZED && g_handler.get() &&
          g_handler->GetBrowser()) {
        CefWindowHandle hwnd =
            g_handler->GetBrowser()->GetHost()->GetWindowHandle();
        if (hwnd) {
          // Resize the browser window and address bar to match the new frame
          // window size
          RECT rect;
          GetClientRect(hWnd, &rect);
#ifdef SHOW_TOOLBAR_UI
          rect.top += URLBAR_HEIGHT;

          int urloffset = rect.left + BUTTON_WIDTH * 4;
#endif // SHOW_TOOLBAR_UI

          HDWP hdwp = BeginDeferWindowPos(1);
開發者ID:David-Mulder,項目名稱:brackets-shell,代碼行數:67,代碼來源:cefclient_win.cpp

示例7: _ASSERTE

/**
 * @param hwnd - window handle.
 * @param uMsg - message identifier.
 * @param wParam - first message parameter.
 * @param lParam - second message parameter.
 */
LRESULT CALLBACK CSplitter::SplitterWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	int x, y, nSplitterPos, nSplitterSize;
	POINT point;
	HCURSOR hCursor;
	PAINTSTRUCT ps;
	HDC hdc;
	DWORD dwResult;

	CSplitter* _this  = (CSplitter*)GetWindowLongPtr(hwnd, GWL_USERDATA);
	_ASSERTE(_this != NULL);
	switch(uMsg)
	{
	case WM_NCHITTEST:
		if (GetCapture() == hwnd)
			return HTCLIENT;
		point.x = GET_X_LPARAM(lParam);
		point.y = GET_Y_LPARAM(lParam);
		ScreenToClient(hwnd, &point);
		return (_this->HitTest(point) ? HTCLIENT : HTTRANSPARENT);
	case WM_SETCURSOR:
		_ASSERTE(g_pResManager != NULL);
		dwResult = GetMessagePos();
		point.x = GET_X_LPARAM(dwResult);
		point.y = GET_Y_LPARAM(dwResult);
		ScreenToClient(hwnd, &point);
		if (_this->HitTest(point))
			hCursor = _this->m_eDirection == SD_VERTICAL ? g_pResManager->m_hUpDownCursor : g_pResManager->m_hLeftRightCursor;
		else
			hCursor = g_pResManager->m_hArrowCursor;
		if (hCursor)
		{
			SetCursor(hCursor);
			return TRUE;
		}
		return FALSE;
	case WM_LBUTTONDOWN:
		if (GetCapture() != hwnd)
		{
			x = GET_X_LPARAM(lParam);
			y = GET_Y_LPARAM(lParam);
			if (_this->HitTest(x, y))
				SetCapture(hwnd);
		}
		return 0;
	case WM_MOUSEMOVE:
		if (GetCapture() == hwnd)
		{
			nSplitterPos = _this->m_eDirection == SD_VERTICAL ? GET_Y_LPARAM(lParam) : GET_X_LPARAM(lParam);
			_this->SetSplitterPos(nSplitterPos);
		}
		return 0;
	case WM_LBUTTONUP:
		if (GetCapture() == hwnd)
			ReleaseCapture();
		return 0;
	case WM_CAPTURECHANGED:
		return 0;
	case WM_ERASEBKGND:
		return TRUE;
	case WM_SIZE:
		nSplitterSize = _this->m_eDirection == SD_VERTICAL ? GET_Y_LPARAM(lParam) : GET_X_LPARAM(lParam);
		_this->ResizeSplitter(nSplitterSize);
		return 0;
	case WM_PAINT:
		hdc = (HDC)wParam;
		if (! hdc)
		{
			hdc = BeginPaint(hwnd, &ps);
			if (hdc)
			{
				_this->DrawSplitter(hdc);
				EndPaint(hwnd, &ps);
			}
		}
		else
			_this->DrawSplitter(hdc);
		return 0;
	case WM_PRINTCLIENT:
		hdc = (HDC)wParam;
		_this->DrawSplitter(hdc);
		return 0;
	case WM_GETDLGCODE:
		return DLGC_STATIC;
	default:
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
	}
}
開發者ID:BeaconDev,項目名稱:xray-16,代碼行數:94,代碼來源:Splitter.cpp

示例8: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	RECT rect;
	COLORREF colorText = RGB(0, 0, 255); // задаём цвет текста
	
	switch (message)
	{

	case WM_COMMAND:

	case BN_CLICKED:

		if (LOWORD(wParam) == ID_BUTTON1)
		{
			
			GetClientRect(hWnd, &rect);
			edit1 = CreateWindowEx(
				WS_EX_CLIENTEDGE,
				L"edit",
				L"Нажмите правую клавишу мыши",
				WS_CHILD | WS_VISIBLE | EM_FMTLINES,
				rect.right / 4,									/*координаты по X*/
				rect.bottom / 4,								/*координаты по Y*/
				rect.right / 2,									/*Ширина окошка*/
				rect.bottom / 2,
				hWnd,
				(HMENU)ID_EDIT1,
				hinst,
				NULL);
		
		}
		
		break;

	case WM_RBUTTONDOWN:
			
			ShowWindow(edit1, SW_HIDE);
			break;

	case WM_CREATE:

		GetClientRect(hWnd, &rect);
				
		button1 = CreateWindowEx(
			WS_EX_CLIENTEDGE,
			L"button",
			L"Показать",
			WS_CHILD | WS_VISIBLE,
			rect.right / 2 - ARRAYSIZE(L"Показать") * 4 - 10,		/*координаты по X*/
			rect.bottom - 30,						/*координаты по Y*/
			ARRAYSIZE(L"Показать") * 10,						/*Ширина окошка*/
			25,
			hWnd,
			(HMENU)ID_BUTTON1,
			hinst,
			NULL);

		
		break;

	case WM_PAINT:

		hdc = BeginPaint(hWnd, &ps); // инициализируем контекст устройства
		GetClientRect(hWnd, &rect); // получаем ширину и высоту области для рисования
		SetTextColor(hdc, colorText); // устанавливаем цвет контекстного устройства
		
		
				DrawText(hdc, L"В в е д и т е   т е к с т", -1, &rect, DT_SINGLELINE | DT_CENTER); // рисуем текст
			
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
開發者ID:andrevyakin,項目名稱:DZ_05.04.15_3_WinAPI,代碼行數:82,代碼來源:DZ_05.04.15_3.cpp

示例9: WinProc

LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   PAINTSTRUCT    ps;

    switch (uMsg)
	{ 
    case WM_SIZE:										// If the window is resized
		if(!g_bFullScreen)								// Do this only if we are NOT in full screen
		{
			SizeOpenGLScreen(LOWORD(lParam),HIWORD(lParam));// LoWord=Width, HiWord=Height
			GetClientRect(hWnd, &g_rRect);				// Get the window rectangle
		}
        break; 
 
	case WM_PAINT:										// If we need to repaint the scene
		BeginPaint(hWnd, &ps);							// Init the paint struct		
		EndPaint(hWnd, &ps);							// EndPaint, Clean up
		break;

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// Below we define our controls for this simple tutorial.
	// The controls are: 

	// Left Mouse Button - Changes the Render mode from normal to wireframe.
	// Right Mouse Button - Turns lighting On/Off
	// Left Arrow Key - Spins the model to the left
	// Right Arrow Key - Spins the model to the right
	// Escape - Quits

	case WM_LBUTTONDOWN:								// If the left mouse button was clicked
		
		if(g_ViewMode == GL_TRIANGLES) {				// We our drawing mode is at triangles
			g_ViewMode = GL_LINE_STRIP;					// Go to line strips
		} else {
			g_ViewMode = GL_TRIANGLES;					// Go to triangles
		}
		break;

	case WM_RBUTTONDOWN:								// If the right mouse button was clicked.
		
		g_bLighting = !g_bLighting;						// Turn lighting ON/OFF

		if(g_bLighting) {								// If lighting is ON
			glEnable(GL_LIGHTING);						// Enable OpenGL lighting
		} else {
			glDisable(GL_LIGHTING);						// Disable OpenGL lighting
		}
		break;

	case WM_KEYDOWN:									// If we pressed a key

		switch(wParam) {								// Check if we hit a key
			case VK_ESCAPE:								// If we hit the escape key
				PostQuitMessage(0);						// Send a QUIT message to the window
				break;

			case VK_LEFT:								// If the LEFT arrow key was pressed
				g_RotationSpeed -= 0.05f;				// Decrease the rotation speed (eventually rotates left)
				break;

			case VK_RIGHT:								// If the RIGHT arrow key is pressed
				g_RotationSpeed += 0.05f;				// Increase the rotation speed (rotates right)
				break;
		}
		break;

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


    case WM_CLOSE:										// If the window is being closed
        PostQuitMessage(0);								// Send a QUIT Message to the window
        break; 
     
    default:											// Return by default
        return DefWindowProc (hWnd, uMsg, wParam, lParam); 
    } 
 
    return 0;											// If we handled the messge return 0
}
開發者ID:88er,項目名稱:tutorials,代碼行數:80,代碼來源:Main.cpp

示例10: MsgBoxDlgProc

BOOL CALLBACK MsgBoxDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MBDATA * pMbd;

	switch (uMsg)
		{
		//  center in parent but on screen if hWndPar != NULL
		case WM_INITDIALOG : {
			CRect rWin;
			GetClientRect (hDlg, &rWin);
			ASSERT ((rWin.left == 0) && (rWin.top == 0));
			HWND hWndPar = GetParent (hDlg);

			if (hWndPar == NULL)
				rWin += CPoint ((GetSystemMetrics (SM_CXSCREEN) - rWin.Width ()) / 2,
										(GetSystemMetrics (SM_CYSCREEN) - rWin.Height ()) / 2);
			else
			  {
			  CRect rPar;
				GetWindowRect (hWndPar, &rPar);
				rWin += CPoint (rPar.left + (rPar.Width () - rWin.Width ()) / 2,
										rPar.top + (rPar.Height () - rWin.Height ()) / 2);
				if (rWin.left < 0)
					rWin += CPoint (- rWin.left, 0);
				else
					if (rWin.right > GetSystemMetrics (SM_CXSCREEN))
						rWin -= CPoint (rWin.right - GetSystemMetrics (SM_CXSCREEN), 0);
				if (rWin.top < 0)
					rWin += CPoint (0, - rWin.top);
				else
					if (rWin.bottom > GetSystemMetrics (SM_CYSCREEN))
						rWin -= CPoint (0, rWin.bottom - GetSystemMetrics (SM_CYSCREEN));
			  }

			SetWindowPos (hDlg, NULL, rWin.left, rWin.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
			} // NO BREAK - falls through

		case WM_ACTIVATE :
		case WM_ACTIVATEAPP :
			hDlgBox = hDlg;
			return (TRUE);
		case WM_DESTROY :
			hDlgBox = NULL;
			break;

		case WM_PAINT :
			pMbd = (MBDATA *) GetWindowLong (hDlg, DWL_USER);
			if ((pMbd == NULL) || (pMbd->hIcon == NULL))
				break;
			PAINTSTRUCT ps;
			BeginPaint (hDlg, &ps);
			DrawIcon (ps.hdc, pMbd->iXicon, pMbd->iYicon, pMbd->hIcon);
			EndPaint (hDlg, &ps);
			return (TRUE);

		case WM_COMMAND :
			if ((LOWORD (lParam) == 0) || (HIWORD (lParam) != BN_CLICKED))
				break;
			if ((pMbd = (MBDATA *) GetWindowLong (hDlg, DWL_USER)) == NULL)
				break;

			// check for help
			if (wParam == pMbd->wHelpBtn)
			  {
				const char *pHelpFile;
				char sName[130];
				CWinApp *pApp = AfxGetApp ();
				if (pApp != NULL)
					pHelpFile =	pApp->m_pszHelpFilePath;
				else
				  {
				  GetModuleFileName (AfxGetInstanceHandle (), sName, 128);
					int iLen = strlen (sName);
					if (iLen < 3)
						break;
					sName[iLen-3] = 0;
					strcat (sName, "HLP");
					pHelpFile = sName;
				  }

				if (pMbd->lHelp == 0)
					WinHelp (hDlg, pHelpFile,	HELP_CONTENTS, 0);
				else
					WinHelp (hDlg, pHelpFile,	HELP_CONTEXT, pMbd->lHelp);
			  return (TRUE);
			  }

			*(pMbd->piRtn) = wParam;
			return (TRUE);
		}

	return (FALSE);
}
開發者ID:Marenz,項目名稱:EnemyNations,代碼行數:93,代碼來源:MSG_BOX.CPP

示例11: WndProc

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	int mX, mY;
	PAINTSTRUCT ps;
	HDC hdc;

	::GetClientRect(hWnd, &winRect);
	WorldRenderer worldHandle(hWnd, hdc, winRect, player);

	/*
	*/
	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		worldHandle.update(playerAct);
		EndPaint(hWnd, &ps);
		break;	
	
	case WM_MOUSEMOVE:
		// 부드럽게 보이기 위해서는 잔상처리를 그대로 하는 게 더 부드럽게 보임
		// 잔상처리를 안할경우 화면이 번쩍거리는 현상이 보이게 됨
		mX = LOWORD(lParam); // x coordinate
		mY = HIWORD(lParam); // y coordinate
		/*
		*/
		switch (wParam){
		case MK_LBUTTON:
			if (player.moveFlag == true){
				player.pos = worldHandle.getPlayerCoordinate(mX, mY);
				player.curpos = { mX, mY };

				if (worldHandle.isCurInside(player)){
					player.obj = worldHandle.getTileCoordnate(mX, mY);
					hdc = ::GetDC(hWnd);
					::Ellipse(hdc, player.obj.left, player.obj.top, player.obj.right, player.obj.bottom);
					::ReleaseDC(hWnd, hdc);
					playerAct = true;
				}
				else if (playerAct){
					hdc = ::GetDC(hWnd);
					::Ellipse(hdc, player.obj.left, player.obj.top, player.obj.right, player.obj.bottom);
					::ReleaseDC(hWnd, hdc);
				}
				else{
					//
				}
			}
			break;				
		}			
		/*
		*/
		break;

	case WM_LBUTTONUP:
		InvalidateRect(hWnd, NULL, true);
		break;

	case WM_LBUTTONDOWN:
		mX = LOWORD(lParam); // x coordinate
		mY = HIWORD(lParam); // y coordinate

		//test
		if (player.pos.x == worldHandle.getPlayerCoordinate(mX, mY).x &&
			player.pos.y == worldHandle.getPlayerCoordinate(mX, mY).y){
			player.moveFlag = true;
		}
		else {
			player.moveFlag = false;
		}
		//

//.........這裏部分代碼省略.........
開發者ID:arkiny,項目名稱:C-Cpp-WinApi,代碼行數:101,代碼來源:TileMapDrawer.cpp

示例12: WndProc

static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
  switch (uMessage)
    {
    case WM_PAINT:
      {
	PAINTSTRUCT ps;
	BeginPaint(hwnd, &ps);
	SetMapMode(ps.hdc, MM_ANISOTROPIC);
	/* Set the window extent to a sane value in case the metafile doesn't */
	SetWindowExtEx(ps.hdc, width, height, NULL);
	SetViewportExtEx(ps.hdc, width, height, NULL);
	SetViewportOrgEx(ps.hdc, deltax, deltay, NULL);
       if (isEnhanced && enhmf)
       {
           RECT r;
           GetClientRect(hwnd, &r);
           PlayEnhMetaFile(ps.hdc, enhmf, &r);
       }
       else if (hmf)
           PlayMetaFile(ps.hdc, hmf);
	EndPaint(hwnd, &ps);
      }
      break;

    case WM_COMMAND: /* message: command from application menu */
        switch (LOWORD(wparam))
	{
	case IDM_OPEN:
	  {
              WCHAR filename[MAX_PATH];
              if (FileOpen(hwnd, filename, sizeof(filename)/sizeof(WCHAR)))
              {
                  szFileTitle[0] = 0;
                  GetFileTitleW(filename, szFileTitle, sizeof(szFileTitle)/sizeof(WCHAR));
                  DoOpenFile(filename);
                  UpdateWindowCaption();
              }
	  }
	  break;

	case IDM_SET_EXT_TO_WIN:
	  {
	    RECT r;
	    GetClientRect(hwnd, &r);
	    width = r.right - r.left;
	    height = r.bottom - r.top;
	    deltax = deltay = 0;
	    InvalidateRect( hwnd, NULL, TRUE );
	  }
	  break;


	case IDM_LEFT:
	  deltax += 100;
	  InvalidateRect( hwnd, NULL, TRUE );
	  break;
	case IDM_RIGHT:
	  deltax -= 100;
	  InvalidateRect( hwnd, NULL, TRUE );
	  break;
	case IDM_UP:
	  deltay += 100;
	  InvalidateRect( hwnd, NULL, TRUE );
	  break;
	case IDM_DOWN:
	  deltay -= 100;
	  InvalidateRect( hwnd, NULL, TRUE );
	  break;

	case IDM_EXIT:
	  DestroyWindow(hwnd);
	  break;

	default:
	  return DefWindowProcW(hwnd, uMessage, wparam, lparam);
	}
      break;

    case WM_DESTROY:  /* message: window being destroyed */
      PostQuitMessage(0);
      break;

    default:          /* Passes it on if unprocessed */
      return DefWindowProcW(hwnd, uMessage, wparam, lparam);
    }
    return 0;
}
開發者ID:AlexSteel,項目名稱:wine,代碼行數:88,代碼來源:view.c

示例13: switch

/*************************************************************************
    Win32 'Window Procedure' function
*************************************************************************/
LRESULT CALLBACK Win32AppHelper::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_CHAR:
        s_samplesFramework->injectChar((CEGUI::utf32)wParam);
        break;

    case WM_MOUSELEAVE:
        mouseLeaves();
        break;

    case WM_NCMOUSEMOVE:
        mouseLeaves();
        break;

    case WM_MOUSEMOVE:
        mouseEnters();

        s_samplesFramework->injectMousePosition((float)(LOWORD(lParam)), (float)(HIWORD(lParam)));
        break;

    case WM_LBUTTONDOWN:
        s_samplesFramework->injectMouseButtonDown(CEGUI::LeftButton);
        break;

    case WM_LBUTTONUP:
        s_samplesFramework->injectMouseButtonUp(CEGUI::LeftButton);
        break;

    case WM_RBUTTONDOWN:
        s_samplesFramework->injectMouseButtonDown(CEGUI::RightButton);
        break;

    case WM_RBUTTONUP:
        s_samplesFramework->injectMouseButtonUp(CEGUI::RightButton);
        break;

    case WM_MBUTTONDOWN:
        s_samplesFramework->injectMouseButtonDown(CEGUI::MiddleButton);
        break;

    case WM_MBUTTONUP:
        s_samplesFramework->injectMouseButtonUp(CEGUI::MiddleButton);
        break;

    case 0x020A: // WM_MOUSEWHEEL:
        s_samplesFramework->injectMouseWheelChange(static_cast<float>((short)HIWORD(wParam)) / static_cast<float>(120));
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    case WM_SIZE:
        {
            // get CEGUI::System as a pointer so we can detect if it's not
            // instantiated yet.
            CEGUI::System* cegui_system = CEGUI::System::getSingletonPtr();

            // only continue if CEGUI is up an running and window was not
            // minimised (else it's just a waste of time)
            if ((cegui_system != 0) && (wParam != SIZE_MINIMIZED))
            {
                // get renderer identification string
                CEGUI::Renderer* renderer = cegui_system->getRenderer();
                CEGUI::String id(renderer->getIdentifierString());

                // invoke correct function based on the renderer we have ID'd
#ifdef CEGUI_BUILD_RENDERER_DIRECT3D9
                if (id.find("Official Direct3D 9") != id.npos)
                    DeviceReset_Direct3D9(hWnd, renderer);
#endif
#ifdef CEGUI_BUILD_RENDERER_DIRECT3D10
                if (id.find("Official Direct3D 10") != id.npos)
                    DeviceReset_Direct3D10(hWnd, renderer);
#endif
#ifdef CEGUI_BUILD_RENDERER_DIRECT3D11
                if (id.find("Official Direct3D 11") != id.npos)
                    DeviceReset_Direct3D11(hWnd, renderer);
#endif
            }
        }
        break;

    case WM_PAINT:
        {
            HDC         hDC;
            PAINTSTRUCT ps;

            hDC = BeginPaint(hWnd, &ps);
            EndPaint(hWnd, &ps);
            break;
        }

    default:
        return(DefWindowProc(hWnd, message, wParam, lParam));
//.........這裏部分代碼省略.........
開發者ID:LiberatorUSA,項目名稱:GUCEF,代碼行數:101,代碼來源:Win32AppHelper.cpp

示例14: win_proc


//.........這裏部分代碼省略.........
                                break;
                                /////
                    }
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    if(event==BTN_UP && id==ID_CLOSE)
                    {
                    	PostMessage(hwnd,MSG_CLOSE,0,0);
                    }////


                    if(event==BTN_UP && id==ID_RIGHT)
                    {
                    	char *buf;
                    	int i;
                    	i =SendMessage(hwndLB1,LBM_GETCURSEL,0,0);

                    	if(i>=0)
                    	{
                    	     buf =(char*)malloc(SendMessage(hwndLB1,LBM_GETTEXTLEN,i,0));
                    	     if(buf!=NULL)
                    	     {
                    	         SendMessage(hwndLB1,LBM_GETTEXT,i,(u32)buf);
                    	         SendMessage(hwndLB1,LBM_DELSTRING,i,0);

                    	         SendMessage(hwndLB2,LBM_ADDSTRING,-1,(u32)buf);
                    	         i=SendMessage(hwndLB2,LBM_GETCOUNT,0,0)-1;
                    	         SendMessage(hwndLB2,LBM_SETTOPINDEX,i-3,0);
                    	         SendMessage(hwndLB2,LBM_SETCURSEL,-1,0);

                    	         free(buf);
                    	      }
                    	}
                    }////

                    if(event==BTN_UP && id==ID_LEFT)
                    {
                    	char *buf;
                        int i;
                        i =SendMessage(hwndLB2,LBM_GETCURSEL,0,0);
                        if(i>=0)
                        {
                    		buf =(char*)malloc(SendMessage(hwndLB2,LBM_GETTEXTLEN,i,0));
                    		if(buf!=NULL)
                    		{
                    			SendMessage(hwndLB2,LBM_GETTEXT,i,(u32)buf);
                    			SendMessage(hwndLB2,LBM_DELSTRING,i,0);

                    			SendMessage(hwndLB1,LBM_ADDSTRING,-1,(u32)buf);
                    			i=SendMessage(hwndLB1,LBM_GETCOUNT,0,0)-1;
                    			SendMessage(hwndLB1,LBM_SETTOPINDEX,i-3,0);
                    			SendMessage(hwndLB1,LBM_SETCURSEL,-1,0);

                    			free(buf);
                    		}
                         }
                    }////

                    if(event==LBN_SELCHANGE && id==ID_LISTBOX1)
                    {
                    	printf("listbox1 sel change.\r\n");
                    }////

                    if(event==LBN_SELCHANGE && id==ID_LISTBOX2)
                    {
                    	printf("listbox2 sel change.\r\n");
                    }////
                }
                break;
                ////

        case    MSG_PAINT:
                {
                    hdc =BeginPaint(hwnd);

                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(200,200,200));
                    FillRect(hdc,&rc0);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
開發者ID:jiankangshiye,項目名稱:DJYOS,代碼行數:101,代碼來源:gdd_demo_listbox.c

示例15: CreateHypCtrl


//.........這裏部分代碼省略.........
		GetObject(hFontParent, sizeof(LOGFONT), &lf);

		switch (pHcWnd->ulStyle) {
			case ulHover:
				hFontNormal = CreateFontIndirect(&lf);
				lf.lfUnderline = (BYTE) TRUE;
				hFontHover  = CreateFontIndirect(&lf);
				break;
			case ulAlways:
				lf.lfUnderline = (BYTE) TRUE;
				hFontNormal = CreateFontIndirect(&lf);
				hFontHover  = CreateFontIndirect(&lf);
				break;
			case ulNone:
				hFontNormal = CreateFontIndirect(&lf);
				hFontHover  = CreateFontIndirect(&lf);
				break;
			}
			// save the fonts in the window extra space
			SetWindowLong(hWndHyperlink, WND_FONTN, (LONG) hFontNormal);
			SetWindowLong(hWndHyperlink, WND_FONTH, (LONG) hFontHover);
	} else {
		// use the system font
		SetWindowLong(hWndHyperlink, WND_FONTN, (LONG) NULL);
		SetWindowLong(hWndHyperlink, WND_FONTH, (LONG) NULL);
	}

	GetClientRect(hWndHyperlink, &rect);

	// adjust window size to fit the text
	if (pHcWnd->bAutoSize) {
		PAINTSTRUCT ps;
		HDC hdc;
		SIZE size;

		hdc	= BeginPaint(hWndHyperlink, &ps);
 		SelectObject(hdc, (HFONT) GetWindowLong(hWndHyperlink, WND_FONTN));
		GetTextExtentPoint32(hdc, pHcWnd->szText, GetStringLength(pHcWnd->szText), &size);
		rect.right	= size.cx - rect.left;
		rect.bottom	= size.cy - rect.top;
		EndPaint(hWndHyperlink, &ps);

		SetWindowPos(hWndHyperlink,
			0,
			0, 0, size.cx, size.cy,
			SWP_NOMOVE | SWP_NOZORDER);
	}

	// save window size in the window extra space
	SetWindowLong(hWndHyperlink, WND_LEFT, (LONG) (rect.left));
	SetWindowLong(hWndHyperlink, WND_TOP, (LONG) (rect.top));
	SetWindowLong(hWndHyperlink, WND_RIGHT, (LONG) (rect.right));
	SetWindowLong(hWndHyperlink, WND_BOTTOM, (LONG) (rect.bottom));

	// create tooltip if requested
	if (pHcWnd->szTooltip != NULL) {
    	HWND hWndTT;
    	TOOLINFO ti;

    	hWndTT = CreateWindowEx(WS_EX_TOPMOST,
    		TOOLTIPS_CLASS,
    		NULL,
    		WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		CW_USEDEFAULT,
    		hWndHyperlink,
    		NULL,
    		hInst,
    		NULL);
    				
    	if (!hWndTT) return FALSE;

    	SetWindowPos(hWndTT,
    		HWND_TOPMOST,
    		0, 0, 0, 0,
    		SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

    	ti.cbSize      = sizeof(TOOLINFO);
    	ti.uFlags      = TTF_SUBCLASS;
    	ti.hwnd        = hWndHyperlink;
    	ti.hinst       = hInst;
    	ti.uId         = 0;
    	ti.lpszText    = pHcWnd->szTooltip; // get text for tooltip
    	ti.rect.left   = (LONG) GetWindowLong(hWndHyperlink, WND_LEFT);
    	ti.rect.top    = (LONG) GetWindowLong(hWndHyperlink, WND_TOP);
    	ti.rect.right  = (LONG) GetWindowLong(hWndHyperlink, WND_RIGHT);
    	ti.rect.bottom = (LONG) GetWindowLong(hWndHyperlink, WND_BOTTOM);

    	// add tooltip
    	SendMessage(hWndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
	}

	// show the window
	ShowWindow(hWndHyperlink, SW_NORMAL);
	UpdateWindow(hWndHyperlink);

	return hWndHyperlink;
}
開發者ID:469306621,項目名稱:Languages,代碼行數:101,代碼來源:hyperlink.c


注:本文中的BeginPaint函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。