static int DrawiconWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    static HICON myicon_small, myicon_large;
    HDC hdc;

    switch (message) {
    case MSG_CREATE:
        myicon_small = LoadIconFromFile(HDC_SCREEN, "myicon.ico", 0);
        if (myicon_small == 0)
            fprintf (stderr, "Load icon file failure!");
        myicon_large = LoadIconFromFile(HDC_SCREEN, "myicon.ico", 1);
        if (myicon_large == 0)
            fprintf (stderr, "Load icon file failure!");
        break;

    case MSG_PAINT:
        hdc = BeginPaint(hWnd);
        if (myicon_small != 0)
            DrawIcon(hdc, 10, 10, 0, 0, myicon_small);
        if (myicon_large != 0)
            DrawIcon(hdc, 60, 60, 0, 0, myicon_large);
        EndPaint(hWnd, hdc);
        return 0;

    case MSG_CLOSE:
        DestroyIcon(myicon_small);
        DestroyIcon(myicon_large);
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 2
0
static int More_noteWindowProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	hwindowDlg = hWnd;
	switch (message) {
	case MSG_CREATE:

		CreateWindow(  "button",
			       MSG_EDIT,
			       WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
			       IDM_BJ,
			       10, 45, 70, 25,
			       hWnd,
			       0);

		CreateWindow(  "button",
			       MSG_DELECT,
			       WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
			       IDM_SC,
			       10, 90, 70, 25,
			       hWnd,
			       0);
		CreateWindow(  "button",
			       MSG_RETURN,
			       WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
			       IDM2_FH,
			       10, 135, 70, 25,
			       hWnd,
			       0);


		break;
	case MSG_COMMAND:

		switch (wParam) {
		case IDM_BJ:

			break;
		case IDM_FS:

			break;
		case IDM_SC:
			if (MessageBox(hWnd, MSG_DELECT, MSG_SAVE, MB_YESNO) == IDYES) {
				delnote(hWnd);
			}
			break;
		case IDM2_FH:
			DestroyMainWindow(hWnd);
			PostQuitMessage(hWnd);
			break;
		}
		break;
	case MSG_CLOSE:
		DestroyMainWindow(hWnd);
		PostQuitMessage(hWnd);
		break;
	}
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
static int TimeEditorWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_CREATE:
    {
        HWND hwnd;
        HDC hdc;
        HWND timeedit, spin;
        SIZE size;

        hwnd = CreateWindow (CTRL_STATIC, PROMPT, 
                        WS_CHILD | WS_VISIBLE | SS_LEFT, 
                        IDC_STATIC, 
                        10, 10, 210, 200, hWnd, 0);

        timefont = CreateLogFont (NULL, "System", "ISO8859-1", 
                        FONT_WEIGHT_BOOK, FONT_SLANT_ROMAN, FONT_FLIP_NIL,
                        FONT_OTHER_AUTOSCALE, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE, 
                        32, 0);

        hdc = GetClientDC (hWnd);
        SelectFont (hdc, timefont);
        GetTextExtent (hdc, "00:00:00", -1, &size);
        ReleaseDC (hdc);

        timeedit = CreateWindow (CTRL_SLEDIT, 
                        "00:00:00", 
                        WS_CHILD | WS_VISIBLE | ES_BASELINE, 
                        IDC_EDIT, 
                        40, 220, size.cx + 4, size.cy + 4, hWnd, 0);

        SetWindowFont (timeedit, timefont);
        old_edit_proc = SetWindowCallbackProc (timeedit, TimeEditBox);

        spin = CreateWindow (CTRL_SPINBOX, 
                        "", 
                        WS_CHILD | WS_VISIBLE, 
                        IDC_SPINBOX, 
                        40 + size.cx + 6, 220 + (size.cy - 14) / 2, 20, 20, hWnd, 0);
        SendMessage (spin, SPM_SETTARGET, 0, timeedit);
        break;
    }

    case MSG_DESTROY:
        DestroyAllControls (hWnd);
        DestroyLogFont (timefont);
	return 0;

    case MSG_CLOSE:
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
Exemplo n.º 4
0
static int PaletteWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int x, y;
    static GAL_Color colorPal[256], myPal[256];
    switch (message) {
    case MSG_CREATE:
        GetPalette(HDC_SCREEN, 0, 256, colorPal);
#ifdef _DEBUG
	int i;
        for (i = 0; i < 256; i++) {
            printf ("i = %d\n, red = %d\n, green = %d\n, blue = %d\n\n", 
                    i, colorPal[i].r, colorPal[i].g, colorPal[i].b);
        }
#endif
        break;

    case MSG_PAINT:
        {
            if (g_bShowBall)
                SendMessage (hWnd, MSG_LBUTTONDOWN, 0, 0);
        }
        break;
    case MSG_LBUTTONDOWN:
        g_bShowBall = TRUE;
        hdc = GetClientDC(hWnd);
        InitMyPalette(myPal);
        SetPalette(hdc, 0, 256, myPal);
        SetBrushColor(hdc, COLOR_red);
        FillCircle(hdc, 10, 10, 8);
        for (y = 0; y < 240; y += 20) {
            for (x = 0; x < 320; x += 20) {
              BitBlt(hdc, 0, 0, 20, 20, hdc, x, y, 0);
              SetColorfulPalette(hdc);
            }
        }
        ReleaseDC(hdc);
        break;

    case MSG_RBUTTONDOWN:
        SetColorfulPalette(HDC_SCREEN);
        SetBrushColor(HDC_SCREEN, PIXEL_yellow);
        FillCircle(HDC_SCREEN, 50, 50, 15);
        break;

    case MSG_CLOSE:
        DestroyAllControls (hWnd);
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
/* main windoww proc */
static int CaptureWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_CREATE:
        RegisterMybutton();
        CreateWindow ("mybutton", "", WS_VISIBLE | WS_CHILD, IDC_MYBUTTON, 
                110, 80, 70, 20, hWnd, 0);
        break;

    case MSG_CLOSE:
        DestroyAllControls (hWnd);
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 6
0
int mgi_container_win_proc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    switch (message) {
        case MSG_CREATE:
            create_cont_toolbar (hwnd);
            break;
        case MSG_SETFOCUS:
        case MSG_KILLFOCUS:
            return 0;
        case MSG_PAINT:
            hdc = BeginPaint (hwnd);
            draw_border (hwnd, hdc);
            EndPaint (hwnd, hdc);
            break;
    };
    return DefaultMainWinProc (hwnd, message, wParam, lParam);
}
/* main windoww proc */
static int CaretdemoWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HWND hMyedit;

    switch (message) {
    case MSG_CREATE:
        RegisterMyedit();
        hMyedit = CreateWindow("myedit", "", WS_VISIBLE | WS_CHILD, IDC_MYEDIT, 
                30, 50, 100, 20, hWnd, 0);
        SetFocus(hMyedit);
        break;

    case MSG_CLOSE:
        DestroyAllControls (hWnd);
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 8
0
/********************************************************************************************
* Function Name:		KeyBoardPro()
* Function Discription:	Processing function of the KeyBoard window
********************************************************************************************/
static int KeyBoardPro (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HWND        Kbs, Kbb;
	static char Text[100], PhoneNum[40];
	switch (message) {
	case MSG_CREATE:
		//創建鍵盤控件
		CreateKbd(hWnd);
		break;

	case MSG_COMMAND:   //鍵盤事件觸發
	{
		int id       = LOWORD(wParam);
		int keyid    = HIWORD(wParam);
		int KeyValue = KeyV[keyid];
		if (id == IDC_KB) {
			//其它按鍵觸發時,發送鍵盤按鍵消息
			SendMessage(InputEdit, MSG_KEYDOWN, KeyValue, 0L);

		}
	}
	break;
	//用於在銷毀時退出的代碼,重要不然會死掉。
	case MSG_DESTROY:
		DestroyAllControls(hWnd);
		return 0;

	case MSG_CLOSE:
		DestroyMainWindow(hWnd);
		PostQuitMessage(hWnd);
		return 0;



	}
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 9
0
static int ModemWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;

	switch (message){
		case MSG_CREATE:
			InitModemWin(hWnd);
			ModemCurWnd = 0;
			SetFocusChild(ModemWnd[ModemCurWnd]);
			UpdateWindow(hWnd, TRUE);
			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, gOptions.LCDHeight, &ModemBkg);
				if(fGetDC){
					ReleaseDC(hdc);
				}

				return 0;
			}

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

		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
			if(gOptions.KeyPadBeep)
				ExKeyBeep();

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN){
				if (ModemCurWnd == 11) {
					ModemCurWnd = 0;
				} else if (ModemCurWnd == 0 && module_type == MODEM_MODULE_EM660) {
					ModemCurWnd += 2;
				} else if (4 < ModemCurWnd && ModemCurWnd < 9) {
					ModemCurWnd = 9;
				} else {
					ModemCurWnd++;
				}
				SetFocusChild(ModemWnd[ModemCurWnd]);
				return 0;
			}

			if (LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT || LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT ||
					(gOptions.TFTKeyLayout == 3 && LOWORD(wParam)  == SCANCODE_BACKSPACE)){
				if (ModemCurWnd == 0){
					if (SendMessage(ModemWnd[ModemCurWnd], CB_GETCURSEL, 0, 0)==0)
						SendMessage(ModemWnd[ModemCurWnd], CB_SETCURSEL, 1, 0);
					else
						SendMessage(ModemWnd[ModemCurWnd], CB_SETCURSEL, 0, 0);
					return 0;
				}

				if (4 < ModemCurWnd && ModemCurWnd < 8 && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd += 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
				}

				if (5 < ModemCurWnd && ModemCurWnd < 9 && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd -= 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
				}

				if ((ModemCurWnd == 9 || ModemCurWnd == 10) && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd += 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}

				if ((ModemCurWnd == 10 || ModemCurWnd == 11) && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd -= 1;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
				if (ModemCurWnd == 9 && LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT){
					ModemCurWnd = 11;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
				if (ModemCurWnd == 11 && LOWORD(wParam) == SCANCODE_CURSORBLOCKRIGHT){
					ModemCurWnd = 9;
					SetFocusChild(ModemWnd[ModemCurWnd]);
					return 0;
				}
			}

			if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP){
				if (ModemCurWnd == 0) {
					ModemCurWnd = 11;
				} else if (ModemCurWnd == 2 && module_type == MODEM_MODULE_EM660) {
					ModemCurWnd -= 2;
				} else if(ModemCurWnd == 9) {
					ModemCurWnd = 5;
				} else if (4 < ModemCurWnd && ModemCurWnd < 9) {
					ModemCurWnd = 4;
				} else {
					ModemCurWnd--;
				}
				SetFocusChild(ModemWnd[ModemCurWnd]);
				return 0;
			}


			if (LOWORD(wParam)==SCANCODE_F9 || ((gOptions.TFTKeyLayout == 0 || 
							gOptions.TFTKeyLayout == 4) && (LOWORD(wParam) == SCANCODE_F11))) {
				if ((ModemCurWnd > 1 && ModemCurWnd < 5) || (module_type != MODEM_MODULE_EM660 && ModemCurWnd == 1)) {
					T9IMEWindow(hWnd, 0, 200,gOptions.LCDWidth, gOptions.LCDHeight, 0);
				}
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_F8){
				CreateModemInfoWindow(hWnd);
				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_ENTER){
				if (ModemCurWnd == 9){
					PostMessage(hWnd, MSG_COMMAND, IDOK, 0);
				}

				if (ModemCurWnd == 10){
					PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
				}

				if (ModemCurWnd == 11){
					CreateModemInfoWindow(hWnd);
				}

				return 0;
			}

			if (LOWORD(wParam)==SCANCODE_ESCAPE){
				PostMessage(hWnd, MSG_COMMAND, IDCANCEL, 0);
			}

			if (LOWORD(wParam)==SCANCODE_MENU){
				PostMessage(hWnd, MSG_COMMAND, IDOK, 0);
				return 0;
			}

			break;

		case MSG_COMMAND:
			switch(LOWORD(wParam)){
				case IDOK:
					if(isModemSettingChanged()){
						if(!ismenutimeout){
							SaveModemSetting(hWnd);
							PostMessage(hWnd, MSG_CLOSE, 0, 0);
						}
					}else{
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
					break;

				case IDCANCEL:
					if(isModemSettingChanged()){
						if(MessageBox1(hWnd, LoadStrByID(MID_SAVEDATA), LoadStrByID(MID_APPNAME),MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) == IDOK)
						{
							if(!ismenutimeout){
								SaveModemSetting(hWnd);
								PostMessage(hWnd, MSG_CLOSE, 0, 0);
							}
						}
						else
						{
							if(!ismenutimeout)
								PostMessage(hWnd, MSG_CLOSE, 0, 0);
						}
					}else{
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
					break;

			}
			break;

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

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

}
Exemplo n.º 10
0
static int duressparawinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int id,nc;
    char sstr[10];
    int tmpvalue;
    static char keyupFlag=0;
    switch (message)
    {
    case MSG_CREATE:
        //if (LoadBitmap(HDC_SCREEN,&gpmngbk1,GetBmpPath("submenubg.jpg")))
        //        return 0;

        InitWindow(hWnd);		//add controls
        InitWindowText(hWnd);
        UpdateWindow(hWnd,TRUE);
        actindex=0;
        SetFocusChild(EdDAM[actindex]);
        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, gOptions.LCDHeight, 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, ID_EXIT, 0L);
        }

        if(LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN)
        {
            if(actindex==4)
            {
                memset(sstr,0,10);
                GetWindowText(EdDAM[actindex],sstr,3);
                if(strlen(sstr)==0)
                    return 0;
            }
            if(++actindex > 6) actindex = 0;
            //Liaozz 20081008 fix bug third 6
            if (gOptions.IsOnlyRFMachine) {
                if (actindex == 1 || actindex == 2)
                    actindex = 3;
            }
            //Liaozz end
            SetFocusChild(EdDAM[actindex]);
            return 0;
        }

        if( LOWORD(wParam)==SCANCODE_CURSORBLOCKUP)
        {
            if(actindex==4)
            {
                memset(sstr,0,10);
                GetWindowText(EdDAM[actindex],sstr,3);
                if(strlen(sstr)==0)
                    return 0;
            }
            if(--actindex < 0) actindex = 6;
            //Liaozz 20081008 fix bug third 6
            if (gOptions.IsOnlyRFMachine) {
                if (actindex == 1 || actindex == 2)
                    actindex = 0;
            }
            //Liaozz end
            SetFocusChild(EdDAM[actindex]);
            return 0;
        }

        if(LOWORD(wParam) == SCANCODE_CURSORBLOCKLEFT || (gOptions.TFTKeyLayout == 3 && LOWORD(wParam) == SCANCODE_BACKSPACE))
        {
            if(actindex<4)
            {
                tmpvalue=SendMessage(EdDAM[actindex], CB_GETCURSEL, 0, 0);
                if(--tmpvalue < 0) tmpvalue = 1;
                SendMessage(EdDAM[actindex], CB_SETCURSEL, tmpvalue, 0);
                return 0;
            }
            else if(actindex>4)
            {
                if(--actindex < 0) actindex = 6;
                SetFocusChild(EdDAM[actindex]);
                return 0;
            }
        }

        if(LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
        {
            if(actindex<4)
            {
                tmpvalue=SendMessage(EdDAM[actindex], CB_GETCURSEL, 0, 0);
                if(++tmpvalue > 1) tmpvalue = 0;
                SendMessage(EdDAM[actindex], CB_SETCURSEL, tmpvalue, 0);
                return 0;
            }
            else if(actindex>4)
            {
                if(++actindex > 6) actindex = 0;
                SetFocusChild(EdDAM[actindex]);
                return 0;
            }
        }

        if(LOWORD(wParam)==SCANCODE_ENTER)
        {
            if(actindex<5)
                PostMessage(hWnd,MSG_COMMAND,(WPARAM)ID_SAVE,0);
        }

        if(LOWORD(wParam)==SCANCODE_F10)
        {
            if(actindex!=6)
                PostMessage(hWnd, MSG_COMMAND, (WPARAM)ID_SAVE, 0L);
            else
                PostMessage(hWnd, MSG_COMMAND, (WPARAM)ID_EXIT, 0L);
        }

        if(LOWORD(wParam)==SCANCODE_MENU)
            PostMessage (hWnd, MSG_COMMAND, (WPARAM)ID_SAVE, 0L);

        break;

    case MSG_COMMAND:
        id = LOWORD(wParam);
        nc = HIWORD(wParam);
        if(nc==EN_CHANGE)
        {
            if(id == DAM_ID+4)
            {
                memset(sstr,0,5);
                GetWindowText(EdDAM[actindex],sstr,3);
                tmpvalue = atoi(sstr);
                if(tmpvalue>255)
                {
                    SetWindowText(EdDAM[actindex],"0");
                    SendMessage(EdDAM[actindex],EM_SETCARETPOS,0,1);
                }
            }
        }

        switch(id)
        {
        case ID_SAVE:
            SaveDuressParameter(hWnd);
            LoadOptions(&gOptions);
            MessageBox1(hWnd ,LoadStrByID(HIT_RIGHT) ,LoadStrByID(HIT_RUN),MB_OK| MB_ICONINFORMATION);
            if(!ismenutimeout) PostMessage(hWnd,MSG_CLOSE,0,0);
            break;

        case ID_EXIT:
            if(ismodified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA), LoadStrByID(MID_APPNAME),
                                           MB_OKCANCEL | MB_ICONQUESTION | MB_BASEDONPARENT) == IDOK)
                SendMessage(hWnd, MSG_COMMAND, ID_SAVE, 0);
            if(!ismenutimeout) PostMessage(hWnd,MSG_CLOSE,0,0L);
            break;
        }

        break;

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

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

}
Exemplo n.º 11
0
static int Verifywinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int id,nc, tmpvalue = 0;
	static char keyupFlag=0;
	switch (message)	
	{
		case MSG_CREATE:

			InitWindow(hWnd);
			SetFocusChild(editacno3);			
			SetWindowText(editacno3,propin);
			SendMessage(editacno3,EM_SETCARETPOS,0,1);
			return 0;
		case MSG_PAINT:
			hdc=BeginPaint(hWnd);
		    tmpvalue= SetBkMode(hdc,BM_TRANSPARENT);
		    SetTextColor(hdc,PIXEL_lightwhite);		
			TextOut(hdc,60,70,LoadStrByID(HID_PLACEFINGER));			     
			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 ((GetFocusChild(hWnd)==editacno3)&&((LOWORD(wParam)==SCANCODE_ENTER)
				||(LOWORD(wParam)==SCANCODE_F10)))
				procverifychoose(hWnd);		
			if ((LOWORD(wParam)==SCANCODE_ESCAPE))		
				PostMessage (hWnd, MSG_CLOSE, 0, 0L);
			break;		
	    case MSG_DESTROY:
        	DestroyAllControls (hWnd);
	        hMainWnd1 = HWND_INVALID;
        	return 0;
		case MSG_CLOSE:
			DestroyMainWindow(hWnd);
			MainWindowThreadCleanup (hWnd);
			return 0;
		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			if (id==ID_ACNO)
			{
				if (nc==EN_CHANGE)
				{
					memset(propin,0,24);
                    GetWindowText (editacno3, propin, 24);
					printf("keybuffer:%s\n",propin);
				}
			}
			break;

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);
}
Exemplo n.º 12
0
static int NewWiFiWinProc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int id,nc;
	static char keyupFlag=0;

	switch (message)
	{
		case MSG_CREATE:
			wifidhcpflag = gOptions.wifidhcpfunon;
			InitWifiWindow(hWnd);		//add controls
			InitParameters();

			curFocusWnd =0;
			SetFocusChild(WifiWnd[curFocusWnd]);
			UpdateWindow(hWnd,TRUE);
			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, &wifibkg);
				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_EXIT, 0);
			} else 	if (LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN) {
				char tmpssid[128];
				if (curFocusWnd==0) {
					GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
					if(tmpssid && strlen(tmpssid)>0) {
						if(hIMEWnd!=HWND_INVALID){
							SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
							hIMEWnd=HWND_INVALID;
						}
						curFocusWnd++;
					}
				} else if (curFocusWnd==1) {
					if(hIMEWnd!=HWND_INVALID){
						SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
						hIMEWnd=HWND_INVALID;
					}
					curFocusWnd++;
				} else if(++curFocusWnd>16) {
					curFocusWnd=0;
				}

				if (wifidhcpflag == 1 && curFocusWnd == 3) {
					curFocusWnd=15;
				}
				if (curFocusWnd == 4 || curFocusWnd == 5 ||curFocusWnd == 6 ){
					curFocusWnd = 7;
				}
				if (curFocusWnd == 8 || curFocusWnd == 9 || curFocusWnd == 10){
					curFocusWnd = 11;
				}
				if (curFocusWnd == 12 || curFocusWnd == 13 || curFocusWnd == 14){
					curFocusWnd = 15;
				}
				SetFocusChild(WifiWnd[curFocusWnd]);		
				return 0;
			} else if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP){
				char tmpssid[128];
				if(curFocusWnd==0){
					GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
					if(tmpssid && strlen(tmpssid)>0){
						if(hIMEWnd!=HWND_INVALID){
							SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
							hIMEWnd=HWND_INVALID;
						}
						curFocusWnd--;
					}
				} else if (curFocusWnd==1) {
					if(hIMEWnd!=HWND_INVALID){
						SendMessage(hIMEWnd,MSG_CLOSE,0,0L);
						hIMEWnd=HWND_INVALID;
					}
					curFocusWnd--;
				
				} else if(--curFocusWnd<0){
					curFocusWnd=16;
				}

				if (wifidhcpflag == 1 && curFocusWnd == 14) {
					curFocusWnd= 2;
				}

				if (curFocusWnd == 10|| curFocusWnd == 11|| curFocusWnd == 12 ||curFocusWnd == 13 ){
					curFocusWnd = 7;
				} else if (curFocusWnd == 6|| curFocusWnd == 7|| curFocusWnd == 8 || curFocusWnd == 9){
					curFocusWnd = 3;
				} else if (curFocusWnd == 3 || curFocusWnd == 4 || curFocusWnd == 5){
					curFocusWnd = 2;
				} else if(curFocusWnd == 14){
					curFocusWnd = 11;
				}

				SetFocusChild(WifiWnd[curFocusWnd]);
				return 0;

			} else if(LOWORD(wParam)==SCANCODE_F9 || 
					((gOptions.TFTKeyLayout==0 || gOptions.TFTKeyLayout==4) && (LOWORD(wParam)==SCANCODE_F11))) {
				if((curFocusWnd==0 || curFocusWnd==1) && (gOptions.IMEFunOn==1 && gOptions.TFTKeyLayout!=3))
				{
					T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight,gOptions.HzImeOn);
				}
			} else if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT) || (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)
				|| ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE)) {

				if ((LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT) && gOptions.IMEFunOn==1 
						&& gOptions.TFTKeyLayout==3 && (curFocusWnd==0 || curFocusWnd==1)) {
					T9IMEWindow(hWnd,0,200,gOptions.LCDWidth, gOptions.LCDHeight, 0);
					return 0;
				}

				if(curFocusWnd==2 && ((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT || ((gOptions.TFTKeyLayout==3) && LOWORD(wParam)==SCANCODE_BACKSPACE))
					||LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT)) {

					int tmpsel = SendMessage(WifiWnd[curFocusWnd], CB_GETCURSEL, 0, 0);		
					if (tmpsel == 0) {
						SendMessage(WifiWnd[curFocusWnd], CB_SETCURSEL, 1, 0);
						dhcpswitch(1);
						UpdateWindow(hWnd,TRUE);
						wifidhcpflag =1;
					} else {
						SendMessage(WifiWnd[curFocusWnd], CB_SETCURSEL, 0, 0);
						dhcpswitch(0);
						UpdateWindow(hWnd,TRUE);
						wifidhcpflag = 0;
					}
				}
				if (curFocusWnd >2 && curFocusWnd<15 && wifidhcpflag ==0) {
					if (LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT ){
						curFocusWnd --;
						if (curFocusWnd == 2){
							curFocusWnd =14;
						}
					}else if (LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT){
						curFocusWnd ++;
						if (curFocusWnd ==15){
							curFocusWnd = 3;
						}
					}
					SetFocusChild(WifiWnd[curFocusWnd]);
				}
				return 0;	
			} else if ((LOWORD(wParam)==SCANCODE_ENTER) || (LOWORD(wParam)==SCANCODE_F10)) {
				char tmpssid[128];
				switch(curFocusWnd)
				{
					case 0:
						GetWindowText(WifiWnd[0], tmpssid, sizeof(tmpssid));
						if(tmpssid && strlen(tmpssid)>0)
							SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
						else
							MessageBox1(hWnd ,LoadStrByID(HIT_ERROR0) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
						break;
					case 16:		//exit
						SendMessage(hWnd, MSG_COMMAND, WIFI_EXIT, 0);
						break;
					default:
						SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				}
				return 0;
			} else if(LOWORD(wParam)==SCANCODE_MENU) {
				SendMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				return 0;
			}
			break;

		case MSG_COMMAND:
			id = LOWORD(wParam);
			nc = HIWORD(wParam);
			if(id==WIFI_SAVE) {
				if(isModified() && SaveNewWiFiSetting(hWnd)) {
					MessageBox1(hWnd ,LoadStrByID(HIT_RIGHT) ,LoadStrByID(HIT_RUN),MB_OK| MB_ICONINFORMATION);
					if(!ismenutimeout) {
						PostMessage(hWnd, MSG_CLOSE, 0, 0);
					}
				} else if(!ismenutimeout) {
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			} else if (id==WIFI_EXIT) {
				if(isModified() && MessageBox1(hWnd,LoadStrByID(MID_SAVEDATA),LoadStrByID(MID_APPNAME),
					MB_OKCANCEL|MB_ICONQUESTION|MB_BASEDONPARENT)==IDOK) {
					PostMessage(hWnd, MSG_COMMAND, WIFI_SAVE, 0);
				} else if(!ismenutimeout) {
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
				}
			}
			break;

		case MSG_CLOSE:
			if(hIMEWnd!=HWND_INVALID){
				SendMessage(hIMEWnd,MSG_CLOSE,0,0);
				hIMEWnd=HWND_INVALID;
			}

			UnloadBitmap(&wifibkg);
			//MainWindowCleanup(hWnd);
			DestroyMainWindow(hWnd);
			return 0;

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);
}
Exemplo n.º 13
0
static int mainstatewinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	static char keyupFlag=0;
	switch (message)	
	{
		case MSG_CREATE:
			//LoadBitmap(HDC_SCREEN,&mainstatebmp,GetBmpPath("submenubg.jpg"));
			UpdateWindow(hWnd,TRUE);		
			break;

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);		
			procmainstatekey(hdc,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_F1) && ((LOWORD(wParam)<=SCANCODE_F8)))
			{
				putkey=LOWORD(wParam)-SCANCODE_F1;
				if (procgetstate(wParam))
				{
					InvalidateRect(hWnd,NULL,FALSE);

				}
			}
			else
				PostMessage(hWnd, MSG_CLOSE, 0, 0L);
			if ((LOWORD(wParam)==SCANCODE_ESCAPE))		
				PostMessage(hWnd, MSG_CLOSE, 0, 0L);
			break;			

		case MSG_CLOSE:
			//UnloadBitmap(&mainstatebmp);
			DestroyMainWindow(hWnd);
			return 0;
		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, 0, 0, get_submenubg_jgp());
				if (fGetDC)
					ReleaseDC (hdc);
				return 0;
			}

	}
	return DefaultMainWinProc(hWnd,message,wParam,lParam);
}
Exemplo n.º 14
0
static int boardwinproc(HWND  hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	char sstr[20];
	static char keyupFlag=0;
	int tmpvalue = 0;
	switch (message)
	{
		case MSG_CREATE:
			LoadBitmap(HDC_SCREEN,&smsshowbk,GetBmpPath("sms.jpg"));
			LoadBitmap(HDC_SCREEN,&barbmp, GetBmpPath("bar.bmp"));
			LoadBitmap(HDC_SCREEN,&smsshowbmp1,GetBmpPath("left2.gif"));
			LoadBitmap(HDC_SCREEN,&smsshowbmp2,GetBmpPath("right2.gif"));

			if (gfont==NULL)
			{
				smsshowfont = CreateLogFont (NULL,"fixed","GB2312",FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
						FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,10, 0);
				titlefont = CreateLogFont (NULL,"fixed","GB2312",FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
						FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,12, 0);
			}
			else
			{
				smsshowfont=gfont;
				titlefont=gfont1;
			}
			LoadsshowHint();
			InitWindow(hWnd);		//add controls
			curIdx=1;
			ShowMessage(hWnd,GetSmsPIN(curIdx));

			exitcount = 0;
#ifdef ZEM600
			SetTimer(hWnd,IDC_TIMERSMS,50);
#else
			SetTimer(hWnd,IDC_TIMERSMS,100);
#endif
			break;

		case MSG_PAINT:
			hdc=BeginPaint(hWnd);

			//write title
			SelectFont(hdc,titlefont);
			SetTextColor(hdc,PIXEL_lightwhite);
			tmpvalue = SetBkMode(hdc,BM_TRANSPARENT);
			memset(sstr,0,20);
			sprintf(sstr,"%s",sshowhint[0]);
			TextOut(hdc,140,15,sstr);

			//                        SetBkColor(hdc,0x00FFA2BE);
			//SelectFont(hdc,smsshowfont);
			SelectFont(hdc,titlefont);
			SetTextColor(hdc,PIXEL_lightwhite);

			memset(sstr,0,20);
			if (fromRight)
				sprintf(sstr,"%s",sshowhint[1]);
			else
				sprintf(sstr,"%s:",sshowhint[1]);
			TextOut(hdc,5,220,sstr);
			FillBoxWithBitmap (hdc, 65, 218,16, 16, &smsshowbmp1);

			memset(sstr,0,20);
			if (fromRight)
				sprintf(sstr,"%s",sshowhint[2]);
			else
				sprintf(sstr,"%s:",sshowhint[2]);
			TextOut(hdc,90,220,sstr);
			FillBoxWithBitmap (hdc, 140, 218,16, 16, &smsshowbmp2);

			memset(sstr,0,20);
			if (fromRight)
				sprintf(sstr,"%s%d:%s,%s%d:%s",sshowhint[3],bsmscount,sshowhint[4],sshowhint[5],curIdx,sshowhint[4]);
			else
				sprintf(sstr,"%s:%d%s,%s:%d%s",sshowhint[3],bsmscount,sshowhint[4],sshowhint[5],curIdx,sshowhint[4]);
			TextOut(hdc,170,220,sstr);

			EndPaint(hWnd,hdc);
			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, gOptions.LCDHeight-30, &smsshowbk);
				FillBoxWithBitmap (hdc, 0, 210, gOptions.LCDWidth,30,&barbmp);

				if(fGetDC) ReleaseDC (hdc);
				break;
			}

		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;
			}
			exitcount=0;

			if ((LOWORD(wParam)==SCANCODE_ESCAPE))
				PostMessage(hWnd,MSG_CLOSE,0,0L);

			/*SMS快捷键查看,modify by yangxiaolong,start*/
			//del
			/*
			   if(LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN || LOWORD(wParam)==SCANCODE_CURSORBLOCKUP)
			   {
			   SendMessage(EdText,MSG_KEYDOWN,wParam,lParam);
			   }*/
			//add
			//快捷键查看SMS时,上下键翻动换行反应缓慢,调成翻页处理
			if(LOWORD(wParam)==SCANCODE_CURSORBLOCKDOWN)
			{
				SendMessage(EdText,MSG_KEYDOWN,SCANCODE_PAGEDOWN,lParam);
			}
			else if (LOWORD(wParam)==SCANCODE_CURSORBLOCKUP)
			{
				SendMessage(EdText,MSG_KEYDOWN,SCANCODE_PAGEUP,lParam);
			}
			/*SMS快捷键查看,modify by yangxiaolong,end*/	

			if(LOWORD(wParam)==SCANCODE_F11)
				SendMessage(EdText,MSG_KEYDOWN,SCANCODE_PAGEUP,lParam);
			if(LOWORD(wParam)==SCANCODE_F12)
				SendMessage(EdText,MSG_KEYDOWN,SCANCODE_PAGEDOWN,lParam);

			//if(LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT && bsmscount>1)
			if((LOWORD(wParam)==SCANCODE_CURSORBLOCKLEFT || (LOWORD(wParam)==SCANCODE_BACKSPACE && 3==gOptions.TFTKeyLayout)) && bsmscount>1)
			{
				if(--curIdx < 1) curIdx = bsmscount;
				ShowMessage(hWnd,GetSmsPIN(curIdx));
			}

			if(LOWORD(wParam)==SCANCODE_CURSORBLOCKRIGHT && bsmscount>1)
			{
				if(++curIdx > bsmscount) curIdx = 1;
				ShowMessage(hWnd,GetSmsPIN(curIdx));
			}

			break;

		case MSG_TIMER:
			if(wParam==IDC_TIMERSMS)
			{
				if(++exitcount>60) SendMessage(hWnd,MSG_CLOSE,0,0);
			}
			break;

		case MSG_CLOSE:
			UnloadBitmap(&smsshowbk);
			UnloadBitmap(&barbmp);
			UnloadBitmap(&smsshowbmp1);
			UnloadBitmap(&smsshowbmp2);
			if (gfont1==NULL)
			{
				DestroyLogFont(smsshowfont);
				DestroyLogFont(titlefont);
			}
			KillTimer(hWnd,IDC_TIMERSMS);
			freeList();
			DestroyMainWindow(hWnd);
			//hSMSWnd=NULL;
			break;

		default:
			return DefaultMainWinProc(hWnd,message,wParam,lParam);

	}
	return (0);

}
Exemplo n.º 15
0
static int PlatformProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case MSG_CREATE:
            {
                if (!hmWnd)
                    hmWnd = hWnd;

                unsigned char* pdr = 0;
                int w,h,p;
                RECT r;
                key_down = FALSE;
                GetClientRect(hWnd, &r);
#if RGB555
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000);    
#else
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00);    
#endif
                pdr = LockDC(sdc, &r, &w, &h, &p);
                UnlockDC(sdc);
