CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: How can I get two threads to run simultaneously in a single process?

    Quote Originally Posted by Mike Pliam View Post
    Any idea how this might be accomplished ?
    See your modified sample attached.
    Code:
    			  case SPEI_VISEME :
    			// Viseme was determined by synthesis engine. The high word of wParam is the duration, in milliseconds, 
    			// of the current viseme. The low word is for the next viseme of type SPVISEMES. The high word of lParam 
    			// is the viseme feature defined in SPVFEATURE. This value will be zero if the current viseme is not primary 
    			// stress or emphasis. The low word of lParam is the current viseme being synthesized.
    			// wmId    = LOWORD(wParam);
    			// wmEvent = HIWORD(wParam);
    
    				//_RPT1(0, "wmId = %d\n", wmId);
    				//_RPT1(0, "wmEvent = %d\n", wmEvent);
    
                    pVoice->GetStatus( &eventStatus, NULL );
    				ULONG viseme;
    				viseme = eventStatus.VisemeId;
    
    				_RPT1(0, "viseme = %d\n", viseme);
    				// now you know what viseme to render
    				// animation goes here below
    				// decide what bitmap to draw
    				bmpIdx = (viseme > 11); // simple animation: 
    				                        // consonants are above 11, 
    				                        // vowels are up to, therefore, 
    				                        // mouth4.bmp will go for vowels, 
    				                        // and test.bmp for consonants
    
    				// make your window to re-paint the sprite region
    				InvalidateRect(hWnd, NULL /* in fact you need your sprite rect here*/, FALSE);
    				  break;
    
                  default:
                     break;
               }
    
             SpClearEvent( &eventItem );
             }
             break;
    
    	case WM_CREATE:         
    		// pre-load sprite images
    		hBitmap[0] = (HBITMAP)LoadImage(hInst, L"mouth4.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);         
    		hBitmap[1] = (HBITMAP)LoadImage(hInst, L"test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);         
    		break;    
    	case WM_PAINT:         
    		PAINTSTRUCT     ps;        
    		HDC                     hdc;        
    		BITMAP                  bitmap;        
    		HDC                     hdcMem;         
    		HGDIOBJ                 oldBitmap;          
    		hdc = BeginPaint(hWnd, &ps);          
    		hdcMem = CreateCompatibleDC(hdc);         
    		oldBitmap = SelectObject(hdcMem, hBitmap[bmpIdx]);          
    		GetObject(hBitmap[bmpIdx], sizeof(bitmap), &bitmap);         
    		BitBlt(hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);          
    		SelectObject(hdcMem, oldBitmap);         
    		DeleteDC(hdcMem);          
    		EndPaint(hWnd, &ps);         
    		break;
    Attached Files Attached Files
    Last edited by Igor Vartanov; July 19th, 2012 at 05:48 AM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured