Exemplo n.º 1
0
/********************************************************************************
* Description : Select the next file according to type & mode, then get the name of file.
*
* Arguments  :
*            strFile:  msdos 8.3  file name of next file
* Returns     :
*            TRUE: Successful
*            FALSE: Fail, detail information in fselError
* Notes       :  None
*
********************************************************************************/
BOOL fselGetNext(UINT32 *pEntry)
{
	UINT32 num;
	
	switch(fselMode)
	{
	case FSEL_ALL_REPEATONE:
		{
			// handle the case of repeat one
			if((0 == fselFileNo) && (0 != fselTotal))
			{
				fselFileNo = 1;
			}
			return fselGetByNO(pEntry, fselFileNo);
		}
	case FSEL_DIR_RANDOM:
		{
			// handle the case of random
			num = (rand() % fselTotal) + 1;
			return fselGetByNO( pEntry, num);
		}
	case FSEL_DIR_SEQUENCE:
	case FSEL_DIR_INTRO:
		return SelectNext(pEntry);
	case FSEL_ALL_SEQUENCE:
		{
			return SelectNextDisk(pEntry);
		}
	case FSEL_ALL_REPEATALL:
		{
			if (SelectNextDisk(pEntry))
			{
				return TRUE;
			}
			else
			{
				fselInit(fselType, fselMode, 0, fselDiskLetter);
				return SelectNextDisk(pEntry);
			}
		}
	case FSEL_DIR_REPEATALL:
		{
			if (SelectNext(pEntry ))
			{
				return TRUE;
			}
			fselFileNo = 0;
			return SelectNext(pEntry);
		}
	default:
		{
			return FALSE;
		}
	}//switch
}
Exemplo n.º 2
0
LRESULT DUI_RadioGroup::MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	DUI_ControlBase::MsgProc(uMsg, wParam, lParam);
	DUI_Radio* pRadio = nullptr;
	switch (uMsg)
	{
	case RG_ADDRADIO:
		m_IDs->push_back(wParam);
		break;
	case RG_SELECTCHANGE:
		if (m_LastSelectID != INVALID_CONTROLID && m_LastSelectID != wParam)
		{
			pRadio = (DUI_Radio*)m_Parent->FindControlByID(m_LastSelectID);
			pRadio->m_bChecked = FALSE;
			if (pRadio->m_bInAnimating)
			{
				pRadio->EndAnimate();
			}
			pRadio->StartAnimate();
		}
		m_LastSelectID = wParam;
		break;
	case RG_GROUPCHANGE:
		if (m_LastSelectID == wParam)
		{
			SelectNext();
		}
		Remove(wParam);
		break;
	default:
		break;
	}
	return LRESULT();
}
Exemplo n.º 3
0
void CGameGUIList::OnMouseDown(int nButton,double x,double y)
{
  CGameWindowBase::OnMouseDown(nButton,x,y);
  
  SGamePos pos(x,y);
  if(m_nVisibleCount<(int)m_vElements.size() && x>=m_rScroll.x)
  {
	if(m_rScrollUp.Contains(pos)){SelectPrevious();}
	else if(m_rScrollDown.Contains(pos)){SelectNext();}
	else if(m_rScrollThumb.Contains(pos))
	{
		if(DetectDrag(x,y))
		{
			m_piGUIManager->SetMouseCapture(this);
			m_ptScrollThumbDragStart=pos;
			m_nScrollThumbDragStartFirstVisible=m_nFirstVisible;
		}
	}
	else if(m_rScroll.Contains(pos))
	{
		if(y<m_rScrollThumb.y){SelectNextPage();}
		else if(y>(m_rScrollThumb.y+m_rScrollThumb.h)){SelectPreviousPage();}
	}
  }
  else
  {
	m_nSelectedElement=m_nFirstVisible+(int)((m_rRealRect.h-y)/m_dFontPixelHeight);
	if(m_nSelectedElement<0){m_nSelectedElement=-1;}
	if(m_nSelectedElement>=(int)m_vElements.size()){m_nSelectedElement=-1;}
	std::string sElement=(m_nSelectedElement!=-1)?m_vElements[m_nSelectedElement]:"";
	NOTIFY_EVENT(IGameGUIListEvents,OnSelectionChanged(this,m_nSelectedElement,sElement));
  }  
}
Exemplo n.º 4
0
bool
ButtonPanel::KeyPress(unsigned key_code)
{
  assert(key_code != 0);

  const unsigned n = buttons.size();
  for (unsigned i = 0; i < n; ++i) {
    if (keys[i] == key_code) {
      buttons[i]->Click();
      return true;
    }
  }

  if (selected_index >= 0 && !HasPointer()) {
    if (key_code == KEY_LEFT) {
      SelectPrevious();
      return true;
    } else if (key_code == KEY_RIGHT) {
      SelectNext();
      return true;
    } else if (key_code == KEY_RETURN) {
      auto &button = *buttons[selected_index];
      if (button.IsVisible() && button.IsEnabled())
        button.Click();
    }
  }

  return false;
}
Exemplo n.º 5
0
void __fastcall Toperpwdform::newpwd1KeyPress(TObject *Sender, char &Key)
{
    if (Key==13) //enter key been pressed
    {
        Key=0;
        SelectNext(ActiveControl,true,true);
    }
}
Exemplo n.º 6
0
void CGameGUIList::OnKeyDown(int nKey,bool *pbProcessed)
{
  CGameWindowBase::OnKeyDown(nKey,pbProcessed);
  
  if(nKey==GK_UP){SelectPrevious();*pbProcessed=true;}
  if(nKey==GK_DOWN){SelectNext();*pbProcessed=true;}
  if(nKey==GK_PAGEDOWN){SelectNextPage();*pbProcessed=true;}
  if(nKey==GK_PAGEUP){SelectPreviousPage();*pbProcessed=true;}
  if(nKey==GK_HOME){m_nSelectedElement=0;ValidateSelection();*pbProcessed=true;}
  if(nKey==GK_END){m_nSelectedElement=m_vElements.size()-1;ValidateSelection();*pbProcessed=true;}
}
Exemplo n.º 7
0
GLboolean drimi::Gui::Container::HandleEvent ( const drimi::Event::Type eEventType, const sf::Keyboard::Key sfKeyCode ) {
  // If a child is selected then give it events.
  if (HasSelection ()) {
    m_oChildren[m_iSelectedChild]->HandleEvent (eEventType, sfKeyCode);
  }
  if (eEventType == drimi::Event::Type::KeyPressed) {
    if (sfKeyCode == sf::Keyboard::Up)
			SelectPrevious ();
		else if (sfKeyCode == sf::Keyboard::Down)
			SelectNext ();
  }

  return GL_FALSE;
}
Exemplo n.º 8
0
/********************************************************************************
* Description : Select  the file name according to number in current directory
*
* Arguments  :
*            strFile:  file name
*            Num  : File number in currect directory
* Returns     :
*            TRUE: Successful
*            FALSE: Fail, detail information in fselError.
* Notes       :  None
*
********************************************************************************/
BOOL fselGetByNO( UINT32 *strFile, const UINT32 Num)
{
	if( (Num > fselTotal) || (Num == 0))
	{
		fselError = FSEL_ERR_OUTOF;
		return FALSE;
	}
	
	fselFileNo = 0;
	
	while (Num > fselFileNo)
	{
		if(!SelectNext(strFile))
		{
			return FALSE;
		}
	}
	return TRUE;
}
//****************************************************************************************
void CBCGPDateTimeCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if (!IsWindowEnabled ())
	{
		return;
	}

	if (isdigit (nChar))
	{
		PushDigit (nChar - '0');
		return;
	}

	if (nChar >= VK_NUMPAD0 && nChar <= VK_NUMPAD9)
	{
		PushDigit (nChar - VK_NUMPAD0);
		return;
	}

	if (isalpha (nChar))
	{
		switch (m_CurrPartType)
		{
		case MONTH:
			if (m_monthFormat != 2)
			{
				ChangeMonth (nChar);
			}
			break;

		case AMPM:
			ChangeAmPm (nChar);
			break;
		}

		return;
	}

	m_iPrevDigit = -1;

	switch (nChar)
	{
	case VK_DOWN:
		ScrollCurrPart (-1);
		break;

	case VK_UP:
		ScrollCurrPart (1);
		break;

	case VK_RIGHT:
		SelectNext ();
		break;

	case VK_LEFT:
		SelectPrev ();
		break;

	case VK_HOME:
		ScrollCurrPartToLimit (TRUE);
		break;

	case VK_END:
		ScrollCurrPartToLimit (FALSE);
		break;

	case VK_SPACE:
		if (m_CurrPartType == CHECK_BOX)
		{
			ToggleCheck ();
		}
		else if (m_CurrPartType == AMPM)
		{
			ScrollCurrPart (1);
		}
		break;
	}
	
	CButton::OnKeyDown(nChar, nRepCnt, nFlags);
}
//*****************************************************************************************
void CBCGPDateTimeCtrl::PushDigit (int iDigit)
{
	int iDay = m_Date.GetDay ();
	int iMonth = m_Date.GetMonth ();
	int iYear = m_Date.GetYear ();
	int iHour = m_Date.GetHour ();
	int iMin = m_Date.GetMinute ();

	const int iYearDigits = m_type2DigitsInYear ? 2 : 4;

	int iNumber;
	if (m_iPrevDigit == -1)
	{
		iNumber = iDigit;
		m_iYearPos = 0;
	}
	else
	{
		iNumber = m_iPrevDigit * 10 + iDigit;
	}

	switch (m_CurrPartType)
	{
	case NO:
	case CHECK_BOX:
	case AMPM:
		return;

	case DAY:
		iDay = iNumber;
		break;

	case HOUR:
		if (!m_b24HoursFormat)
		{
			BOOL bPM = (iHour >= 12);
			iHour = iNumber;

			if (iHour > 12)
			{
				iHour = iDigit;
			}

			if (bPM)
			{
				iHour += 12;
			}

			if (iHour == 24)
			{
				iHour = 0;
			}

			if (iDigit != 1)	// Only 10, 11 or 12 are allowed!
			{
				iDigit = -1;
			}
		}
		else	// Normal format
		{
			iHour = iNumber;
		}
		break;

	case MIN:
		iMin = iNumber;
		break;

	case MONTH:
		if (m_monthFormat == 2 &&
			iNumber >= 1 && iNumber <= 12)
		{
			iMonth = iNumber;

			if (iDigit > 1 && m_iPrevDigit == -1)
			{
				m_iPrevDigit = 0;	// Stimulate junp to the next part
			}
		}
		break;

	case YEAR:
		if (m_type2DigitsInYear)
		{
			iYear = iYear / 100 * 100 + iNumber;

			if (iYear < m_maxYear2Digits - 99)
			{
				iYear = m_maxYear2Digits / 100 * 100 + iNumber;
			}

			if (iYear > m_maxYear2Digits)
			{
				iYear = (m_maxYear2Digits - 100) / 100 * 100 + iNumber;
			}
		}
		else
		{
			ASSERT (m_iYearPos >= 0);
			ASSERT (m_iYearPos < iYearDigits);

			//------------------------------------------------
			// Replace digit in position m_iYearPos to iDigit:
			//------------------------------------------------
			int iYearNew = 0;

			for (int iPos = 0; iPos < iYearDigits; iPos ++)
			{
				int iTens = 1;
				for (int i = 0; i < iYearDigits - iPos - 1; i ++)
				{
					iTens *= 10;
				}

				iYearNew *= 10;
				if (iPos == m_iYearPos)
				{
					iYearNew += iDigit;
				}
				else
				{
					iYearNew += iYear / iTens;
				}

				iYear %= iTens;
			}

			iYear = iYearNew;
		}

		m_iYearPos ++;
		break;
	}

	COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0);
	BOOL bValidDate = IsDateValid (date);
	
	if (bValidDate)
	{
		m_Date = date;
		RedrawWindow (m_rectText);

		OnDateChanged ();
	}

	if (m_iPrevDigit == -1)	// First push
	{
		m_iPrevDigit = iDigit;
	}
	else
	{
		if (bValidDate && m_iPartNum < m_iPartsNumber - 1)
		{
			if (m_CurrPartType != YEAR || m_iYearPos == iYearDigits)
			{
				m_iPrevDigit = -1;
				SelectNext ();
			}
		}
	}
}
Exemplo n.º 11
0
static int Delwinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int id, nc;
	int mcard = 0;
	int posX1;
	static char keyupFlag=0;
	int focus = 0;
	int tmpvalue=0;

	switch (message)
	{
		case MSG_CREATE:
			//LoadBitmap(HDC_SCREEN,&delbmp,GetBmpPath("submenubg.jpg"));
			LoadBitmap(HDC_SCREEN,&delhintbmp,GetBmpPath("delhint.gif"));
			InitWindow(hWnd);
			UpdateWindow(hWnd,TRUE);
			//SetFocusChild(btndelall);

			/*dsl 2012.4.17*/
			//if (TEST_ONLY_ENROLL_PRIVILLEGE) {
			//	SendMessage(btndelall, MSG_ENABLE, 0, 0);
			//} else {
			//	focus = 1;
			//	SetFocusChild(btndelall);
			//}
			//change by zxz 2013-04-19
			focus = 1;
			SetFocusChild(btndelall);

			if (deluser.Password[0]){
				nopwd=0;
			} else {
				nopwd=1;
			}
			if (nopwd) {
				SendMessage(btndelpwd,MSG_ENABLE,0,0);
			} else if (focus==0){
				focus = 1;
				SetFocusChild(btndelpwd);
			}

			if(!gOptions.IsOnlyRFMachine) {
				if(FDB_GetTmpCnt(deluser.PIN)>0){
					nofp=0;
				} else {
					nofp=1;
				}
				if (nofp) {
					SendMessage(btndelfp,MSG_ENABLE,0,0);
				} else if (focus==0){
					focus = 1;
					SetFocusChild(btndelfp);
				}

			}
#ifdef FACE
			if(gOptions.FaceFunOn) {
				if(FDB_GetFaceTmp(deluser.PIN,0,NULL)) {
					noface=0;
				} else {
					noface=1;
				}

				if(noface) {
					SendMessage(btndelface,MSG_ENABLE,0,0);
				} else if (focus==0){
					focus = 1;
					SetFocusChild(btndelface);
				}
			}
#endif

			if(gOptions.RFCardFunOn) {
				memcpy(&mcard,deluser.Card,4);
				if(mcard) {
					nohid = 0;
				} else {
					nohid = 1;
				}
				if (nohid) {
					SendMessage(btndelhid,MSG_ENABLE,0,0);
				}else if (focus==0){
					focus = 1;
					SetFocusChild(btndelhid);
				}

			}

			if (gOptions.CameraOpen)
			{
				int ret;
				dellist = FDB_GetPhotoToList(0, 0, deluser.PIN2, 1, &ret, 0);
				if (ret) {
					nophoto = 0;
				} else {
					nophoto = 1;
				}
				if (nophoto) {
					SendMessage(btndelphoto, MSG_ENABLE, 0, 0);
				} else if (focus==0){
					focus = 1;
					SetFocusChild(btndelphoto);
				}
			}
			break;

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);
			EndPaint(hWnd,hdc);
			return 0;
		case MSG_KEYUP:
			if(3 == gOptions.TFTKeyLayout)
			{
				keyupFlag=1;
			}
			break;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(3 == gOptions.TFTKeyLayout)
			{
				if(1 ==keyupFlag)
				{
					keyupFlag=0;
				}
				else
					break;
			}
			if (gOptions.KeyPadBeep)
				ExKeyBeep();

			if((LOWORD(wParam)==SCANCODE_CURSORBLOCKUP) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN))
			{
				SelectNext(hWnd,wParam);
				return 0;
			}
			else if (LOWORD(wParam)==SCANCODE_ESCAPE)
			{
				PostMessage (hWnd, MSG_CLOSE, 0, 0L);
				return 0;
			}
			break;

		case MSG_CLOSE:
			//UnloadBitmap(&delbmp);
			UnloadBitmap(&delhintbmp);
			DestroyMainWindow(hWnd);
			//MainWindowCleanup(hWnd);
			return 0;

		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			switch (id) {
				case ID_EXIT:
					SendMessage (hWnd, MSG_CLOSE, 0, 0L);
					break;
				case ID_CKBASE:
					if (!ProcessDeluser(delpin,hWnd,0))	UpdateWindow(hWnd,TRUE);
					break;
				case ID_CKFP:
					if (!ProcessDeluser(delpin,hWnd,1))	UpdateWindow(hWnd,TRUE);
					break;
				case ID_CKPWD:
					if (!ProcessDeluser(delpin,hWnd,2))	UpdateWindow(hWnd,TRUE);
					break;
				case ID_CKHID:
					if (!ProcessDeluser(delpin,hWnd,3))	UpdateWindow(hWnd,TRUE);
					break;
				case ID_CKPHOTO:
					if (!ProcessDeluser(delpin, hWnd, 4))	UpdateWindow(hWnd,TRUE);
					break;
#ifdef FACE
				case ID_CKFACE:
					if (!ProcessDeluser(delpin,hWnd,5))     
					{
						UpdateWindow(hWnd,TRUE);
					}
					break;
#endif
			}
			break;

		case MSG_ERASEBKGND:
			{
				HDC hdc = (HDC)wParam;
				const RECT* clip = (const RECT*) lParam;
				BOOL fGetDC = FALSE;
				RECT rcTemp;
				char textstr[100];

				if (hdc == 0) {
					hdc = GetClientDC (hWnd);
					fGetDC = TRUE;
				}

				if (clip) {
					rcTemp = *clip;
					ScreenToClient (hWnd, &rcTemp.left, &rcTemp.top);
					ScreenToClient (hWnd, &rcTemp.right, &rcTemp.bottom);
					IncludeClipRect (hdc, &rcTemp);
				}

				FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, gOptions.LCDHeight, get_submenubg_jgp());
				FillBoxWithBitmap (hdc, 250+gOptions.ControlOffset, 0, 0, 0, &delhintbmp);

				if (deluser.Name[0])		//modify by jazzy 2008.07.26
				{
					unsigned char mynamename[100];

					memset(mynamename,0,100);
					Str2UTF8(tftlocaleid,(unsigned char *)deluser.Name, mynamename);

					sprintf(textstr,"%s:%s   %s:%s",LoadStrByID(MID_ACNO),deluser.PIN2,
							LoadStrByID(MID_NAME),mynamename);
				}
				else
					sprintf(textstr,"%s:%s", LoadStrByID(MID_ACNO), deluser.PIN2);

				tmpvalue=SetBkMode(hdc,BM_TRANSPARENT);
				SetTextColor(hdc,PIXEL_lightwhite);

				if (fromRight==1)
				{
					TextOut(hdc, 50+gOptions.ControlOffset, 10, textstr);
					posX1=10+gOptions.ControlOffset;
				}
				else
				{
					TextOut(hdc, 10+gOptions.ControlOffset, 10, textstr);
					posX1=220+gOptions.ControlOffset;
				}
				if (delret==2)
				{
					TextOut(hdc, posX1, h_fp, LoadStrByID(MID_FPHADDEL));
					if (pwddelhint) TextOut(hdc, posX1, h_pwd, LoadStrByID(MID_PWDHADDEL));
					//For face
					if (facedelhint)TextOut(hdc, posX1, h_face, LoadStrByID(MID_FACEHADDEL));
					//end face
					if (hiddelhint)	TextOut(hdc, posX1, h_hid, LoadStrByID(MID_HIDHADDEL));
					if (photodelhint) TextOut(hdc, posX1, h_pic, LoadStrByID(MID_DELPHOTO_HINT));
					pwddelhint=0;	hiddelhint=0;	photodelhint=0;	fpdelhint=0;	//add by jazzy 2008.12.03
					facedelhint=0;
				}
				if (delret==3)
				{
					if (fpdelhint) TextOut(hdc, posX1, h_fp, LoadStrByID(MID_FPHADDEL));
					TextOut(hdc, posX1, h_pwd, LoadStrByID(MID_PWDHADDEL));
					if (facedelhint)TextOut(hdc, posX1, h_face, LoadStrByID(MID_FACEHADDEL));
					if (hiddelhint)	TextOut(hdc, posX1, h_hid, LoadStrByID(MID_HIDHADDEL));
					if (photodelhint) TextOut(hdc, posX1, h_pic, LoadStrByID(MID_DELPHOTO_HINT));
					pwddelhint=0;   hiddelhint=0;   photodelhint=0; fpdelhint=0;	//add by jazzy 2008.12.03
					facedelhint=0;
				}
				if (delret==4)
				{
					if (fpdelhint) TextOut(hdc, posX1, h_fp, LoadStrByID(MID_FPHADDEL));
					if (pwddelhint)	TextOut(hdc, posX1, h_pwd, LoadStrByID(MID_PWDHADDEL));
					if (facedelhint)TextOut(hdc, posX1, h_face, LoadStrByID(MID_FACEHADDEL));
					TextOut(hdc, posX1, h_hid, LoadStrByID(MID_HIDHADDEL));
					if (photodelhint) TextOut(hdc, posX1, h_pic, LoadStrByID(MID_DELPHOTO_HINT));
					pwddelhint=0;   hiddelhint=0;   photodelhint=0; fpdelhint=0;	//add by jazzy 2008.12.03
					facedelhint=0;
				}
				if (delret==5)
				{
					if (fpdelhint) TextOut(hdc,posX1, h_fp, LoadStrByID(MID_FPHADDEL));
					if (pwddelhint) TextOut(hdc,posX1, h_pwd, LoadStrByID(MID_PWDHADDEL));
					if (facedelhint)TextOut(hdc, posX1, h_face, LoadStrByID(MID_FACEHADDEL));
					if (hiddelhint) TextOut(hdc, posX1, h_hid, LoadStrByID(MID_HIDHADDEL));
					TextOut(hdc, posX1, h_pic, LoadStrByID(MID_DELPHOTO_HINT));
					pwddelhint=0;   hiddelhint=0;   photodelhint=0; fpdelhint=0;	//add by jazzy 2008.12.03
					facedelhint=0;
				}
				if (delret==6)
				{
					if (fpdelhint)
					{
						TextOut(hdc,posX1, h_fp, LoadStrByID(MID_FPHADDEL));
					}
					if(pwddelhint)
					{
						TextOut(hdc,posX1, h_pwd, LoadStrByID(MID_PWDHADDEL));
					}
					TextOut(hdc, posX1, h_face, LoadStrByID(MID_FACEHADDEL));
					if (hiddelhint)
					{
						TextOut(hdc, posX1, h_hid, LoadStrByID(MID_HIDHADDEL));
					}
					if (photodelhint)
					{
						TextOut(hdc, posX1, h_pic, LoadStrByID(MID_DELPHOTO_HINT));
					}
					pwddelhint=0;
					hiddelhint=0;
					photodelhint=0;
					fpdelhint=0;
					facedelhint=0;
				}
				ReleaseDC (hdc);
				return 0;
			}
	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);
}
Exemplo n.º 12
0
WINDOWPROC MainWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                RECT rc;

                /*
                 * Create the status window.
                 */
                CreateDialog(ghInst, MAKEINTRESOURCE(DID_STATUS),
                        hwnd, StatusDlgProc);

                /*
                 * Save away its height for sizing later (like when
                 * the app is minimized then restored).
                 */
                GetWindowRect(hwndStatus, &rc);
                gcyStatus = rc.bottom - rc.top;

                ghwndSubClient = CreateWindow(szSubClientClass, NULL,
                        WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
                        hwnd, NULL, ghInst, NULL);

                ghMenuMain = GetMenu(hwnd);
                LoadMenuBitmaps(ghMenuMain);
            }

            break;

        case WM_ACTIVATE:
            /*
             * If the main window is getting activated, there is no
             * currently active dialog.
             */
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = 0;

            goto DoDefault;

        case WM_INITMENU:
            if (GetMenu(ghwndMain) == (HMENU)wParam)
                InitMenu((HMENU)wParam);

            break;

        case WM_MENUSELECT:
            if (GET_WM_MENUSELECT_FLAGS(wParam, lParam) &
                    (MF_POPUP | MF_SYSMENU))
                gMenuSelected = 0;
            else
                gMenuSelected = GET_WM_MENUSELECT_CMD(wParam, lParam);

            break;

        case WM_COMMAND:
            DialogMenu(GET_WM_COMMAND_ID(wParam, lParam));
            break;

        case WM_KEYDOWN:
            switch (wParam) {
                case VK_UP:
                case VK_DOWN:
                case VK_LEFT:
                case VK_RIGHT:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Move the control in the specified direction.
                     */
                    MoveControl(wParam);
                    break;

                case VK_TAB:
                    if (GetKeyState(VK_CONTROL) & 0x8000)
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Is the shift key pressed also?
                     */
                    if (GetKeyState(VK_SHIFT) & 0x8000)
                        SelectPrevious();
                    else
                        SelectNext();

                    break;

                case VK_ESCAPE:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    if (gState == STATE_SELECTING)
                        OutlineSelectCancel();

                    /*
                     * Cancel any drag operation they might have been doing.
                     */
                    if (gState != STATE_NORMAL)
                        DragCancel();

                    break;

                case VK_RETURN:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    switch (gState) {
                        MPOINT mpt;
                        POINT pt;
                        DWORD dwPos;

                        case STATE_SELECTING:
                            /*
                             * In outline selection mode.  Map the
                             * location of the mouse at the time that
                             * the user pressed Enter into a point
                             * relative to the dialog client and complete
                             * the selection operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);
                            ScreenToClient(gcd.npc->hwnd, &pt);
                            OutlineSelectEnd(pt.x, pt.y);

                            break;

                        case STATE_DRAGGING:
                        case STATE_DRAGGINGNEW:
                            /*
                             * We are dragging something.  Map the
                             * location of the mouse at the time
                             * that the user pressed Enter into a
                             * point relative to the proper window
                             * and complete the drag operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);

                            /*
                             * The point must be changed to be relative to
                             * the window that the ending mouse up message
                             * would have come through, which will be the
                             * capture window for the drag.  This will be
                             * the dialog if we are adding a new control,
                             * or it will be the selected control if we are
                             * dragging an existing control.
                             */
                            ScreenToClient((gState == STATE_DRAGGING) ?
                                    gnpcSel->hwnd : gcd.npc->hwnd, &pt);

                            /*
                             * If the dialog is selected, map the points from
                             * the client area to the window.
                             */
                            if (gfDlgSelected)
                                MapDlgClientPoint(&pt, TRUE);

                            DragEnd(pt.x, pt.y);

                            break;
                    }

                    break;
            }

            break;

        case WM_NCCALCSIZE:
            /*
             * Save away what is going to be the new window position.
             */
            if (!IsIconic(hwnd) && !IsZoomed(hwnd))
                grcAppPos = *((LPRECT)lParam);

            /*
             * Now let the DefWindowProc calculate the client area normally.
             */
            goto DoDefault;

        case WM_MOVE:
            if (gfEditingDlg)
                RepositionDialog();

            break;

        case WM_SIZE:
            SizeRibbons(hwnd);

            /*
             * Did the app start minimized and is it being restored
             * for the first time?  If so, show the toolbox if
             * the user has requested it.
             */
            if (fStartAsIcon && !IsIconic(hwnd)) {
                if (gfShowToolbox)
                    ToolboxShow(TRUE);

                fStartAsIcon = FALSE;
            }

            break;

        case WM_SYSCOLORCHANGE:
            LoadSysColorBitmaps();
            break;

        case WM_CLOSE:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                break;

            /*
             * First destroy the Properties Bar.
             */
            DestroyWindow(hwndStatus);
            hwndStatus = NULL;

            DestroyWindow(hwnd);
            break;

        case WM_QUERYENDSESSION:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                return FALSE;
            else
                return TRUE;

        case WM_DESTROY:
            /*
             * Save the position of the app's window.
             */
            WriteWindowPos(&grcAppPos, IsZoomed(hwnd), szAppPos);

            WinHelp(hwnd, gszHelpFile, HELP_QUIT, 0L);
            FreeMenuBitmaps();
            PostQuitMessage(0);
            break;

        default:
            /*
             * Is this the registered help message from one of the common
             * dialogs?  If so, show the help for it.
             *
             * The check to be sure gmsgHelp is non-zero is just in
             * case the call to register the help message failed
             * (it will return zero) and there happens to be a zero
             * message that gets sent to this window somehow.
             */
            if (msg == gmsgHelp && gmsgHelp) {
                ShowHelp(FALSE);
                return 0;
            }

        DoDefault:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}