#if RGB555
                fmt = COLOR_FORMAT_RGB555;
#else
                fmt = COLOR_FORMAT_RGB565;
#endif
                ps_initialize();

                canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p);
                context = ps_context_create(canvas, 0);
                on_init(context, width, height);    
            }
            break;
        case MSG_TIMER:
            on_timer();
            break;
        case MSG_PAINT:
            {
                HDC hdc = BeginPaint(hWnd);
                on_draw(context);
                BitBlt(sdc, 0, 0, width, height, hdc, 0, 0, 0);
                EndPaint(hWnd, hdc);
            }
            return 0;
        case MSG_ERASEBKGND:
            return 0;
        case MSG_LBUTTONDOWN:
            {
                key_down = TRUE;
                on_mouse_event(LEFT_BUTTON_DOWN, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_LBUTTONUP:
            {
                key_down = FALSE;
                on_mouse_event(LEFT_BUTTON_UP, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_MOUSEMOVE:
            {
                DWORD k = key_conv(wParam);
                if (key_down)
                    k |= EVT_LBUTTON;
                on_mouse_event(MOUSE_MOVE, k, LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_KEYDOWN:
            on_key_event(KEY_EVENT_DOWN, get_virtual_key(wParam));
            break;
        case MSG_KEYUP:
            on_key_event(KEY_EVENT_UP, get_virtual_key(wParam));
            break;
        case MSG_SIZECHANGED:
            {
                RECT r;
                int w,h,p;
                unsigned char* pdr = 0;
                ps_canvas* old_canvas = 0;
                RECT* rc = (RECT*)lParam;
                width = RECTWP(rc);
                height = RECTHP(rc);
                if (sdc)
                    DeleteMemDC(sdc);

                if (width < 1)
                    width = 1;
                if (height < 1)
                    height = 1;
#if RGB555
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000);    
#else
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00);    
#endif
                GetClientRect(hWnd, &r);
                pdr = LockDC(sdc, &r, &w, &h, &p);
                UnlockDC(sdc);
                canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p);
                old_canvas = ps_context_set_canvas(context, canvas);
                ps_canvas_unref(old_canvas);
                on_size(width, height);
            }
            break;
        case MSG_CLOSE:
            on_term(context);
            ps_context_unref(context);
            ps_canvas_unref(canvas);
            ps_shutdown();
            DeleteMemDC(sdc);
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
            return 0;
    }
    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 16
0
static int MainHandler(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int id   = LOWORD(lParam);
    int code = HIWORD(lParam);

    switch (message) {
        case MSG_CREATE:
            FillBoxWithBitmap(HDC_SCREEN, 0, 20, 480, 272, &pic_bk);
            // Initial Objects
            msgbox = CreateWindow(CTRL_STATIC, "It's sloting time!", 
                                  WS_CHILD | WS_VISIBLE | SS_RIGHT | WS_BORDER,
                                  MSGBOX, 10, 10, 460, 20, hWnd, 0);
            LoadBitmap(p1, &pic_stuff1, "./img/stuff1.bmp");
            btn_stuff1 = CreateWindow(CTRL_BUTTON, "Stuff1",
                                      WS_CHILD | BS_PUSHBUTTON | BS_BITMAP | BS_NOTIFY | WS_VISIBLE,
                                      BTN_S1, 10, 40, 100, 100, hWnd, (DWORD)&pic_stuff1);
            LoadBitmap(p2, &pic_stuff2, "./img/stuff2.bmp");
            btn_stuff2 = CreateWindow(CTRL_BUTTON, "Stuff2",
                                      WS_CHILD | BS_PUSHBUTTON | BS_BITMAP | BS_NOTIFY | WS_VISIBLE,
                                      BTN_S2, 190, 40, 100, 100, hWnd, (DWORD)&pic_stuff2);
            LoadBitmap(p3, &pic_stuff3, "./img/stuff3.bmp");
            btn_stuff3 = CreateWindow(CTRL_BUTTON, "Stuff3",
                                      WS_CHILD | BS_PUSHBUTTON | BS_BITMAP | BS_NOTIFY | WS_VISIBLE,
                                      BTN_S3, 370, 40, 100, 100, hWnd, (DWORD)&pic_stuff3);
            SetNotificationCallback(btn_stuff1, buyStuff);
            SetNotificationCallback(btn_stuff2, buyStuff);
            SetNotificationCallback(btn_stuff3, buyStuff);
            status_stuff1 = CreateWindow(CTRL_STATIC, priceLabel1,
                                         WS_CHILD | SS_CENTER | WS_VISIBLE,
                                         STA_S1, 10, 150, 100, 20, hWnd, 0);
            status_stuff2 = CreateWindow(CTRL_STATIC, priceLabel2,
                                         WS_CHILD | SS_CENTER | WS_VISIBLE,
                                         STA_S2, 190, 150, 100, 20, hWnd, 0);
            status_stuff3 = CreateWindow(CTRL_STATIC, priceLabel3,
                                         WS_CHILD | SS_CENTER | WS_VISIBLE,
                                         STA_S3, 370, 150, 100, 20, hWnd, 0);
            btn_refund = CreateWindow(CTRL_BUTTON, "Refund Coin",
                                      WS_CHILD | BS_PUSHBUTTON | BS_NOTIFY | WS_VISIBLE,
                                      BTN_REFUND, 10, 180, 100, 40, hWnd, 0);
            SetNotificationCallback(btn_refund, refundCoin);
            EnableWindow(btn_refund, FALSE);
            btn_coin50 = CreateWindow(CTRL_BUTTON, "50",
                                      WS_CHILD | BS_PUSHBUTTON | BS_NOTIFY | WS_VISIBLE,
                                      BTN_C50, 180, 180, 40, 40, hWnd, 0);
            btn_coin10 = CreateWindow(CTRL_BUTTON, "10",
                                      WS_CHILD | BS_PUSHBUTTON | BS_NOTIFY | WS_VISIBLE,
                                      BTN_C10, 260, 180, 40, 40, hWnd, 0);
            btn_coin5 = CreateWindow(CTRL_BUTTON, "5",
                                      WS_CHILD | BS_PUSHBUTTON | BS_NOTIFY | WS_VISIBLE,
                                      BTN_C5, 340, 180, 40, 40, hWnd, 0);
            btn_coin1 = CreateWindow(CTRL_BUTTON, "1",
                                      WS_CHILD | BS_PUSHBUTTON | BS_NOTIFY | WS_VISIBLE,
                                      BTN_C1, 420, 180, 40, 40, hWnd, 0);
            SetNotificationCallback(btn_coin50, coinAction);
            SetNotificationCallback(btn_coin10, coinAction);
            SetNotificationCallback(btn_coin5, coinAction);
            SetNotificationCallback(btn_coin1, coinAction);
            return 0;
        case MSG_ERASEBKGND:
            return 0;
        case MSG_TIMER:
            break;
        case MSG_PAINT:
            hdc = BeginPaint(hWnd);
            EndPaint(hWnd, hdc);
            return 0;
        case MSG_KEYDOWN:
            return 0;
        case MSG_CLOSE:
            DestroyMainWindow(hWnd);
            PostQuitMessage(hWnd);
            return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 17
0
static int CounterDialogProc(HWND hcwd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC          hdc;
	RECT         rc;
	int          itemcount, i;
	char         buffer1[Max];
	char         buffer2[Max];
	static char  buffer3[Max];
	static float tal;
	static float tall;
	static float sum;
	char         *str;
	static char  ter1[Max] = {'+', '\0'};
	static char  ter2[Max] = {'-', '\0'};
	static char  ter3[Max] = {'*', '\0'};
	static char  ter4[Max] = {'/', '\0'};

	switch (message) {
	case MSG_CREATE:
		flag1 = 0;
		CreateWindow(CTRL_EDIT, "", WS_VISIBLE | WS_BORDER | ES_RIGHT, IDC_INPUT1,
			     15, 10, 280, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, MSG_RETURN, WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_RET1,
			     15, 45, 80, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "C", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_RET2,
			     105, 45, 80, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "9", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT2,
			     15, 80, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "8", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT3,
			     85, 80, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "7", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT4,
			     155, 80, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "+", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT5,
			     225, 80, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "6", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT6,
			     15, 115, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "5", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT7,
			     85, 115, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "4", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT8,
			     155, 115, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "-", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INPUT9,
			     225, 115, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "3", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT,
			     15, 150, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "2", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT1,
			     85, 150, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "1", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT2,
			     155, 150, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "*", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT3,
			     225, 150, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "0", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT4,
			     15, 185, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, ".", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT5,
			     85, 185, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "/", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT6,
			     155, 185, 60, 25, hcwd, 0);
		CreateWindow(CTRL_BUTTON, "=", WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON, IDC_INSERT7,
			     195, 45, 80, 25, hcwd, 0);
		break;

	case MSG_COMMAND:
	{
		switch (wParam)	{
		case IDC_INPUT2:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "9");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INPUT3:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "8");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INPUT4:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "7");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INPUT6:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "6");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INPUT7:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "5");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INPUT8:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "4");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INSERT:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "3");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INSERT1:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "2");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INSERT2:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			strcpy(buffer1, "1");
			strcat(buffer2, buffer1);
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag3 = 0;
			return 0;
		case IDC_INSERT4:
			if (flag3 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				buffer2[0] = '\0';
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			if (strcmp(buffer3, ter4) != 0)	{
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				strcpy(buffer1, "0");
				strcat(buffer2, buffer1);
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				flag3 = 0;
			}
			return 0;

		case IDC_INSERT5:
			if (flag1 == 0)	{
				flag1 = 1;
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				if (buffer2[0] == '\0') {
					strcpy(buffer1, "0");
					strcat(buffer2, buffer1);
					strcpy(buffer1, ".");
					strcat(buffer2, buffer1);
				} else   {
					strcpy(buffer1, ".");
					strcat(buffer2, buffer1);
				}
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			return 0;


		case IDC_INPUT5:
			if (flag2 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				str = buffer2;
				tal = atof(str);
				if (strcmp(buffer3, ter1) == 0)	{
					sum = tall + tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter2) == 0) {
					sum = tall - tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter3) == 0)            {
					sum = tall * tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter4) == 0)            {
					sum = tall / tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				}
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			str  = buffer2;
			tall = atof(str);
			strcpy(buffer3, "+");
			buffer2[0] = '\0';
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag1 = 0;
			flag2 = 1;
			return 0;
		case IDC_INPUT9:
			if (flag2 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				str = buffer2;
				tal = atof(str);
				if (strcmp(buffer3, ter1) == 0)	{
					sum = tall + tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter2) == 0)       {
					sum = tall - tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter3) == 0)              {
					sum = tall * tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter4) == 0)              {
					sum = tall / tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				}
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			str  = buffer2;
			tall = atof(str);
			strcpy(buffer3, "-");
			buffer2[0] = '\0';
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag1 = 0;
			return 0;
		case IDC_INSERT3:
			if (flag2 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				str = buffer2;
				tal = atof(str);
				if (strcmp(buffer3, ter1) == 0)	{
					sum = tall + tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter2) == 0) {
					sum = tall - tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter3) == 0)            {
					sum = tall * tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter4) == 0)            {
					sum = tall / tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				}
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			str  = buffer2;
			tall = atof(str);
			strcpy(buffer3, "*");
			buffer2[0] = '\0';
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag1 = 0;
			return 0;
		case IDC_INSERT6:
			if (flag2 == 1) {
				GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
				str = buffer2;
				tal = atof(str);
				if (strcmp(buffer3, ter1) == 0)	{
					sum = tall + tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter2) == 0) {
					sum = tall - tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter3) == 0)            {
					sum = tall * tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				} else if (strcmp(buffer3, ter4) == 0)            {
					sum = tall / tal;
					sprintf(buffer2, "%f", sum);
					SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
				}
			}
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			str  = buffer2;
			tall = atof(str);
			strcpy(buffer3, "/");
			buffer2[0] = '\0';
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag1 = 0;
			return 0;
		case IDC_INSERT7:
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			str = buffer2;
			//MessageBox(0,str,"",MB_OK);
			//MessageBox(0,buffer1,"",MB_OK);
			//printf("%f",tall);
			tal   = atof(str);
			flag1 = 1;
			if (strcmp(buffer3, ter1) == 0)	{
				sum = tall + tal;
				sprintf(buffer2, "%f", sum);
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			} else if (strcmp(buffer3, ter2) == 0)       {
				sum = tall - tal;
				sprintf(buffer2, "%f", sum);
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			} else if (strcmp(buffer3, ter3) == 0)               {
				sum = tall * tal;
				sprintf(buffer2, "%f", sum);
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			} else if (strcmp(buffer3, ter4) == 0)              {
				sum = tall / tal;
				sprintf(buffer2, "%f", sum);
				SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			}
			flag2 = 0;
			flag3 = 1;
			return 0;

		case IDC_RET2:
			GetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2, Max);
			buffer2[0] = '\0';
			SetWindowText(GetDlgItem(hcwd, IDC_INPUT1), buffer2);
			flag1 = 0;
			return 0;

		case IDC_RET1:
			//DestroyAllControls(hcwd);
			DestroyMainWindow(hcwd);
			PostQuitMessage(hcwd);
			return 0;
		}
	}
	break;

	case MSG_DESTROY:
		DestroyAllControls(hcwd);
		return 0;

	case MSG_CLOSE:
		DestroyMainWindow(hcwd);
		PostQuitMessage(hcwd);
		return 0;
	}
	return DefaultMainWinProc(hcwd, message, wParam, lParam);
}
Exemplo n.º 18
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.º 19
0
static int ControlOneLogWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{

	HDC hdc;
	HWND statushWnd;
	static char keyupFlag=0;
	switch (message)
	{
		case MSG_CREATE:
			{
				LoadBitmap(HDC_SCREEN,&onequerybmp,GetBmpPath("warningsmall.gif"));

				if (gfont1==NULL) {
					logqyfont = CreateLogFont (NULL,"fixed","GB2312",FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, 
							FONT_SETWIDTH_NORMAL,FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,12, 0);
					logqyfont1 = CreateLogFont (NULL,"fixed","GB2312",FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, 
							FONT_SETWIDTH_NORMAL,FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,12, 0);
				} else {
					logqyfont1=gfont1;
					logqyfont=gfont1;
				}
				if (gOptions.ShowState){
					g_celcount=5;
				} else {
					g_celcount=4;
				}
				statushWnd = createStatusWin1(hWnd , 250 , 50 , LoadStrByID(MID_APPNAME) , LoadStrByID(MID_WAIT));
				ProcessFindLog(hWnd,oneuserpin,onesttm,oneedtm);
				destroyStatusWin1(statushWnd);
				SetFocusChild(hOneLogWnd);
				SendMessage(hOneLogWnd,LVM_CHOOSEITEM,0,0);
				processlogstateandvf(hWnd);
				return 0;
			}
			/*
			   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, 210, 32, 32, &onequerybmp);
			   if (fGetDC)
			   ReleaseDC (hdc);
			   return 0;
			   }
			   */
		case MSG_PAINT:
			SetMenuTimeOut(time(NULL));
			hdc=BeginPaint(hWnd);
			//FillBoxWithBitmap (hdc, 10, 217, 24, 24, &onequerybmp);
			FillBoxWithBitmap (hdc, 10+gOptions.GridWidth, 215, 24, 24, &onequerybmp);
			EndPaint(hWnd,hdc);
			return 0;

		case MSG_COMMAND:
			if (wParam == IDCANCEL){
				SendMessage (hWnd, MSG_CLOSE, 0, 0L);
				break;
			}

			if ((LOWORD(wParam)==IDC_LISTVIEW) &&(HIWORD(wParam)==LVN_SELCHANGE)){
				processlogstateandvf(hWnd);
			}
			break;

		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 ) {
				SendMessage (hWnd, MSG_CLOSE, 0, 0L);
			}

			if(LOWORD(wParam)==SCANCODE_F12) {
				SendMessage(hOneLogWnd,MSG_KEYDOWN,SCANCODE_PAGEDOWN,0);
				processscrollview(hOneLogWnd,1,10);
			}

			if(LOWORD(wParam)==SCANCODE_F11) {
				SendMessage(hOneLogWnd,MSG_KEYDOWN,SCANCODE_PAGEUP,0);
				processscrollview(hOneLogWnd,0,10);
			}
			break;
		case MSG_CLOSE:
			UnloadBitmap(&onequerybmp);
			if (gfont==NULL) {
				DestroyLogFont(logqyfont);
				DestroyLogFont(logqyfont1);
			}
			DestroyMainWindow(hWnd);
			return TRUE;

	}
	return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
