BOOL OnSetCursor( HWND hWnd, LPARAM lParam ) { // HCURSOR hRect = LoadCursor( g_hInstance, // MAKEINTRESOURCE(IDC_CURSOR1) ); // HCURSOR hBall = LoadCursor( g_hInstance, // MAKEINTRESOURCE(IDC_CURSOR2) ); HCURSOR hRect = LoadCursorFromFile( "c:/windows/Cursors/dinosaur.ani" ); HCURSOR hBall = LoadCursorFromFile( "c:/windows/Cursors/dinosau2.ani" ); if( LOWORD(lParam) == HTCLIENT ) { POINT pt = { 0 }; GetCursorPos( &pt ); ScreenToClient( hWnd, &pt ); RECT rc = { 0 }; GetClientRect( hWnd, &rc ); if( pt.x <= rc.right/2 ) { SetCursor( hBall ); }else{ SetCursor( hRect ); } return TRUE; } return FALSE; }
//--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { try { AnsiString CursorFile = ExtractFilePath(Application->ExeName) + "Images\\move.cur"; HCURSOR hCursor = LoadCursorFromFile(CursorFile.c_str()); if(hCursor) Screen->Cursors[crDrag] = hCursor; } catch(...) { } AnsiString sCmd = ParamStr(0); //current program AnsiString sExt = ".cpf"; TExtInfo *inf; try { inf = Reg1->GetExtInfo(sExt); if (inf->ExecutePath != "\"" + ParamStr(0) + "\" \"%1\"") RegisterExt(); } catch(...) { RegisterExt(); } NewClientWP = (FARPROC)MakeObjectInstance(MDIClientWndProc); // Bg additions OldClientWP = (FARPROC)SetWindowLong(ClientHandle, GWL_WNDPROC, (LONG)NewClientWP); }
void WindowsHelper::Refresh() { if(!cursorOverride) { activeCursor = LoadCursorFromFile("aero_arrow.cur"); } cursorOverride = false; }
bool SPInputManager::SetCursor( SPString path ) { SPFilePtr file = SPFileManager::GetSingleton().OpenFile(path); if (!file) { return false; } LONGLONG length = file->GetFileLength(); char* pData = new char[length]; file->Read(pData, length); wchar_t tname[10]; _wtmpnam_s(tname, 10); SPString name = SPString(tname);// + path.substr(path.find_last_of(L".") + 1); HANDLE newFile = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (newFile == INVALID_HANDLE_VALUE) { return false; } DWORD numOfByte; if(FALSE == WriteFile(newFile, pData, length, &numOfByte, NULL)) { delete [] pData; SPFileManager::GetSingleton().CloseFile(path); CloseHandle(newFile); DeleteFile(name.c_str()); return false; } CloseHandle(newFile); HCURSOR cursor = LoadCursorFromFile(name.c_str()); if (!cursor) { DWORD err = GetLastError(); delete [] pData; SPFileManager::GetSingleton().CloseFile(path); CloseHandle(newFile); DeleteFile(name.c_str()); return false; } SPWindow::GetSingleton().SetCursor(cursor); DeleteFile(name.c_str()); delete [] pData; SPFileManager::GetSingleton().CloseFile(path); //CloseHandle(newFile); return true; }
//窗口处理函数(处理消息) LRESULT CALLBACK WndProc( HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam ) { switch( msgID ) { case WM_SETCURSOR: { // HCURSOR hRec = LoadCursor( g_hInstance, // MAKEINTRESOURCE(IDC_CURSOR1)); // HCURSOR hBall = LoadCursor( g_hInstance, // MAKEINTRESOURCE(IDC_CURSOR2)); HCURSOR hRec = LoadCursorFromFile( "c:/windows/Cursors/dinosau2.ani" ); HCURSOR hBall = LoadCursorFromFile( "c:/windows/Cursors/dinosaur.ani" ); if( LOWORD(lParam)==HTCLIENT ) { POINT pt = { 0 }; GetCursorPos( &pt );//屏幕坐标系(光标位置) ScreenToClient( hWnd, &pt );//转换坐标 RECT rc = { 0 }; GetClientRect(hWnd,&rc);//客户区坐标系(边界信息) if( pt.x <= rc.right/2 ) SetCursor( hBall ); else SetCursor( hRec ); return 0; }else{ //什么都不写 } } break; case WM_PAINT: OnPaint( hWnd ); break; case WM_COMMAND: OnCommand( hWnd, wParam ); break; case WM_DESTROY: PostQuitMessage( 0 );//可以使GetMessage返回0?? break; } return DefWindowProc( hWnd, msgID, wParam, lParam ); //给各种消息做默认处理 }
/** \param mouseX X-Coordinate of the mouse. \param mouseY Y-Coordinate of the mouse. \param lClick true if the left mouse button was clicked, false otherwise. */ void Inventory::QueryInventory(long mouseX, long mouseY, bool lClick) { // if in script, then we do not need to worry about input. if(GetInScript()) { UpdateScript(mouseX, mouseY, lClick); return; } for(std::list<Object>::iterator iObject = objectList.begin(); iObject != objectList.end(); iObject++) { // Check if the mouse is hovering over an object. if((*iObject).CheckMouseCollision(mouseX, mouseY)) { // if so, we need to render the descriptor. if(pParent->GetCurrentlyHeldItem() == 0) { SetCursor(LoadCursorFromFile("Data\\red-cursor.cur")); } curMouseObject = (*iObject).GetDescriptor(); if(lClick) { SetCurActionObject(&(*iObject)); if(pParent->GetCurrentlyHeldItem() != 0) { (*iObject).UseItem(pParent->GetCurrentlyHeldItem()->GetName(), pParser); SetInScript(true); } else if(GetGlobalAction() == IS_USE) { stringstream cursorFile; cursorFile << "Data\\" << (*iObject).GetName() << ".cur"; SetCursor(LoadCursorFromFile((char*)cursorFile.str().c_str())); pParent->SetCurrentlyHeldItem(&(*iObject)); } else { // If the user also clicked on this object, then we need to process a script. if((*iObject).DoAction(GetGlobalAction(), pParser)) { // We are now in script. SetInScript(true); } } return; } return; } curMouseObject.clear(); // otherwise, there is no current object. } }
Window::Window(const string& title, U32 width, U32 height) { U32 styleFlags = WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;// | WS_THICKFRAME; AdjustWindowSize(styleFlags, &width, &height); this->width = width; this->height = height; isClosed = false; isMinimized = false; isInactive = false; HINSTANCE instanceHandle = (HINSTANCE)GetModuleHandle(NULL); WNDCLASS wc; wc.style = CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC) Window::StaticWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = instanceHandle; wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hCursor = LoadCursorFromFile("..//Data//Cursors//arrow.cur"); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = "MainWinWindowClass"; if (!RegisterClass(&wc)) { throw WinException(GetLastError()); } // Create window instance handle = CreateWindow("MainWinWindowClass", // Registered WNDCLASS instance to use. title.c_str(), // window title styleFlags, // style flags CW_USEDEFAULT, // x-coordinate CW_USEDEFAULT, // y-coordinate width, // width height, // height 0, // parent window 0, // menu handle instanceHandle, // app instance 0); if (!handle) { throw WinException(GetLastError()); } SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)this); // Show window ShowWindow(handle, true); UpdateWindow(handle); }
static int load_cursor (int cli, int clifd, void* buff, size_t len) { HCURSOR hcsr; hcsr = LoadCursorFromFile (buff); #ifdef _MGHAVE_CURSOR if (hcsr) { add_global_res (cli, (void*) hcsr, (void*)hcsr, (ReleaseProc)DestroyCursor); } #endif return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR)); }
void Win32CursorController::setCursorShape( const UTF8 *fileName, bool reload ) { #ifdef UNICODE const UTF16 *lFileName = convertUTF8toUTF16( fileName ); #else const UTF8 *lFileName = fileName; #endif if ( !gCursorShape || reload ) gCursorShape = LoadCursorFromFile( lFileName ); if ( gCursorShape ) SetCursor( gCursorShape ); }
MoonChildApp::MoonChildApp(void) { _AppState = MAINMENU; char ch[256]; GetPrivateProfileString("scene","scene","default",ch,256,"./start.cfg"); _scnname = ch; m_strWindowTitle = "UnrealWorld"; m_strWindowTitle += " SceneName: "; m_strWindowTitle += ch; _normalCursor = LoadCursorFromFile("../media/cursors/normal.ani"); the3DText = NULL; theScene = NULL; _StartPanel = NULL; _LoadingPanel = NULL; }
// 커서를 변경하기 위해 나오는 메세지. BOOL CMainFrame::OnSetCursor(CWnd *pWnd, // 커서 아래 있는 윈도우 UINT nHit, // hit Test code UINT msg) { if ( nHit == HTCAPTION ) // hit test code -> 현재 커서의 위치 { //SetCursor( AfxGetApp()->LoadCursor(IDC_CURSOR1) ); // Animation Cursor 사용하기. API 함수. HCURSOR h = LoadCursorFromFile("C:\\winnt\\cursors\\banana.ani"); SetCursor( h ); return TRUE; // 커서를 바꾼경우. } // 커서를 바꾸지 않은 경우는 반드시 부모에게 보낸다. // 그러면 부모가 default 값으로 바꾸어 준다. return CFrameWnd::OnSetCursor(pWnd, nHit, msg ); }
// // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage are only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; // could use 0 too for no icon wcex.hCursor = LoadCursorFromFile(L"cursor.cur"); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; // no menu in use wcex.lpszClassName = szWindowClass; wcex.hIconSm = 0; // no small icon either return RegisterClassEx(&wcex); }
BOOL I4C3DCursor::SetTransparentCursor(LPCTSTR szFilePath) { HCURSOR hCursor = NULL; hCursor = LoadCursorFromFile(szFilePath); if (hCursor == NULL) { LoggingMessage(Log_Error, _T(MESSAGE_ERROR_CURSOR_MISSING), GetLastError(), g_FILE, __LINE__); return FALSE; } if (SetSystemCursor(hCursor, 32512)) { return TRUE; } else { RestoreCursor(); } DestroyCursor(hCursor); // 現在使用中のカーソルはDestroyすることはできない。 return FALSE; }
static VALUE swincursor_load(VALUE klass,VALUE fname){ struct SwinCursor* sc; VALUE robj; TCHAR pathbuffer[MYMAXPATH*2*sizeof(TCHAR)]; robj = Data_Make_Struct(cSwinCursor,struct SwinCursor,0,release_cursor,sc); sc->sysflag=FALSE; sc->hotspot=0; path_conv_to_win(SWIN_API_STR_PTR(fname),pathbuffer); sc->hcursor=LoadCursorFromFile(pathbuffer); if(sc->hcursor==NULL){ rb_raise(rb_eRuntimeError,"fail to create cursor"); return Qfalse; } sc->shared = TRUE; return robj; }
bool DBBitmapHelper::IsButtonClicked(int buttonID) { int mouseX = dbMouseX(); int mouseY = dbMouseY(); int width = dbSpriteWidth(buttonID); int height = dbSpriteHeight(buttonID); int x = dbSpriteX(buttonID); int y = dbSpriteY(buttonID); bool result = false; bool inButtonArea = false; if (mouseX > x && mouseX < (x + width)) { if (mouseY > y && mouseY < (y + height)) { inButtonArea = true; // The mouse is inside the button. // Now check for mouse clicks. if(dbMouseClick()==1) { //WindowsHelper::SetActiveCursor(LoadCursorFromFile("aero_arrow.cur")); return true; } } } if(inButtonArea) { WindowsHelper::SetActiveCursor(LoadCursorFromFile("aero_link.cur")); } //else //{ // WindowsHelper::SetActiveCursor(LoadCursorFromFile("aero_arrow.cur")); //} return false; }
void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWindow* meterWindow) { DestroyCustomCursor(); m_LeftDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"", false); m_RightDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false); m_MiddleDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"", false); m_X1DownAction = parser.ReadString(section, L"X1MouseDownAction", L"", false); m_X2DownAction = parser.ReadString(section, L"X2MouseDownAction", L"", false); m_LeftUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"", false); m_RightUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false); m_MiddleUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"", false); m_X1UpAction = parser.ReadString(section, L"X1MouseUpAction", L"", false); m_X2UpAction = parser.ReadString(section, L"X2MouseUpAction", L"", false); m_LeftDoubleClickAction = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false); m_RightDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false); m_MiddleDoubleClickAction = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false); m_X1DoubleClickAction = parser.ReadString(section, L"X1MouseDoubleClickAction", L"", false); m_X2DoubleClickAction = parser.ReadString(section, L"X2MouseDoubleClickAction", L"", false); m_OverAction = parser.ReadString(section, L"MouseOverAction", L"", false); m_LeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false); m_MouseScrollDownAction = parser.ReadString(section, L"MouseScrollDownAction", L"", false); m_MouseScrollUpAction = parser.ReadString(section, L"MouseScrollUpAction", L"", false); m_MouseScrollLeftAction = parser.ReadString(section, L"MouseScrollLeftAction", L"", false); m_MouseScrollRightAction = parser.ReadString(section, L"MouseScrollRightAction", L"", false); if (!m_MouseScrollDownAction.empty() || !m_MouseScrollUpAction.empty() || !m_MouseScrollLeftAction.empty() || !m_MouseScrollRightAction.empty()) { meterWindow->SetHasMouseScrollAction(); } const bool defaultState = (section == L"Rainmeter") ? true : meterWindow->GetMouse().GetCursorState(); m_CursorState = 0!=parser.ReadInt(section, L"MouseActionCursor", defaultState); const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L""; const WCHAR* mouseCursor = parser.ReadString(section, L"MouseActionCursorName", defaultMouseCursor).c_str(); if (_wcsicmp(mouseCursor, L"HAND") == 0) { m_CursorType = MOUSECURSOR_HAND; } else if (_wcsicmp(mouseCursor, L"TEXT") == 0) { m_CursorType = MOUSECURSOR_TEXT; } else if (_wcsicmp(mouseCursor, L"HELP") == 0) { m_CursorType = MOUSECURSOR_HELP; } else if (_wcsicmp(mouseCursor, L"BUSY") == 0) { m_CursorType = MOUSECURSOR_BUSY; } else if (_wcsicmp(mouseCursor, L"CROSS") == 0) { m_CursorType = MOUSECURSOR_CROSS; } else if (_wcsicmp(mouseCursor, L"PEN") == 0) { m_CursorType = MOUSECURSOR_PEN; } else if (wcschr(mouseCursor, L'.')) { m_CursorType = MOUSECURSOR_CUSTOM; } else { // Inherit from [Rainmeter]. m_CursorType = meterWindow->GetMouse().GetCursorType(); if (m_CursorType == MOUSECURSOR_CUSTOM) { mouseCursor = meterWindow->GetParser().ReadString(L"Rainmeter", L"MouseActionCursorName", L"").c_str(); } } if (m_CursorType == MOUSECURSOR_CUSTOM) { std::wstring cursorPath = meterWindow->GetResourcesPath(); cursorPath += L"Cursors\\"; cursorPath += mouseCursor; m_CustomCursor = LoadCursorFromFile(cursorPath.c_str()); if (!m_CustomCursor) { m_CursorType = MOUSECURSOR_ARROW; LogWithArgs(LOG_ERROR, L"Invalid cursor: %s", cursorPath.c_str()); } } }
void Mouse::ReadOptions(ConfigParser& parser, const WCHAR* section) { DestroyCustomCursor(); m_MouseActions[MOUSE_LMB_UP].action = parser.ReadString(section, L"LeftMouseUpAction", L"", false); m_MouseActions[MOUSE_LMB_DOWN].action = parser.ReadString(section, L"LeftMouseDownAction", L"", false); m_MouseActions[MOUSE_LMB_DBLCLK].action = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false); m_MouseActions[MOUSE_MMB_UP].action = parser.ReadString(section, L"MiddleMouseUpAction", L"", false); m_MouseActions[MOUSE_MMB_DOWN].action = parser.ReadString(section, L"MiddleMouseDownAction", L"", false); m_MouseActions[MOUSE_MMB_DBLCLK].action = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false); m_MouseActions[MOUSE_RMB_UP].action = parser.ReadString(section, L"RightMouseUpAction", L"", false); m_MouseActions[MOUSE_RMB_DOWN].action = parser.ReadString(section, L"RightMouseDownAction", L"", false); m_MouseActions[MOUSE_RMB_DBLCLK].action = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false); m_MouseActions[MOUSE_X1MB_UP].action = parser.ReadString(section, L"X1MouseUpAction", L"", false); m_MouseActions[MOUSE_X1MB_DOWN].action = parser.ReadString(section, L"X1MouseDownAction", L"", false); m_MouseActions[MOUSE_X1MB_DBLCLK].action = parser.ReadString(section, L"X1MouseDoubleClickAction", L"", false); m_MouseActions[MOUSE_X2MB_UP].action = parser.ReadString(section, L"X2MouseUpAction", L"", false); m_MouseActions[MOUSE_X2MB_DOWN].action = parser.ReadString(section, L"X2MouseDownAction", L"", false); m_MouseActions[MOUSE_X2MB_DBLCLK].action = parser.ReadString(section, L"X2MouseDoubleClickAction", L"", false); m_MouseActions[MOUSE_MW_UP].action = parser.ReadString(section, L"MouseScrollUpAction", L"", false); m_MouseActions[MOUSE_MW_DOWN].action = parser.ReadString(section, L"MouseScrollDownAction", L"", false); m_MouseActions[MOUSE_MW_LEFT].action = parser.ReadString(section, L"MouseScrollLeftAction", L"", false); m_MouseActions[MOUSE_MW_RIGHT].action = parser.ReadString(section, L"MouseScrollRightAction", L"", false); m_MouseActions[MOUSE_OVER].action = parser.ReadString(section, L"MouseOverAction", L"", false); m_MouseActions[MOUSE_LEAVE].action = parser.ReadString(section, L"MouseLeaveAction", L"", false); if (HasScrollAction()) { m_Skin->SetHasMouseScrollAction(); } const bool defaultState = (section == L"Rainmeter") ? true : m_Skin->GetMouse().GetCursorState(); m_CursorState = parser.ReadBool(section, L"MouseActionCursor", defaultState); const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L""; const WCHAR* mouseCursor = parser.ReadString(section, L"MouseActionCursorName", defaultMouseCursor).c_str(); auto inheritSkinDefault = [&]() { // Inherit from [Rainmeter]. m_CursorType = m_Skin->GetMouse().GetCursorType(); if (m_CursorType == MOUSECURSOR_CUSTOM) { mouseCursor = m_Skin->GetParser().ReadString(L"Rainmeter", L"MouseActionCursorName", L"").c_str(); } }; if (*mouseCursor == L'\0') // meters' default { inheritSkinDefault(); } else if (_wcsicmp(mouseCursor, L"HAND") == 0) // skin's default { m_CursorType = MOUSECURSOR_HAND; } else if (_wcsicmp(mouseCursor, L"TEXT") == 0) { m_CursorType = MOUSECURSOR_TEXT; } else if (_wcsicmp(mouseCursor, L"HELP") == 0) { m_CursorType = MOUSECURSOR_HELP; } else if (_wcsicmp(mouseCursor, L"BUSY") == 0) { m_CursorType = MOUSECURSOR_BUSY; } else if (_wcsicmp(mouseCursor, L"CROSS") == 0) { m_CursorType = MOUSECURSOR_CROSS; } else if (_wcsicmp(mouseCursor, L"PEN") == 0) { m_CursorType = MOUSECURSOR_PEN; } else if (wcschr(mouseCursor, L'.')) { m_CursorType = MOUSECURSOR_CUSTOM; } else { inheritSkinDefault(); } if (m_CursorType == MOUSECURSOR_CUSTOM) { std::wstring cursorPath = m_Skin->GetResourcesPath(); cursorPath += L"Cursors\\"; cursorPath += mouseCursor; m_CustomCursor = LoadCursorFromFile(cursorPath.c_str()); if (!m_CustomCursor) { m_CursorType = MOUSECURSOR_ARROW; LogErrorF(m_Skin, L"Invalid cursor: %s", cursorPath.c_str()); } } }
#include <Tetris.h> HCURSOR WindowsHelper::activeCursor = LoadCursorFromFile("aero_arrow.cur"); bool WindowsHelper::cursorOverride = false; void WindowsHelper::SetActiveCursor(HCURSOR cursor) { cursorOverride = true; activeCursor = cursor; } HCURSOR WindowsHelper::GetActiveCursor() { return activeCursor; } void WindowsHelper::Refresh() { if(!cursorOverride) { activeCursor = LoadCursorFromFile("aero_arrow.cur"); } cursorOverride = false; }
BOOL StartUpAnimation::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_hCursor = LoadCursorFromFile(_T("./resource/ani/normal.cur")); if (NULL == m_hCursor) { MessageBox("资源文件无法打开,请检查程序所在的路径是否正确?"); exit(-1); } m_selectBtnCur = LoadCursorFromFile(_T("./resource/ani/onSelectBtn.ani")); SetWindowPos(this, 0,0, SCREEN_WIDTH, SCREEN_HEIGHT, SWP_NOZORDER); CenterWindow(this); SetWindowEllispeFrame(this->GetSafeHwnd(), 20, 20); // 窗口边角圆弧 // minSizeBtn.SetWindowPos(NULL, 4, 0, 32, 32, SWP_SHOWWINDOW); cancelBtn.SetWindowPos(NULL, SCREEN_WIDTH-42, 0, 32, 32, SWP_SHOWWINDOW); m_aboutBtn.SetWindowPos(NULL, SCREEN_WIDTH - 74, 0, 32, 32, SWP_SHOWWINDOW); toTrayBtn.SetWindowPos(NULL, SCREEN_WIDTH - 108, 0, 32, 32, SWP_SHOWWINDOW); int width = 250; int hight = 70; int py = 180; m_computerBtn.SetWindowPos(NULL, 380, py, width, hight, SWP_SHOWWINDOW); py += 70; m_singleBtn.SetWindowPos(NULL, 380, py, width, hight, SWP_SHOWWINDOW); py += 70; m_networdBtn.SetWindowPos(NULL, 380, py, width, hight, SWP_SHOWWINDOW); py += 70; m_settingBtn.SetWindowPos(NULL, 380, py, width, hight, SWP_SHOWWINDOW); py += 70; m_exitBtn.SetWindowPos(NULL, 380, py, width, hight, SWP_SHOWWINDOW); m_aboutBtn.SetIcon(IDI_ICO_ABOUT, (int)BTNST_AUTO_GRAY); m_aboutBtn.DrawTransparent(FALSE); m_aboutBtn.SetWindowText(""); m_aboutBtn.SetTooltipText("关于"); // minSizeBtn.SetIcon(IDI_MIN_SIZE); // minSizeBtn.DrawTransparent(FALSE); // minSizeBtn.SetTooltipText("最小化"); // minSizeBtn.SetWindowText(""); minSizeBtn.ShowWindow(SW_HIDE); toTrayBtn.SetIcon(IDI_TOTRAY, IDI_ICON_XU); // toTrayBtn.DrawBorder(FALSE); toTrayBtn.DrawTransparent(FALSE); toTrayBtn.SetWindowText(""); toTrayBtn.SetTooltipText("最小化到托盘"); cancelBtn.SetIcon(IDI_ICON_EXIT, (int)BTNST_AUTO_GRAY); // cancelBtn.DrawBorder(FALSE); cancelBtn.DrawTransparent(FALSE); cancelBtn.SetTooltipText("退出"); cancelBtn.SetWindowText(""); cpicBg.loadBmpFromFile(_T("./resource/bg/theme_gray/select_mode_bg.bmp")); // 加载游戏模式选择界面上的按钮bmp HBITMAP hBmp, hBmpIn = NULL; COLORREF maskColor = RGB(90, 90, 90); hBmpIn = getBmpImg(CString("./resource/buttons/theme_gray/vsComputerLight.bmp")); hBmp = getBmpImg(computerPath); if (hBmp && hBmpIn) { m_computerBtn.SetBitmaps(hBmpIn, maskColor, hBmp, maskColor); m_computerBtn.SetWindowText(""); // m_computerBtn.DrawBorder(FALSE); m_computerBtn.DrawTransparent(FALSE); } hBmp = getBmpImg(singlePath); hBmpIn = getBmpImg(CString("./resource/buttons/theme_gray/p2pLight.bmp")); if (hBmp && hBmpIn) { m_singleBtn.SetBitmaps(hBmpIn, maskColor, hBmp, maskColor); m_singleBtn.SetWindowText(""); // m_singleBtn.DrawBorder(FALSE); m_singleBtn.DrawTransparent(FALSE); } hBmp = getBmpImg(networdPath); hBmpIn = getBmpImg(CString("./resource/buttons/theme_gray/vsNetwordLight.bmp")); if (hBmp && hBmpIn) { m_networdBtn.SetBitmaps(hBmpIn, maskColor, hBmp, maskColor); m_networdBtn.SetWindowText(""); // m_networdBtn.DrawBorder(FALSE); m_networdBtn.DrawTransparent(FALSE); } hBmp = getBmpImg(settingPath); hBmpIn = getBmpImg(CString("./resource/buttons/theme_gray/gameConfigLight.bmp")); if (hBmp) { m_settingBtn.SetBitmaps(hBmpIn, maskColor, hBmp, maskColor); m_settingBtn.SetWindowText(""); // m_settingBtn.DrawBorder(FALSE); m_settingBtn.DrawTransparent(FALSE); } hBmp = getBmpImg(exitPath); hBmpIn = getBmpImg(CString("./resource/buttons/theme_gray/exitGameLight.bmp")); if (hBmp) { m_exitBtn.SetBitmaps(hBmpIn, maskColor, hBmp, maskColor); m_exitBtn.SetWindowText(""); // m_exitBtn.DrawBorder(FALSE); m_exitBtn.DrawTransparent(FALSE); } m_singleBtn.SetPlaySound(true, "IDR_HVER"); m_computerBtn.SetPlaySound(true, "IDR_HVER"); m_networdBtn.SetPlaySound(true, "IDR_HVER"); m_settingBtn.SetPlaySound(true, "IDR_HVER"); m_exitBtn.SetPlaySound(true, "IDR_HVER"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
FWindowsCursor::FWindowsCursor() { // Load up cursors that we'll be using for( int32 CurCursorIndex = 0; CurCursorIndex < EMouseCursor::TotalCursorCount; ++CurCursorIndex ) { CursorHandles[ CurCursorIndex ] = NULL; HCURSOR CursorHandle = NULL; switch( CurCursorIndex ) { case EMouseCursor::None: case EMouseCursor::Custom: // The mouse cursor will not be visible when None is used break; case EMouseCursor::Default: CursorHandle = ::LoadCursor( NULL, IDC_ARROW ); break; case EMouseCursor::TextEditBeam: CursorHandle = ::LoadCursor( NULL, IDC_IBEAM ); break; case EMouseCursor::ResizeLeftRight: CursorHandle = ::LoadCursor( NULL, IDC_SIZEWE ); break; case EMouseCursor::ResizeUpDown: CursorHandle = ::LoadCursor( NULL, IDC_SIZENS ); break; case EMouseCursor::ResizeSouthEast: CursorHandle = ::LoadCursor( NULL, IDC_SIZENWSE ); break; case EMouseCursor::ResizeSouthWest: CursorHandle = ::LoadCursor( NULL, IDC_SIZENESW ); break; case EMouseCursor::CardinalCross: CursorHandle = ::LoadCursor(NULL, IDC_SIZEALL); break; case EMouseCursor::Crosshairs: CursorHandle = ::LoadCursor( NULL, IDC_CROSS ); break; case EMouseCursor::Hand: CursorHandle = ::LoadCursor( NULL, IDC_HAND ); break; case EMouseCursor::GrabHand: CursorHandle = LoadCursorFromFile((LPCTSTR)*(FString( FPlatformProcess::BaseDir() ) / FString::Printf( TEXT("%sEditor/Slate/Cursor/grabhand.cur"), *FPaths::EngineContentDir() ))); if (CursorHandle == NULL) { // Failed to load file, fall back CursorHandle = ::LoadCursor( NULL, IDC_HAND ); } break; case EMouseCursor::GrabHandClosed: CursorHandle = LoadCursorFromFile((LPCTSTR)*(FString( FPlatformProcess::BaseDir() ) / FString::Printf( TEXT("%sEditor/Slate/Cursor/grabhand_closed.cur"), *FPaths::EngineContentDir() ))); if (CursorHandle == NULL) { // Failed to load file, fall back CursorHandle = ::LoadCursor( NULL, IDC_HAND ); } break; case EMouseCursor::SlashedCircle: CursorHandle = ::LoadCursor(NULL, IDC_NO); break; case EMouseCursor::EyeDropper: CursorHandle = LoadCursorFromFile((LPCTSTR)*(FString( FPlatformProcess::BaseDir() ) / FString::Printf( TEXT("%sEditor/Slate/Icons/eyedropper.cur"), *FPaths::EngineContentDir() ))); break; // NOTE: For custom app cursors, use: // CursorHandle = ::LoadCursor( InstanceHandle, (LPCWSTR)MY_RESOURCE_ID ); default: // Unrecognized cursor type! check( 0 ); break; } CursorHandles[ CurCursorIndex ] = CursorHandle; } // Set the default cursor SetType( EMouseCursor::Default ); ClipRect.left = ClipRect.right = ClipRect.top = ClipRect.bottom = -1; }
#define WM_SOCKET 104 #define MAX_LOADSTRING 100 #ifdef _DEBUG #define new new( _CLIENT_BLOCK, __FILE__, __LINE__ ) #endif // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name RECT g_ClientRect; // window client size CSceneManager* g_Manager; HCURSOR bbCursor = LoadCursorFromFile(L"Resource/Image/update/cursor.cur"); // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // 콘솔창 생성
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, INT) { WNDCLASSEX wc = { sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0,0, GetModuleHandle(NULL),NULL,NULL,NULL,NULL, L"Sneaky Ropes",NULL }; //wc.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_APPICON16), IMAGE_ICON, 16, 16, 0); //wc.hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_APPICON32), IMAGE_ICON, 32, 32, 0); //wc.hCursor = LoadCursor(NULL, IDC_ARROW); cursor1 = LoadCursorFromFile(L"cursor1.cur"); SetCursor(cursor1); RegisterClassEx(&wc); RECT wr; wr.left = 160; wr.right = 1600 + wr.left; wr.top = 90; wr.bottom = 900 + wr.top; AdjustWindowRect(&wr, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE); HWND hWnd = CreateWindowW(L"Sneaky Ropes", L"Sneaky Ropes", (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX), wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, NULL, NULL, wc.hInstance, NULL); ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); if (!hWnd) return -1; graphics = new Graphics(); if (!graphics->Init(hWnd)) { delete graphics; return -1; } GameLevel::Init(graphics); ShowWindow(hWnd, SW_SHOWDEFAULT); //UpdateWindow(hWnd); nowyKoniec = false; GameStateChanged = false; CurrentLevel = 0; GameController::LoadInitalLevel(gameLevel = new LevelMainMenu(kServ, mServ)); MSG msg; ZeroMemory(&msg, sizeof(msg)); while (msg.message != WM_QUIT) { //SetCursor(cursor1); if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { GameController::Update(); graphics->BeginDraw(); GameController::Render(); graphics->EndDraw(); if (GameStateChanged) { GameStateChanged = false; switch (g_GameState) { case GS_LevelMainMenu: // 0 GameController::SwitchLevel(gameLevel = new LevelMainMenu(kServ, mServ)); break; case GS_LevelMenuSaves: // 1 GameController::SwitchLevel(gameLevel = new LevelMenuSaves(kServ, mServ)); break; case GS_LevelMenuCharacters: // 2 GameController::SwitchLevel(gameLevel = new LevelMenuCharacters(kServ, mServ)); break; case GS_LevelStandard: // 3 GameController::SwitchLevel(gameLevel = new LevelStandard(kServ, mServ, CurrentLevel)); break; case GS_LevelCity: // 4 GameController::SwitchLevel(gameLevel = new LevelCity(kServ, mServ, CurrentLevel)); break; } } } if (nowyKoniec) { delete graphics; UnregisterClass(L"Sneaky Ropes", wc.hInstance); return 0; } } delete graphics; UnregisterClass(L"Sneaky Ropes", wc.hInstance); return 0; }
TkCursor * TkGetCursorByName( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which cursor will be used. */ Tk_Uid string) /* Description of cursor. See manual entry for * details on legal syntax. */ { struct CursorName *namePtr; TkWinCursor *cursorPtr; int argc; CONST char **argv = NULL; /* * All cursor names are valid lists of one element (for * Unix-compatability), even unadorned system cursor names. */ if (Tcl_SplitList(interp, string, &argc, &argv) != TCL_OK) { return NULL; } if (argc == 0) { goto badCursorSpec; } cursorPtr = (TkWinCursor *) ckalloc(sizeof(TkWinCursor)); cursorPtr->info.cursor = (Tk_Cursor) cursorPtr; cursorPtr->winCursor = NULL; cursorPtr->system = 0; if (argv[0][0] == '@') { /* * Check for system cursor of type @<filename>, where only the name is * allowed. This accepts any of: * -cursor @/winnt/cursors/globe.ani * -cursor @C:/Winnt/cursors/E_arrow.cur * -cursor {@C:/Program\ Files/Cursors/bart.ani} * -cursor {{@C:/Program Files/Cursors/bart.ani}} * -cursor [list @[file join "C:/Program Files" Cursors bart.ani]] */ if (Tcl_IsSafe(interp)) { Tcl_AppendResult(interp, "can't get cursor from a file in", " a safe interpreter", NULL); ckfree((char *) argv); ckfree((char *) cursorPtr); return NULL; } cursorPtr->winCursor = LoadCursorFromFile(&(argv[0][1])); } else { /* * Check for the cursor in the system cursor set. */ for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) { if (strcmp(namePtr->name, argv[0]) == 0) { cursorPtr->winCursor = LoadCursor(NULL, namePtr->id); break; } } if (cursorPtr->winCursor == NULL) { /* * Hmm, it is not in the system cursor set. Check to see if it is * one of our application resources. */ cursorPtr->winCursor = LoadCursor(Tk_GetHINSTANCE(), argv[0]); } else { cursorPtr->system = 1; } } if (cursorPtr->winCursor == NULL) { ckfree((char *) cursorPtr); badCursorSpec: ckfree((char *) argv); Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); return NULL; } else { ckfree((char *) argv); return (TkCursor *) cursorPtr; } }
/* GameWindow - This constructor creates a EG Windows window. All drawing in future examples will use such a window, inside of which we will do drawing using DirectX. After making the window it displays it. */ WindowsGameOS::WindowsGameOS(HINSTANCE hInstance, int nCmdShow, bool isFullscreen, wchar_t *initApplicationName, Game *initGame) { game = initGame; // THIS WILL BE THE TITLE FOR THE WINDOW applicationName = initApplicationName; // WINDOWS CAN EITHER BE IN WINDOWED MODE, MEANING // THE WINDOW PLAYS NICELY WITH OTHER APPLICATIONS // AND CAN BE RESIZED, MINIMIZED, MAXIMIZED, ETC., // OR IT CAN BE IN FULLSCREEN MODE, IN WHICH CASE // IT LIKES TO HOG RESOURCES AND CANNOT BE RESIZED. // GAMES IN FULL SCREEN MODE GET MORE OF THE SYSTEM // RESOURCES, BUT CAN ONLY SWITCH TO ANOTHER // APPLICATION VIA EITHER ALT-TAB, OR BY CLOSING // THE APPLICATION VIA SOME GAME CONTROL (i.e. BUTTON). long initStyle; if (isFullscreen) initStyle = fullscreenStyle; else initStyle = windowedStyle; // WE'LL EGIZE THIS STRUCTURE TO CREATE OUR // OWN WINDOW CLASS WNDCLASSEX wc; // EMPTY THE wc STRUCTURE ZeroMemory(&wc, sizeof(WNDCLASSEX)); // FILL IN THE wc VARIABLES TO CREATE // OUR OWN WINDOW TYPE wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; // MESSAGE RELAYING METHOD, WE DEFINE OUR OWN // WinProc BELOW. NOTE THAT THIS METHOD DOESN'T // HAVE TO BE NAMED WinProc, BUT THAT IS THE // COMMON PRACTICE wc.lpfnWndProc = (WNDPROC)WinProc; // APPLICATION HANDLE wc.hInstance = hInstance; // WE'LL DEAL WITH THE CURSOR ELSEWHERE wc.hCursor = NULL; // NAME DOESN'T MATTER AS LONG AS WE USE THE SAME // NAME WHEN WE CALL CreateWindowEx wc.lpszClassName = L"GameWindowClass"; // REGISTER OUR NEW wc WINDOW TYPE RegisterClassEx(&wc); // USE THE CreateWindowEx FACTORY METHOD TO CREATE // AN INSTANCE OF OUR OWN EG WINDOW TYPE. THIS // METHOD RETURNS A HANDLE TO OUR WINDOW, WHICH // WE WILL NEED TO CREATE OTHER OBJECTS, LIKE A // DirectX GRAPHICS DEVICE windowHandle = CreateWindowEx(NULL, L"GameWindowClass", // OUR WINDOW CLASS TYPE applicationName, // WINDOW TITLE initStyle, // FULLSCREEN or WINDOWED? 0, 0, // WINDOW LOCATION DEFAULT_SCREEN_WIDTH, // WINDOW WIDTH DEFAULT_SCREEN_HEIGHT, // WINDOW HEIGHT NULL, // NO PARENT WINDOW NULL, // NO MENUS hInstance, // APPLICATION HANDLE NULL); // NO MULTIPLE WINDOWS // LOAD THE BLANK CURSOR FILE LPCWSTR LcursorName = L"BlankCursor.cur"; blankWindowsCursor = LoadCursorFromFile(LcursorName); // THIS WILL MAKE THE WINDOWS CURSOR DISAPPEAR // REMEMBER, WE'LL DRAW OUR OWN ANOTHER WAY SetCursor(blankWindowsCursor); ShowCursor(TRUE); // OPEN UP YOUR WINDOW TO THE SCREEN ShowWindow(windowHandle, nCmdShow); // GET SOME INFO ABOUT THE WINDOW. wi STORES // SOME USEFUL INFO ABOUT THE SCREEN AND THE WINDOW GetWindowInfo(windowHandle, &wi); }