Exemplo n.º 13
0
static int WiFiPWDWinProc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int nc, id;
	static char keyupFlag=0;
	switch (message)
	{
		case MSG_CREATE:
			InitWindow(hWnd);		//add controls
			InitPWDSetting();
			UpdateWindow(hWnd,TRUE);
			curCtlidx=0;
			SetFocusChild(WifiPWDWnd[curCtlidx]);
			break;

		case MSG_ERASEBKGND:
		{
	            	HDC hdc = (HDC)wParam;
			const RECT* clip = (const RECT*)lParam;
			BOOL fGetDC = FALSE;
			RECT rcTemp;
			if(hdc == 0)
			{
				hdc = GetClientDC(hWnd);
				fGetDC = TRUE;
			}

			if(clip)
			{
				rcTemp = *clip;
				ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
				ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
				IncludeClipRect(hdc, &rcTemp);
			}

			FillBoxWithBitmap (hdc, 0, 0, gOptions.LCDWidth, 0, get_submenubg_jgp());
			if(fGetDC) ReleaseDC (hdc);
			return 0;
		}

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);	
			EndPaint(hWnd,hdc);
			return 0;

		case MSG_KEYUP:
			if(3 == gOptions.TFTKeyLayout)
			{
				keyupFlag=1;
			}
			break;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(3 == gOptions.TFTKeyLayout)
			{
				if(1==keyupFlag)
					keyupFlag=0;
				else
					break;
			}
			if (gOptions.KeyPadBeep)
				ExKeyBeep();

			if ((LOWORD(wParam)==SCANCODE_ESCAPE))
			{
				PostMessage(hWnd, MSG_COMMAND, WIFI_PWDEXIT, 0);
			}
			else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP))
			{
                                if(hIMEWnd!=HWND_INVALID)
                                {
                                        SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
                                        hIMEWnd=HWND_INVALID;
                                }

				SelectNext(wParam);
				return 0;
			}
			else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
				|| ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
			{
				if(pwdmode==0)
				{
					if(curCtlidx==0 || curCtlidx==1)
					{
						int curidx = SendMessage(WifiPWDWnd[curCtlidx], CB_GETCURSEL, 0, 0);
						if(LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT  || ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
						{
							if(--curidx<0) curidx=3;
						}
						else if(LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
						{
							if(++curidx>3) curidx=0;
						}
						SendMessage(WifiPWDWnd[curCtlidx], CB_SETCURSEL, curidx, 0);
						
						if(curCtlidx==0)
						{
							curpwdidx=curidx;
							RefreshPWDWindow(curpwdidx);
						}
						else
						{
							tmppwdmode[curpwdidx]=curidx;
//							SetWindowText(WifiPWDWnd[2+curpwdidx],"");
							SendMessage(WifiPWDWnd[2+curpwdidx], EM_LIMITTEXT, lenValue[curidx], 0L);
						}
						return 0;
					}
					 else if((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) &&(curCtlidx>=2 && curCtlidx<=5)&&
					    gOptions.IMEFunOn==1&&gOptions.TFTKeyLayout==3)
					{
                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
						return 0;
					}
					else if(curCtlidx>=6 && curCtlidx<=7)
					{
						if(curCtlidx==6) curCtlidx=7;
						else curCtlidx=6;
						SetFocusChild(WifiPWDWnd[curCtlidx]);
						return 0;
					}
				}
				else
				{
					if(curCtlidx>=1 && curCtlidx<=2)
					{
						if(curCtlidx==1) curCtlidx=2;
						else curCtlidx=1;
						SetFocusChild(WifiPWDWnd[curCtlidx]);
						return 0;
					}
					else if((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) && curCtlidx==0 &&
					    gOptions.IMEFunOn==1 && gOptions.TFTKeyLayout==3)
					{
                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
					}
				}
			}
			else if(LOWORD(wParam)==SCANCODE_ENTER) 
			{
				if((pwdmode==0 && curCtlidx<6) || (pwdmode==1 && curCtlidx<1))
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0L);
			}
			else if(LOWORD(wParam)==SCANCODE_F10)
			{
				if((pwdmode==0 && curCtlidx==7)||(pwdmode==1 && curCtlidx==2))
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDEXIT, 0L);
				else
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0L);
			}
			else if(LOWORD(wParam)==SCANCODE_MENU)
			{
				PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0);
			}
