int KWndEdit::Copy() { int bCopyed = false; if ((m_Flag & WNDEDIT_ES_MASK_CHARACTER) == 0 && m_nTextLen > 0 && m_pText) { if (OpenClipboard(g_GetMainHWnd())) { EmptyClipboard(); HGLOBAL hData = (char*)GlobalAlloc(GMEM_MOVEABLE, m_nTextLen + 1); if (hData) { char* pszData = (char*)GlobalLock(hData); if (pszData) { memcpy(pszData, m_pText, m_nTextLen); pszData[m_nTextLen] = 0; GlobalUnlock(hData); SetClipboardData(CF_TEXT, hData); bCopyed = true; } } CloseClipboard(); } } return bCopyed; }
int KUiBase::NotifyEvent(const char* szEvent) //0为已经处理, 不要再处理了, 非0为未处理或错误 { if (szEvent == NULL || szEvent[0] == 0) return -1; int nLen = strlen(szEvent) + 1; int nRet = -1; EVENTWNDLIST::iterator i = m_EventWndList.begin(); while(i != m_EventWndList.end()) { if (i->second) { COPYDATASTRUCT cp; cp.dwData = 0; cp.cbData = nLen; cp.lpData = (void*)szEvent; nRet = ::SendMessage((HWND)i->second, WM_COPYDATA, (WPARAM)g_GetMainHWnd(), (LPARAM)&cp); if (!nRet) return nRet; } i++; } return nRet; }
int KUiPlayVideo::OpenVideo(const char* pszVideoFile) { if (m_bInitialized == false || m_Width == 0 || m_Height == 0) return false; m_nbAlreadyPaintBlack = false; CloseVideo(false); m_bnk = m_KLVideoOpen(pszVideoFile, 0, g_GetMainHWnd()); if(!m_bnk) return false; if(m_Width < (int)m_bnk->Width || m_Height < (int)m_bnk->Height) { CloseVideo(); return false; } m_KLVideoSetSoundVolume(m_bnk, 100); for (int i = 0; i < 10000; i++) { sprintf(m_szBitmapName, "VideoBitmap_%d", i); m_uBitmapId = g_pRepresentShell->CreateImage(m_szBitmapName, m_bnk->Width, m_bnk->Height, ISI_T_BITMAP16); if (m_uBitmapId) break; } if (m_uBitmapId) { m_uBitmapIsPosition = IMAGE_IS_POSITION_INIT; g_pRepresentShell->ClearImageData(m_szBitmapName, m_uBitmapId, m_uBitmapIsPosition); m_nBlackHeight = m_bnk->Height * m_Width / m_bnk->Width; if (m_nBlackHeight <= m_Height) { m_nBlackHeight = (m_Height - m_nBlackHeight) / 2; } else { m_nBlackHeight = 0; m_nBlackWidth = m_bnk->Width * m_Height / m_bnk->Height; if (m_nBlackWidth < m_Width) { m_nBlackWidth = (m_Width - m_nBlackWidth) / 2; } else { m_nBlackWidth = 0; } } return true; } CloseVideo(); return false; }
//-------------------------------------------------------------------------- // 功能:设置鼠标指针位置 //-------------------------------------------------------------------------- void Wnd_SetCursorPos(int x, int y) { s_WndStation.Cursor.SetPosition(x, y); HWND hWnd = g_GetMainHWnd(); POINT Pos; Pos.x = x; Pos.y = y; ::ClientToScreen(hWnd, &Pos); ::SetCursorPos(Pos.x, Pos.y); }
//-------------------------------------------------------------------------- // 功能:初始化 //-------------------------------------------------------------------------- int KWndEdit::Init(KIniFile* pIniFile, const char* pSection) { if (KWndWindow::Init(pIniFile, pSection)) { int nValue; pIniFile->GetInteger(pSection, "MultiLine", 0, &nValue); if (nValue) { m_Flag |= WNDEDIT_ES_MULTI_LINE; m_nSkipAhead = 0; } else { m_Flag &= ~WNDEDIT_ES_MULTI_LINE; m_nCaretLineIndex = 0; } pIniFile->GetInteger(pSection, "Password", 0, &nValue); if (nValue) { m_Flag |= WNDEDIT_ES_MASK_CHARACTER; m_Flag &= ~WNDEDIT_ES_MULTI_LINE; } else { m_Flag &= ~WNDEDIT_ES_MASK_CHARACTER; } m_Flag &= ~WNDEDIT_ES_CHAR_TYPE_FILTER; pIniFile->GetInteger(pSection, "Type", 0, &nValue); if (nValue == 1) m_Flag |= WNDEDIT_ES_ENGLISH_AVAILABLE; else if (nValue == 2) m_Flag |= WNDEDIT_ES_IME_AVAILABLE; //====字串限长==== pIniFile->GetInteger(pSection, "MaxLen", -1, &m_nLimitText); if (m_nLimitText > m_nBufferSize - 1 || m_nLimitText == -1) m_nLimitText = m_nBufferSize -1; if (m_nLimitText < 0) m_nLimitText = 0; //if limitext value is been changed, ignore changing. //===文字颜色==== char Buff[16]; pIniFile->GetString(pSection, "Color", "", Buff, 16); m_TextColor = GetColor(Buff); pIniFile->GetString(pSection, "BorderColor", "", Buff, 16); m_TextBorderColor = GetColor(Buff); //====文字大小==== pIniFile->GetInteger(pSection, "Font", 12, &m_nFontSize); if (m_nFontSize < 8) m_nFontSize = 12; if (m_Width < m_nFontSize) { if (m_Flag & WNDEDIT_ES_IME_AVAILABLE) m_Width = m_nFontSize; else m_Width = m_nFontSize / 2; } if (m_Height < m_nFontSize + 1) m_Height = m_nFontSize + 1; pIniFile->GetString(pSection, "FocusBKColor", "0,0,0", Buff, sizeof(Buff)); m_FocusBkColor = (GetColor(Buff) & 0xffffff); if (pIniFile->GetInteger(pSection, "FocusBKColorAlpha", 128, &nValue)) { if (nValue > 255 || nValue < 0) m_FocusBkColor |= 0x16000000; else m_FocusBkColor |= (((255 - nValue) << 21) & 0xff000000); } pIniFile->GetInteger(pSection, "Win32Edit", 0, &nValue); //nValue = true; if (nValue) { if (m_hWin32Wnd == NULL) m_hWin32Wnd = Win32Edit_Create(g_GetMainHWnd(), m_Flag, m_nLimitText); if (m_hWin32Wnd) { Win32Edit_UpdateSizePos(m_hWin32Wnd, m_nAbsoluteLeft, m_nAbsoluteTop, m_Width, m_Height); Win32Edit_SetTextColor(m_hWin32Wnd, m_TextColor); m_Flag |= WNDEDIT_ES_WIN32_WND; } else { m_Flag &= ~WNDEDIT_ES_WIN32_WND; } } if (m_hWin32Wnd && (m_Flag & WNDEDIT_ES_WIN32_WND) == 0) { Win32Edit_Destroy(m_hWin32Wnd); m_hWin32Wnd = NULL; } FmtForShow(); return true; } return false; }