Exemplo n.º 20
0
static int FaceEnrollWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int ret=0;
	RECT rect={142,221,180,240};

	switch (message) 
	{
		case MSG_CREATE:
			UpdateFaceRegWindow( hWnd, hdc);
			InitShowFaceImage();
			FaceRegState=FACE_REG_PREPARE;

			SetTimer(hWnd, IDC_FACE_TIMER1, IDC_TIMER_NUM);
			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);
                        }
			UpdateFaceRegWindow(hWnd,hdc);

                        if(fGetDC) ReleaseDC (hdc);
                        	return 0;
                }
			return 0;
		
                case MSG_PAINT:
		{
			char buf[20];
                        hdc = BeginPaint(hWnd);
			SelectFont(hdc,gfont);
			SetTextColor(hdc,PIXEL_lightwhite);
       	 		SetBkMode(hdc,BM_TRANSPARENT);
                        SetPenColor(hdc,PIXEL_black);
    			SetBrushColor(hdc,PIXEL_lightgray);
			SetPenWidth(hdc, 2);
			LineEx(hdc,-1,221,322,222);
			FillBox(hdc,-1,223,322,20);
			if(RegBegin == REG_PREPARE)
			{
				sprintf(buf,"0%%");
				TextOut(hdc,145,225,buf);
			}
			else
			{
                        	SetBrushColor (hdc, PIXEL_blue);
                        	if(FaceCount>=FACE_NUM)  // 0,220,320,20
                        	{
                        	        FillBox(hdc,1,223,318,17);
					sprintf(buf,"100%%");
					TextOut(hdc,145,225,buf);
                        	}
                        	else if(FaceCount>0)
                        	{
                        	        FillBox(hdc,1,223,320*FaceCount/FACE_NUM,17);
					sprintf(buf,"%d%%",100*FaceCount/FACE_NUM);
					TextOut(hdc,145,225,buf);
                        	}
				else
				{
					sprintf(buf,"0%%");
					TextOut(hdc,145,225,buf);
				}
			}
                        EndPaint(hWnd,hdc);
		}
		return 0;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
                        if (gOptions.KeyPadBeep)
                                ExKeyBeep();

			if(LOWORD(wParam) == SCANCODE_ESCAPE)
				PostMessage (hWnd, MSG_CLOSE, 0, 0);
			break;

		case MSG_TIMER:
			if (wParam == IDC_FACE_TIMER1)
			{
				KillTimer(hWnd, IDC_FACE_TIMER1);
				if(ismenutimeout)
				{
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
					return 0;
				}
				hdc=GetClientDC(hWnd);
				if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
				{
					RegCnt=1;
					FaceRegState=FACE_REG_PREPARE;
					ShowFaceHint(hWnd , FACE_REG_PREPARE , hdc, &fvbg,1);
					if(gOptions.VoiceOn)
						ExPlayVoice(VOICE_FACE_START); //start...
					DelayMS(1000);
				}
				if(ShowCaptureFace( hWnd,HDC_SCREEN ,1)) //Extract face template ok
				{

					SetMenuTimeOut(time(NULL));
					ret=RegFaceTmpProc(f_pin);

					if(RET_SUCCESS==ret) //register success
					{
						SendMessage (hWnd, MSG_PAINT, FACE_NUM, 0) ;
						regok=1;
						if(gOptions.VoiceOn)
                                			ExPlayVoice(VOICE_THANK); 
						DelayMS(500);
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_FAILED==ret) // register failed
					{
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_SAME==ret && RegBegin != REG_PREPARE) // move face
					{
						ShowFaceHint(hWnd , HINT_FCHG ,hdc, &fvbg,1);
					}
					else if(RET_CONTINUE==ret)
					{
						if(RegBegin != REG_PREPARE)
						{
							SendMessage (hWnd, MSG_PAINT , FaceCount, 0) ;
							if(FaceCount == 0)
							{
								FaceRegState=FACE_REG_FRONT;
								ShowFaceHint(hWnd , FACE_REG_FRONT , hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_FRONT); 
								DelayMS(600);
							}
							else if(FaceCount == 3)
							{
								FaceRegState=FACE_REG_SCREEN;
								ShowFaceHint(hWnd , FACE_REG_SCREEN ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_SCREEN); 
								DelayMS(600);
							}
							else if(FaceCount == 6)
							{
								FaceRegState=FACE_REG_LEFT;
								ShowFaceHint(hWnd , FACE_REG_LEFT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_LEFT); 
								DelayMS(600);
							}
							else if(FaceCount == 9)
							{
								FaceRegState=FACE_REG_RIGHT;
								ShowFaceHint(hWnd , FACE_REG_RIGHT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_RIGHT); 
								DelayMS(600);
							}
							else if(FaceCount == 12)
							{
								FaceRegState=FACE_REG_CAMERA;
								ShowFaceHint(hWnd ,FACE_REG_CAMERA ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_CAMERA); 
								DelayMS(600);
							}
							else
							{
			                        		ExBeep(1);
							}
						}
						else
						{
			                        	ExBeep(1);
						}
					}
				}
				ReleaseDC(hdc);
				SetTimer(hWnd, IDC_FACE_TIMER1,IDC_TIMER_NUM );
			}
			break;

		case MSG_IDLE:
			if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
 		        {
                        	RegCnt=1;
				FaceRegState=FACE_REG_PREPARE;
				hdc=GetClientDC(hWnd);
				ShowFaceHint(hWnd , FACE_REG_PREPARE ,hdc, &fvbg,1);
				if(gOptions.VoiceOn)
                			ExPlayVoice(VOICE_FACE_START); //start...
				DelayMS(1000);
				ReleaseDC(hdc);
                        }
			break;

		case MSG_CLOSE:
			KillTimer(hWnd, IDC_FACE_TIMER1);


         		// MainWindowCleanup(hWnd);
                        DestroyMainWindow(hWnd);
		        return 0;
        
	}
    
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 21
0
static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
static HWND hwnd;
static int i = 0;
switch (message) {
case MSG_PAINT:
hdc = BeginPaint (hWnd);
TextOut (hdc, 60, 60, "Hello world!");
EndPaint (hWnd, hdc);
return 0;
case 888888888888888888:
        {

            HDC hdc2 = (HDC)wParam;
            const RECT* clip = (const RECT*) lParam;
            BOOL fGetDC = FALSE;
            RECT rcTemp;

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

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

            FillBoxWithBitmap (HDC_SCREEN, 0, 0, 0, 0, &bmp_bkgnd);

            if (fGetDC)
                ReleaseDC (hdc2);
            return 0;
        }
        break;
case MSG_CREATE:
	hwnd = CreateWindowEx("static", "",
			WS_CHILD | WS_VISIBLE,
			WS_EX_NONE,
			123,
			0, 0, 50, 50,
			hWnd, NULL);
	SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10));