//			else if (LOWORD(wParam) == gOptions.IMESwitchKey)
			else if((LOWORD(wParam)==SCANCODE_F9) || 
				(LOWORD(wParam)==SCANCODE_F11 && (gOptions.TFTKeyLayout==0 || gOptions.TFTKeyLayout==4)))
                        {
                                if(((pwdmode==0 && curCtlidx>=2 && curCtlidx<=5) || (pwdmode==1 && curCtlidx==0)) && gOptions.IMEFunOn==1)
                                        T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);	//不支持中文输入
                                break;
                        }
			break;
//Liaozz 20080928 fix bug second 43
		case MSG_CHAR:
		{
			char schar[255];
			int slen;
//			printf("*************char=======l:%d,,,w:%d===\n",lParam, wParam);
			HWND Edtmp = GetFocusChild(hWnd);
			if(pwdmode==0)
			{
				curpwdidx=SendMessage(WifiPWDWnd[0], CB_GETCURSEL, 0, 0);			//password index
				tmppwdmode[curpwdidx]=SendMessage(WifiPWDWnd[1], CB_GETCURSEL, 0, 0);		//password type
				GetWindowText(WifiPWDWnd[2+curpwdidx], schar, 255);				//password string
				slen=strlen(schar);
				//13:Enter; 27:ESC; 127:Backspace
				if(slen==lenValue[tmppwdmode[curpwdidx]] && Edtmp == WifiPWDWnd[2+curpwdidx]
				         && wParam != 127 && wParam != 27 && wParam != 13) {
						ExBeep(1);
					}
			} else {//Liaozz 20081009 fix bug second 43
				 GetWindowText(WifiPWDWnd[0], schar, 255);
					int slen = strlen(schar);
					if (slen == 64 && Edtmp == WifiPWDWnd[0]
					               && wParam != 127 && wParam != 27 && wParam != 13)
						ExBeep(1);
			}
			break;
		}
		//Liaozz end
		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			if(id==WIFI_PWDSAVE)
			{
				if(beModified())
				{
					if(SaveWifiPWDSetting(hWnd) && !ismenutimeout)
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
				else
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
					
			}
			else if(id==WIFI_PWDEXIT)
			{
				if(beModified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA),LoadStrByID(MID_APPNAME),
									MB_OKCANCEL|MB_ICONQUESTION|MB_BASEDONPARENT)==IDOK)
					PostMessage(hWnd, MSG_COMMAND, WIFI_PWDSAVE, 0);
				else
				{
					if(!ismenutimeout) PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			}
			break;

		case MSG_CLOSE:
			//UnloadBitmap(&wifipwdbkg);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);

}
Exemplo n.º 14
0
/********************************************************************************
* Description : Seek to the next file
*
* Arguments  :
        strFile:output file name
* Returns     :
            TRUE: Successful
            FALSE: fail.
* Notes       :  目录树查找,先检查父目录再检查子目录(子目录1 -- 子目录99)
*
********************************************************************************/
BOOL SelectNextDisk(UINT32 *pEntry)
{
	UINT32 inode;
	//在当前目录向下找文件
	fselError = 0;
	
	if ( !SelectNext(pEntry) )
	{
		//寻找当前目录下的所有目录
CurrentDiragain:
		hal_TimWatchDogKeepAlive();
		if ( ERR_SUCCESS == FS_GetNextEntry(&inode,  NULL, FS_DIR_DIR) )
		{
CurrentDiragainNext:
			hal_TimWatchDogKeepAlive();
			if ( ERR_SUCCESS == FS_ChangeSubDir(inode) )
			{
				fselFileNo = 0;
				fselTotal  = 0;
				// 检查当前目录是否有合适的文件.
				if ( SelectNext(pEntry) )
				{
					fselError = 0;
					return TRUE;
				}
				else //子目录下的子目录循环查找
				{
					hal_TimWatchDogKeepAlive();
					goto CurrentDiragain;
				}
			}
			else    //出错了
			{
				fselInit(fselType, fselMode, 0, fselDiskLetter);
				fselError = FSEL_ERR_OUTOF;
				return FALSE;
			}
		}
		else    //寻找当前目录的下一个目录(平级寻找)
		{
ParentDiragainNext:
			hal_TimWatchDogKeepAlive();
			if ( ERR_SUCCESS == FS_ChangeSubDir(FS_PARENT_INO))
			{
				//寻找当前目录的下一个目录(平级寻找)
				if (ERR_SUCCESS == FS_GetNextEntry(&inode,  NULL, FS_DIR_DIR_CONT))
				{
					// 检查目录下是否有合适的文件.
					goto CurrentDiragainNext;
				}
				else    //到上一级目录
				{
					goto ParentDiragainNext;
				}
			}
			else
			{
				fselError = FSEL_ERR_OUTOF;
				return FALSE;
			}
		}
	}
	return TRUE;
}