0
나는 현재 지금처럼 내 SFML/C++ 응용 프로그램에서 윈도우 마우스 커서를 변경하고있어 동안 실패에서는 SetCursor()는 때때로 빠른 마우스 움직임
#include <iostream>
#include <SFML/Graphics.hpp>
#include <Windows.h>
int main() {
sf::RenderWindow window;
window.create(sf::VideoMode(1280, 720), "Window", sf::Style::Close);
static int cursorNum = 0;
HCURSOR cursor = LoadCursorFromFile("graphics\\cursors\\cursor.cur");
HCURSOR cursorTarget = LoadCursorFromFile("graphics\\cursors\\cursor-target.cur");
while (window.isOpen()) {
if (window.hasFocus()) {
//...Irrelevant that decides the value of cursorNum...
////Mouse Cursors////
if (sf::IntRect(0, 0, 1280, 720).contains(sf::Mouse::getPosition(window).x, sf::Mouse::getPosition(window).y)) {
switch (cursorNum) {
case 0:
SetCursor(cursor);
SetClassLongPtr(window.getSystemHandle(), GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor));
break;
case 1:
SetCursor(cursorTarget);
SetClassLongPtr(window.getSystemHandle(), GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursorTarget));
break;
}
}
/////////////////////
}
////Clear////
window.clear(sf::Color(30, 0, 30));
/////////////
window.display();
}
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
return 0;
}
나는 빠르게 마우스를 이동할 때이를 제외하고 완벽하게 잘 작동합니다. 내 사용자 정의 마우스 커서 외에도 기본 창 마우스 커서를 볼 수있는 몇 가지 부족한 경우가 있습니다. 왜 이것이 될 수 있을까요?
나는 당신이 무엇을 묘사하는지 잘 모르겠습니다. 답변에 코드 예제를 추가해 주시겠습니까? – TrampolineTales
각 창은 [WindowProc 콜백] (https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx)을 통해 메시지를받습니다. 시스템이 커서를 업데이트하려고 할 때 커서를 즉시 업데이트하려면 처리해야하는 'WM_SETCURSOR' 알림을 보냅니다. 'WindowProc'은 SFML의 어딘가에있을 수 있으므로 시스템 커서를 숨기고 직접 그릴 필요가 있습니다. – VTT