break;
case MSG_KEYDOWN:
	if (i) {
	SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10));
	} else {
	SetWindowBkColor(hwnd, RGB2Pixel(HDC_SCREEN, 0x00, 0xff, 0xff));
	}
	i = 1-i;
break;
case MSG_CLOSE:
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;

}
return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
Exemplo n.º 22
0
int CIMEWnd::MsgProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    switch (message) {
        case MSG_PAINT:
            hdc = BeginPaint (hwnd);
            draw_border (hwnd, hdc);
            logo.Show(hdc, IMELOGO_LEFT,IMELOGO_TOP,1);
            icon.Show (hdc,imeRect.left,   imeRect.top,   imemgr.cur_ime_bmp_idx);
            icon.Show (hdc,subimeRect.left,subimeRect.top,imemgr.cur_subime_bmp_idx);
            EndPaint (hwnd, hdc);
            break;
        case MSG_LBUTTONDOWN:
        {
               old_x = LOWORD(lParam);
               old_y = HIWORD(lParam);
               int ret = Key_Check(old_x,old_y);

               if(ret == 1)
               {
                    changeInputMothed(hwnd);
               }else if(ret == 2)
               {
                  if(imemgr.cur_ime_type == IME_QUANPIN)
                  {
                      SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0);
                      SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0);
                  }else if(imemgr.cur_ime_type == IME_T9){
                      SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0);
                      SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0);
                  }else{
                     //关闭状态不用发消息
                  }
              }else{
                SetCapture (hwnd);
                ClientToScreen (hwnd,&old_x,&old_y);
                fCaptured=true;
              }
               break;
           }
        case MSG_LBUTTONUP:
        {
                if(fCaptured){
                    ReleaseCapture ();
                    fCaptured=false;
                }
        }
        break;

    case MSG_MOUSEMOVE:
    {
        if (fCaptured)
        {
            RECT rcWindow;
            GetWindowRect(hwnd, &rcWindow);
            int x = LOSWORD(lParam);
            int y = HISWORD(lParam);
/*
            if( rcWindow.left < 0)
                rcWindow.left = 0;
            if(rcWindow.right > 800)
                rcWindow.right = 800;
            if( rcWindow.top < 0)
                rcWindow.top = 0;
            if(rcWindow.bottom > 480)
                rcWindow.bottom = 480;
                */
            OffsetRect(&rcWindow, x - old_x, y - old_y);
            //if( (rcWindow.left > 0) && (rcWindow.right < 800) &&  (rcWindow.top > 0) && (rcWindow.bottom < 480))
            {
                MoveWindow(hwnd, rcWindow.left, rcWindow.top, RECTW(rcWindow),
                           RECTH(rcWindow), TRUE);
                //RECT rc;
                //GetWindowRect(hWnd, &rc);
                //DPRINTF(JINFO, "rc %d %d\n",rc.left,rc.top);
                //g_SKB->move(rc.left, rc.top - 50);
                old_x = x;
                old_y = y;
            }

        }
        break;
    }
        case MSG_USER_IME_STATUS:
            {
                int type = imemgr.changeIme ();
                //fprintf(stderr,"get type %d \n",type);
                if(type == IME_CLOSE){
                    //std::cerr << "ime close\n";
                    mgiSetActiveIMEWindow(imecon_handle,"");
                }else if(type == IME_QUANPIN){
                    mgiSetActiveIMEWindow(imecon_handle,"quanpin");
                }else if(type == IME_T9){
                    //fprintf(stderr,"change to mgphone\n");
                    if(!mgiSetActiveIMEWindow(imecon_handle,"mgphone"))
                    {
                        fprintf(stderr,"change ime to mgphone faild\n");
                    }else
                    {
                        SendNotifyMessage (t9_ime_hwnd, MSG_IME_OPEN, 0, 0);
                        ShowWindow (t9_ime_hwnd,SW_SHOW);
                    }

                }
                InvalidateRect (hwnd,&refRect,TRUE);
            }
            break;
    };
    return DefaultMainWinProc (hwnd, message, wParam, lParam);
}
static int HelloWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    syskey = "";

    switch (message) {
        case MSG_CREATE:
            make_welcome_text ();
            SetTimer (hWnd, 100, 200);
            break;

        case MSG_TIMER:
            sprintf (msg_text, HL_ST_TIMER, 
                            GetTickCount ());
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;
            
        case MSG_LBUTTONDOWN:
            strcpy (msg_text, HL_ST_LBD);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_LBUTTONUP:
            strcpy (msg_text, HL_ST_LBU);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_RBUTTONDOWN:
            strcpy (msg_text, HL_ST_RBD);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_RBUTTONUP:
            strcpy (msg_text, HL_ST_RBU);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_PAINT:
            hdc = BeginPaint (hWnd);
            DrawText (hdc, welcome_text, -1, &welcome_rc, DT_LEFT | DT_WORDBREAK);
            DrawText (hdc, msg_text, -1, &msg_rc, DT_LEFT | DT_WORDBREAK);
            EndPaint (hWnd, hdc);
            return 0;

        case MSG_SYSKEYDOWN:
            syskey = HL_ST_SYS;
        case MSG_KEYDOWN:
            if(last_key == wParam)
                last_key_count++;
            else
            {
                last_key = wParam;
                last_key_count = 1;
            }
            sprintf (msg_text, HL_ST_KEYD, 
                            wParam, syskey, last_key_count);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            return 0;

        case MSG_KEYLONGPRESS:
            sprintf (msg_text, HL_ST_KEYLONG, wParam);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_KEYALWAYSPRESS:
            sprintf (msg_text, HL_ST_KEYALWAY, wParam);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            break;

        case MSG_KEYUP:
            sprintf (msg_text, HL_ST_KEYU, wParam);
            InvalidateRect (hWnd, &msg_rc, TRUE);
            return 0;

        case MSG_CLOSE:
            KillTimer (hWnd, 100);
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
            return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 24
0
static int CoolIndicatorCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC              hdc;
    PCOOL_INDICATOR_CTRL TbarData;
        
	//db_msg("message is %s, wParam: 0x%x, lParam: 0x%lx\n", Message2Str(message), wParam, lParam);
    switch (message) {
    case MSG_CREATE:
		{
			DWORD data; 
            DWORD dwStyle;

			//db_info("Cool Indicator ctrl proc\n");
            if ((TbarData = (COOL_INDICATOR_CTRL*) calloc (1, sizeof (COOL_INDICATOR_CTRL))) == NULL)
                return 1;

            TbarData->nCount = 0;
            TbarData->head = TbarData->tail = NULL;
            TbarData->BackBmp = NULL;
            TbarData->iSel = 0;
            TbarData->hToolTip = 0;

            //ExcludeWindowStyle (hWnd, WS_BORDER);

            dwStyle = GetWindowStyle (hWnd);
            if (dwStyle & CBS_BMP_CUSTOM) {
                data = GetWindowAdditionalData (hWnd);
                TbarData->ItemWidth = LOWORD (data);
                TbarData->ItemHeight = HIWORD (data);
				int screenW,screenH;
				getScreenInfo(&screenW,&screenH);
                TbarData->ItemHeight = 	screenH/8;
            }
            else {
                TbarData->ItemWidth = 16;
                TbarData->ItemHeight = 16;
            }

            SetWindowAdditionalData2 (hWnd, (DWORD)TbarData);
		}
		break;

	case MSG_DESTROY:
        { 
            COOL_INDICATOR_ITEMDATA* unloaddata, *tmp;
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);
            if (TbarData->hToolTip != 0) {
                DestroyCdrToolTipWin(TbarData->hToolTip);
                TbarData->hToolTip = 0;
            }

            if (TbarData->BackBmp) {
                UnloadBitmap (TbarData->BackBmp);
                free (TbarData->BackBmp);
            }

            unloaddata = TbarData->head;
            while (unloaddata) {
                tmp = unloaddata->next;
                free (unloaddata);
                unloaddata = tmp;
            }

            free (TbarData);
        }
        break;
	
	case MSG_SHOWWINDOW:
		{
			if(wParam == SW_SHOWNORMAL) {
				enable_hint = TRUE;
			} else {
				enable_hint = FALSE;
			}
		}
		break;

	case MSG_SIZECHANGING:
        {
            const RECT* rcExpect = (const RECT*)wParam;
            RECT* rcResult = (RECT*)lParam;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);

            rcResult->left = rcExpect->left;
            rcResult->top = rcExpect->top;
            rcResult->right = rcExpect->right;
            rcResult->bottom = rcExpect->top + TbarData->ItemHeight + 14;
            return 0;
        }
		break;

	case MSG_SIZECHANGED:
		{
			RECT* rcWin = (RECT*)wParam;
			RECT* rcClient = (RECT*)lParam;
			*rcClient = *rcWin;
			return 1;
		}
		break;

	case MSG_FONTCHANGED:
		{
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);

			PLOGFONT logfont = GetWindowFont(hWnd);
			//db_msg("MSG_FONTCHANGED, type :%s, familyt: %s, charset: %s\n", logfont->type, logfont->family, logfont->charset);
			if(TbarData != NULL && TbarData->hToolTip != 0) {
				SetWindowFont(TbarData->hToolTip, logfont );
			}
		}
		break;

    case MSG_NCPAINT:
        return 0;

	case MSG_PAINT:	//todo: why MSG_PAINT is received early than MSG_CREATE?
        {
            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2(hWnd);
			if (TbarData == NULL) {
				break;
			}
            hdc = BeginPaint (hWnd);

			PLOGFONT logfont = GetWindowFont(hWnd);

			SelectFont(hdc, logfont );
            DrawCoolBox (hWnd, hdc, TbarData);
            EndPaint (hWnd, hdc);
            return 0;
        }
		break;

	case CBM_ADDITEM:
        {
            COOL_INDICATOR_ITEMINFO* TbarInfo = NULL;
            COOL_INDICATOR_ITEMDATA* ptemp;
            RECT rc;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);
            TbarInfo = (COOL_INDICATOR_ITEMINFO*) lParam;

            if (!(ptemp = (COOL_INDICATOR_ITEMDATA*)calloc (1, sizeof (COOL_INDICATOR_ITEMDATA)))) {
                return -1;
            }

            GetClientRect (hWnd, &rc);

			//db_msg("add item id is %d\n", TbarInfo->id);
            ptemp->id = TbarInfo->id;
            ptemp->Disable = 0;
            ptemp->ItemType = TbarInfo->ItemType;
			ptemp->sliderColor = TbarInfo->sliderColor;

           // if (TbarInfo->ItemHint) {
            //    strncpy (ptemp->Hint, TbarInfo->ItemHint, LEN_HINT);
            //    ptemp->Hint [LEN_HINT] = '\0';
            //}
           // else
                ptemp->Hint [0] = '\0';

            if (TbarInfo->Caption) {
                strncpy (ptemp->Caption, TbarInfo->Caption, LEN_TITLE);
                ptemp->Caption [LEN_TITLE] = '\0';
            }
            else
                ptemp->Caption [0] = '\0';
             
            ptemp->Bmp = TbarInfo->Bmp;

            set_item_rect (hWnd, TbarData, ptemp); 

            ptemp->next = NULL;
            if (TbarData->nCount == 0) {
                TbarData->head = TbarData->tail = ptemp;
            }
            else if (TbarData->nCount > 0) { 
                TbarData->tail->next = ptemp;
                TbarData->tail = ptemp;
            }
            TbarData->nCount++;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;
        }
		break;

	case CBM_CLEARITEM:
		{
            COOL_INDICATOR_ITEMINFO* TbarInfo = NULL;
            COOL_INDICATOR_ITEMDATA *ptemp1, *ptemp2;

            TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);
            TbarInfo = (COOL_INDICATOR_ITEMINFO*) lParam;

			ptemp1 = TbarData->head;
            while (ptemp1) {
                ptemp2 = ptemp1->next;
				ptemp1->next = NULL;
                free (ptemp1);
                ptemp1 = ptemp2;
            }
			TbarData->head = TbarData->tail = NULL;
            TbarData->nCount = 0;
			TbarData->iSel = 0;
		}
		break;

	case CBM_SWITCH2NEXT:
		{
			TbarData = (PCOOL_INDICATOR_CTRL) GetWindowAdditionalData2 (hWnd);

			TbarData->iSel++;
			if(TbarData->iSel >= TbarData->nCount) {
				TbarData->iSel = 0;
			}
			db_info("switch to next, iSel is %d\n", TbarData->iSel);
            InvalidateRect (hWnd, NULL, TRUE);
		}
		break;

	case CBM_ENABLE:
		{
            TbarData = (PCOOL_INDICATOR_CTRL)GetWindowAdditionalData2 (hWnd);
            if (enable_item (TbarData, wParam, lParam))
                return -1;

            InvalidateRect (hWnd, NULL, TRUE);
            return 0;
		}
		break;
	default:
		break;
	}

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 25
0
static int CallWinProc(HWND hcwd, int message, WPARAM wParam, LPARAM lParam)
{
	HWND Kb;
	switch (message) {
	case MSG_CREATE:
		CreateWindow(CTRL_STATIC,
			     MSG_INPUT_NUMBER,
			     WS_VISIBLE,
			     IDC_STA,
			     0, 0, 80, 20,
			     hcwd,
			     0);
		CreateWindow(CTRL_STATIC,
			     "",
			     WS_VISIBLE,
			     IDC_STAW,
			     100, 20, 120, 20,
			     hcwd,
			     0);
		hedit = CreateWindow(CTRL_EDIT,
				     "",
				     WS_CHILD | WS_VISIBLE | WS_BORDER,
				     IDC_EDIT,
				     100, 0, 120, 20,
				     hcwd,
				     0);
		SetNotificationCallback(GetDlgItem(hcwd, IDC_EDIT), ContactNotifProc);

		/*CreateWindow ( CTRL_BUTTON,
			     "編輯",
						     WS_CHILD|WS_VISIBLE,
			     IDC_MAKE,
						     120,50,65,20,
			     hcwd,
			     0);*/
		CreateWindow( CTRL_BUTTON,
			      MSG_OK,
			      WS_CHILD | WS_VISIBLE,
			      IDC_OK,
			      50, 50, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      MSG_PHONEBOOK,
			      WS_CHILD | WS_VISIBLE,
			      IDC_BOOK,
			      255, 0, 65, 30,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      MSG_CANCEL,
			      WS_CHILD | WS_VISIBLE,
			      IDC_CANCEL,
			      190, 50, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "1",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM1,
			      50, 80, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "2",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM2,
			      120, 80, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "3",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM3,
			      190, 80, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "4",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM4,
			      50, 110, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "5",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM5,
			      120, 110, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "6",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM6,
			      190, 110, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "7",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM7,
			      50, 140, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "8",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM8,
			      120, 140, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "9",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM9,
			      190, 140, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "*",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUMX,
			      50, 170, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "0",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUM0,
			      120, 170, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      "#",
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUMY,
			      190, 170, 65, 20,
			      hcwd,
			      0);
		CreateWindow( CTRL_BUTTON,
			      MSG_EXIT,
			      WS_CHILD | WS_VISIBLE,
			      IDC_NUMQ,
			      0, 190, 65, 30,
			      hcwd,
			      0);

		/* CreateWindow ( CTRL_BUTTON,
				      "軟鍵盤",
							      WS_CHILD|WS_VISIBLE,
				      IDC_NUMS,
							      255,190,65,30,
				      hcwd,
				      0);	 */
		SetTimer(hcwd, _IDC_TIMER, 100);

		break;
	case MSG_TIMER:
	{
		if (wParam == _IDC_TIMER) {
			if (flag) {
				T++;
				maintime = maintime + T;
				sprintf(buffer, "%02d:%02d:%02d", T / 3600, (T % 3600) / 60, (T % 3600) % 60);
				SetWindowText(GetDlgItem(hcwd, IDC_STAW), buffer);
			}
		}
	}
	case MSG_COMMAND:
	{
		switch (wParam)	{
		case IDC_NUM1:
			SendMessage(GetDlgItem(hcwd, IDC_NUM1), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM2:
			SendMessage(GetDlgItem(hcwd, IDC_NUM2), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM3:
			SendMessage(GetDlgItem(hcwd, IDC_NUM3), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM4:
			SendMessage(GetDlgItem(hcwd, IDC_NUM4), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM5:
			SendMessage(GetDlgItem(hcwd, IDC_NUM5), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM6:
			SendMessage(GetDlgItem(hcwd, IDC_NUM6), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM7:
			SendMessage(GetDlgItem(hcwd, IDC_NUM7), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM8:
			SendMessage(GetDlgItem(hcwd, IDC_NUM8), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM9:
			SendMessage(GetDlgItem(hcwd, IDC_NUM9), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUMX:
			SendMessage(GetDlgItem(hcwd, IDC_NUMX), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUM0:
			SendMessage(GetDlgItem(hcwd, IDC_NUM0), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;
		case IDC_NUMY:
			SendMessage(GetDlgItem(hcwd, IDC_NUMY), MSG_GETTEXT, 1, (LPARAM)buff1);
			strcat(buff, buff1);
			SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 1, (LPARAM)buff);
			break;

		case IDC_BOOK:
			Menu();
			break;

		case IDC_OK:
			flag = 1;
			if (flagcall == 1) {
				if (flag_call_ans == 1)	{
					gprs_ans();
					flagcall = 0;
				}
				if (buff[0] != '\0') {
					gprs_call(buff, strlen(buff));
					strcpy(buff, MSG_DIAL);
					SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 0, (LPARAM)buff);
					flagcall = 0;
				}
			}
			break;
		case IDC_CANCEL:
			flag = 0;
			T    = 0;
			sprintf(buffer1, "%02d:%02d:%02d", 0, 0, 0);
			SetWindowText(GetDlgItem(hcwd, IDC_STAW), buffer1);
			fp = fopen(FILE_LAST_TIME_DAT, "w");
			fwrite(buffer, sizeof(buffer), 1, fp);
			fclose(fp);
			if (flagcall == 0) {
				gprs_hold();
				flagcall = 1;
				strcpy(buff, MSG_HUNG_UP);
				SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, 0, (LPARAM)buff);
			} else      {
				i           = strlen(buff);
				buff[i - 1] = '\0';
				SendMessage(GetDlgItem(hcwd, IDC_EDIT), MSG_SETTEXT, i - 1, (LPARAM)buff);
			}
			break;
		case IDC_NUMQ:
			flag = 0;
			T    = 0;
			KillTimer(hcwd, _IDC_TIMER);
			//DestroyMainWindow (hcwd);
			//PostQuitMessage (hcwd);
			ShowWindow(hcwd, SW_HIDE);
			break;

		/*  case IDC_NUMS:
				if(KBOn==0)
				      {
						      KBOn = 1;
						      CreateKeyBoard(hcwd);
				      }
				      else
				{
						      KBOn = 0;
					  Kb = GetFirstHosted(hcwd);
					  DestroyAllControls (Kb);
					  DestroyMainWindow (Kb);
			      PostQuitMessage (Kb);
				}

		   break;  */
		default: break;
		}
	}
	break;
	case MSG_TAG:
		ShowWindow(hcwd, SW_SHOWNORMAL);
		break;
	case MSG_RING:
		ShowWindow(hcwd, SW_SHOWNORMAL);
		if (IDYES == MessageBox(hcwd, MSG_PHONE_CALL, MSG_INDICATION, MB_YESNO)) {
			flag_call_ans = 1;
			flagcall == 1;
		} else   {
			gprs_hold();
		}
		return 0;
	case MSG_DESTROY:
		DestroyAllControls(hcwd);
		return 0;

	case MSG_CLOSE:
		flag = 0;
		T    = 0;
		KillTimer(hcwd, _IDC_TIMER);
		DestroyMainWindow(hcwd);
		PostQuitMessage(hcwd);
		return 0;
	}

	return DefaultMainWinProc(hcwd, message, wParam, lParam);
}
Exemplo n.º 26
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);
}
static int ControlTestWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_CREATE:
    {
        int i;
        COOLBARITEMINFO cbii;
        HWND coolbar1, coolbar2, coolbar3, coolbar4;

        coolbar1 = CreateWindow (CTRL_COOLBAR,
                              "",
                              WS_CHILD | WS_VISIBLE | CBS_BMP_CUSTOM,
                              IDC_COOLBAR1,
                              0, 0,
                              52 * (NM_BARPIC + 1), 0,
                              hWnd, MAKELONG (48, 48));
           
        coolbar2 = CreateWindow (CTRL_COOLBAR,
                              "",
                              WS_CHILD | WS_VISIBLE | CBS_BMP_32X32,
                              IDC_COOLBAR2,
                              0, 100,
                              36 * (NM_BARPIC + 1), 0, hWnd, 0);

        coolbar3 = CreateWindow (CTRL_COOLBAR,
                              "",
                              WS_CHILD | WS_VISIBLE,
                              IDC_COOLBAR3,
                              0, 230,
                              20 * (NM_BARPIC + 1), 0, hWnd, 0);
           
        coolbar4 = CreateWindow (CTRL_COOLBAR,
                              "res/bkgnd.gif",
                              WS_CHILD | WS_VISIBLE | CBS_USEBKBMP | CBS_BMP_CUSTOM,
                              IDC_COOLBAR4,
                              0, 170,
                              240, 0, hWnd, MAKELONG (20, 20));
           
        for (i = 0; i < NM_BARPIC; i++) {
            LoadBitmapFromFile (HDC_SCREEN, bmps+i, barpic[i]);
            cbii.id = IDC_BAR + i + 1;
            cbii.ItemType = TYPE_BMPITEM;
            cbii.Bmp = bmps + i;
            cbii.ItemHint = barhint[i];
            cbii.Caption = NULL;
            cbii.dwAddData = 0;
            SendMessage (coolbar1, CBM_ADDITEM, 0, (LPARAM)&cbii);
            SendMessage (coolbar2, CBM_ADDITEM, 0, (LPARAM)&cbii);
            SendMessage (coolbar3, CBM_ADDITEM, 0, (LPARAM)&cbii);

            if (i == 3) {
                cbii.ItemType = TYPE_BARITEM;
                SendMessage (coolbar4, CBM_ADDITEM, 0, (LPARAM)&cbii);
            }

            if (i >= 3) {
                cbii.ItemType = TYPE_TEXTITEM;
                cbii.Bmp = NULL;
                cbii.ItemHint = barhint[i];
                cbii.Caption = barhint[i];
                cbii.dwAddData = 0;
            }

            SendMessage (coolbar4, CBM_ADDITEM, 0, (LPARAM)&cbii);
        }
        break;
    }
       	
    case MSG_COMMAND:
    {
#if 0
        int id = LOWORD (wParam);
        int nc = HIWORD (wParam);
#endif

        break;
    }

    case MSG_DESTROY:
    {
        int i;

        for (i = 0; i < 6; i++)
            UnloadBitmap (bmps+i);

        hMainWnd = HWND_INVALID;
        return 0;
    }

    case MSG_CLOSE:
        DestroyAllControls (hWnd);
        DestroyMainWindow (hWnd);
        MainWindowCleanup (hWnd);
        return 0;

    default:
        break;
    }

    return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
static int ControlTestWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case MSG_CREATE:
              create_combobox (hWnd);

              CreateWindow (CTRL_STATIC,
                        selected_, 
                        WS_CHILD | WS_VISIBLE | SS_SIMPLE, 
                        IDC_SELECTED, 
                        210, 10, 200, 25, hWnd, 0);

              CreateWindow (CTRL_BUTTON,
                        Close, 
                        WS_CHILD | WS_VISIBLE, 
                        IDCANCEL, 
                        320, 190, 60, 25, hWnd, 0);

        break;

        case MSG_COMMAND:
        {
            int id   = LOWORD(wParam);
            int code = HIWORD(wParam);
            char str [NAME_MAX + 20], file [NAME_MAX + 1];
            int selected; 

            if (wParam == IDCANCEL) {
                PostMessage (hWnd, MSG_CLOSE, 0, 0);
                break;
            }

            switch (id) {
            case IDC_BOX1:
                if (code != CBN_SELCHANGE)
                    break;

                selected = SendDlgItemMessage (hWnd, IDC_BOX1, CB_GETCURSEL,0,0);
                if (selected >= 0) {
                    SendDlgItemMessage (hWnd, IDC_BOX1, CB_GETLBTEXT, selected, (LPARAM)file);
                    if (strlen (file)) {
                        sprintf (str, "Selected: %s", file);
                        SetDlgItemText (hWnd, IDC_SELECTED, str);
                    }
                }
                break;
            }

        }
        break;

        case MSG_DESTROY:
            DestroyAllControls (hWnd);
            hMainWnd = HWND_INVALID;
	    return 0;

        case MSG_CLOSE:
            DestroyMainWindow (hWnd);
            MainWindowThreadCleanup (hWnd);
            return 0;
    }

    return  DefaultMainWinProc(hWnd, message, wParam, lParam);
}
static int PaletteWndProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	
	switch ( message ) {
	case MSG_SETCURSOR:
        SetCursorEx(0, FALSE);
        return 0;
 case MSG_CREATE:
        /* fill our palette with a gradually altering sequence of colors */
        for (c=0; c<64; c++) {
            palette[c].r = c*4;
            palette[c].g = 0;
            palette[c].b = 0;
        }
        for (c=64; c<128; c++) {
            palette[c].r = (127-c)*4;
            palette[c].g = (c-64)*4;
            palette[c].b = 0;
        }
        for (c=128; c<192; c++) {
            palette[c].r = 0;
            palette[c].g = (191-c)*4;
            palette[c].b = (c-128)*4;
        }
        for (c=192; c<256; c++) {
            palette[c].r = 0;
            palette[c].g = 0;
            palette[c].b = (255-c)*4;
        }
        SetTimer(hWnd, IDT_PAL, 1); 
        mem_dc = CreateCompatibleDC (hdc);
	break;
	case MSG_TIMER:
		switch(wParam){
            case IDT_PAL:
		temp = palette[255];
		for (c =255; c>0; c--)
		palette[c] = palette [c-1];
		palette[0] = temp;
		SetPalette(mem_dc, 0, 255, palette);

                for (c=255; c>0; c--){
                    pix = RGB2Pixel (mem_dc, palette[c].r, palette[c].g, palette[c].b);
                    SetBrushColor (mem_dc, pix);
                    FillCircle (mem_dc, SCREEN_W/2, SCREEN_H/2, c);
                }
		InvalidateRect (hWnd , NULL , FALSE);
                break;
        }
        break;
	case MSG_PAINT:
		hdc = BeginPaint(hWnd);	
		BitBlt (mem_dc, 0, 0, SCREEN_W, SCREEN_H, hdc, 0, 0, 0);
                
		EndPaint(hWnd, hdc);
	break;
	case MSG_CLOSE:
		KillTimer(hWnd , IDT_PAL);
		DeleteCompatibleDC(mem_dc);
		DestroyMainWindow (hWnd);
		PostQuitMessage (hWnd);
		break;
	}
		

	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
static int ScrollbarProc(HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    /** IDC of SCROLLBAR control */
    static int _my_scroll_idc = 100;

    /** scrollbar handle of main window  */
    static HWND hwnd_sb_main;

    /** scrollbar handle of control */
    HWND hwnd_sb_ctrl;

    switch (message)
    {
        case MSG_CREATE:
            {
                _rect_invalid.left   = SEP;
                _rect_invalid.top    = 0;
                _rect_invalid.right  = g_rcScr.right;
                _rect_invalid.bottom = g_rcScr.bottom;

                SCROLLINFO scinfo = {0};
                scinfo.fMask = SIF_ALL;
                scinfo.nMin = SB_MIN;
                scinfo.nMax = SB_MAX;
                scinfo.nPage = SB_PAGE;
                scinfo.nPos = SB_MIN;

                calc_circle_pos (scinfo.nPos);
                calc_box_pos (scinfo.nPos);

                /** classic VSCROLL with SBS_NOTNOTIFYPARENT */

                hwnd_sb_main = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                        | SBS_NOTNOTIFYPARENT
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_main, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_main, MSG_SETFOCUS, 0, 0);

                /** flat VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        43, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        66, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        92, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        120, 50, 20, 34, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        140, 50, 20, 34, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        160, 50, 20, 34, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        184, 50, 20, 34, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        210, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        232, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        254, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        276, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 220, 150, 20, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 240, 150, 20, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 260, 150, 20, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 280, 150, 20, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);
            }
            break;

        case MSG_COMMAND:
            {
                int code = HIWORD(wParam);
                HWND scroll = (HWND)lParam;
                int pos = 0;

                switch (code) 
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_LINEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_THUMBPOSITION:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }

                draw_shape (hwnd, pos);
            }
            break;

        case MSG_HSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_VSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                            
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;
                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_PAINT:
            {
                HDC hdc = BeginPaint(hwnd); 

                /** separator */
                MoveTo (hdc, SEP, 0);
                LineTo (hdc, SEP, g_rcScr.bottom);

                /** circle */
                Circle (hdc, CC_CENTER_X, CC_CENTER_Y, _radius);

                /** top and bottom line of box */
                MoveTo (hdc, SEP + 20, BOX_Y_MIN);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MIN);

                MoveTo (hdc, SEP + 20, BOX_Y_MAX);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MAX);

                /** box */
                SetBrushColor (hdc, PIXEL_black);
                FillBox (hdc, SEP + 40, _box_pos_y, BOX_WIDTH, BOX_HEIGHT);

                EndPaint (hwnd, hdc);
            }
            break;

        case MSG_CLOSE:
            {
                DestroyMainWindow (hwnd);
                PostQuitMessage (hwnd);
                return 0;
            }
    }

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