Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    487

    [C++] Errore con cAnimCtrl

    Ciao ragazzi ho cercato di compilare questo codice (molto grezzo) per fare comparire un video su finestra......
    mi dice che devo usare la dll per MFC....ma se la uso mi dice che non devo includere winodows.h.....cosa posso fare?

    (Il codice è per 4/5 quello di base per una windows application in visual c++ 2010)

    codice:
    // AVI.cpp : Defines the entry point for the application.
    //
    
    #include "stdafx.h"
    #include "AVI.h"
    
    #define MAX_LOADSTRING 100
    
    // Global Variables:
    HINSTANCE hInst;								// current instance
    TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
    TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name
    
    // Forward declarations of functions included in this code module:
    ATOM				MyRegisterClass(HINSTANCE hInstance);
    BOOL				InitInstance(HINSTANCE, int);
    LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
    INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
    
    int APIENTRY _tWinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPTSTR    lpCmdLine,
                         int       nCmdShow)
    {
    	UNREFERENCED_PARAMETER(hPrevInstance);
    	UNREFERENCED_PARAMETER(lpCmdLine);
    
     	// TODO: Place code here.
    	MSG msg;
    	HACCEL hAccelTable;
    
    	// Initialize global strings
    	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    	LoadString(hInstance, IDC_AVI, szWindowClass, MAX_LOADSTRING);
    	MyRegisterClass(hInstance);
    
    	// Perform application initialization:
    	if (!InitInstance (hInstance, nCmdShow))
    	{
    		return FALSE;
    	}
    
    	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_AVI));
    
    	// Main message loop:
    	while (GetMessage(&msg, NULL, 0, 0))
    	{
    		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
    		{
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    	}
    
    	return (int) msg.wParam;
    }
    
    
    
    //
    //  FUNCTION: MyRegisterClass()
    //
    //  PURPOSE: Registers the window class.
    //
    //  COMMENTS:
    //
    //    This function and its usage are only necessary if you want this code
    //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
    //    function that was added to Windows 95. It is important to call this function
    //    so that the application will get 'well formed' small icons associated
    //    with it.
    //
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
    	WNDCLASSEX wcex;
    
    	wcex.cbSize = sizeof(WNDCLASSEX);
    
    	wcex.style			= CS_HREDRAW | CS_VREDRAW;
    	wcex.lpfnWndProc	= WndProc;
    	wcex.cbClsExtra		= 0;
    	wcex.cbWndExtra		= 0;
    	wcex.hInstance		= hInstance;
    	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_AVI));
    	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
    	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
    	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_AVI);
    	wcex.lpszClassName	= szWindowClass;
    	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
    
    	return RegisterClassEx(&wcex);
    }
    
    //
    //   FUNCTION: InitInstance(HINSTANCE, int)
    //
    //   PURPOSE: Saves instance handle and creates main window
    //
    //   COMMENTS:
    //
    //        In this function, we save the instance handle in a global variable and
    //        create and display the main program window.
    //
    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
       HWND hWnd;
    
       hInst = hInstance; // Store instance handle in our global variable
    
       hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    
       if (!hWnd)
       {
          return FALSE;
       }
    
       ShowWindow(hWnd, nCmdShow);
       UpdateWindow(hWnd);
    
       return TRUE;
    }
    
    //
    //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
    //
    //  PURPOSE:  Processes messages for the main window.
    //
    //  WM_COMMAND	- process the application menu
    //  WM_PAINT	- Paint the main window
    //  WM_DESTROY	- post a quit message and return
    //
    //
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	int wmId, wmEvent;
    	PAINTSTRUCT ps;
    	HDC hdc;
    
    	switch (message)
    	{
    	case WM_COMMAND:
    		wmId    = LOWORD(wParam);
    		wmEvent = HIWORD(wParam);
    		// Parse the menu selections:
    		switch (wmId)
    		{
    		case IDM_ABOUT:
    			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
    			break;
    		case IDM_EXIT:
    			DestroyWindow(hWnd);
    			break;
    		default:
    			return DefWindowProc(hWnd, message, wParam, lParam);
    		}
    		break;
    	case WM_PAINT:
    		hdc = BeginPaint(hWnd, &ps);
    		CreateThread(0,0,(LPTHREAD_START_ROUTINE)MyClipThreadProc,(LPVOID) hWnd,0,0);
    		
    		// TODO: Add any drawing code here...
    		EndPaint(hWnd, &ps);
    		break;
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
    	default:
    		return DefWindowProc(hWnd, message, wParam, lParam);
    	}
    	return 0;
    }
    
    // Message handler for about box.
    INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	UNREFERENCED_PARAMETER(lParam);
    	switch (message)
    	{
    	case WM_INITDIALOG:
    		return (INT_PTR)TRUE;
    
    	case WM_COMMAND:
    		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
    		{
    			EndDialog(hDlg, LOWORD(wParam));
    			return (INT_PTR)TRUE;
    		}
    		break;
    	}
    	return (INT_PTR)FALSE;
    }
    
    // This example creates a secondary thread that implements
    // the methods of CAnimateCtrl. The procedure of the thread
    // is MyClipThreadProc and the thread was created with the
    // code AfxBeginThread( MyClipThreadProc, (LPVOID) pParentWnd).
    // The example code creates and initializes an animation control,
    // then proceeds to pump messages from the queue until one the 
    // private messages WM_STOPCLIP, WM_PLAYCLIP, WM_SHOWFIRSTFRAME or 
    // WM_SHOWLASTFRAME is received. The appropriate action is done for
    // these messages. The thread ends when the WM_STOPCLIP is received.
    // NOTE: the thread parameter, pParam, is a pointer to a CWnd object
    // that will be the parent of the animation control. 
    
    
    #define WM_STOPCLIP               WM_USER+1
    #define WM_PLAYCLIP               WM_USER+2
    #define WM_SHOWFIRSTFRAME         WM_USER+3
    #define WM_SHOWLASTFRAME         WM_USER+4
    
    UINT MyClipThreadProc(LPVOID pParam)
    {
       // NOTE: pParentWnd is the parent window of the animation control.
       CWnd* pParentWnd = (CWnd*) pParam;
       CAnimateCtrl cAnimCtrl;
    
       // Create the animation control.
       if (!cAnimCtrl.Create(WS_CHILD|WS_VISIBLE|ACS_CENTER, 
          CRect(10,10,100,100), pParentWnd, 1))
       {
          return false;
       }
    
       // Open the AVI file.
       if (!cAnimCtrl.Open(_T("C:\\Windows\\winsxs\\x86_microsoft-windows-tabletpc-inputpanel_31bf3856ad364e35_6.1.7600.16385_none_11656be9d8d5e28f\\split.avi")))
       {
          return false;
       }
    
       // Pump message from the queue until the stop play message is received.
       MSG msg;
       while (GetMessage(&msg, NULL, 0, 0) && (msg.message != WM_STOPCLIP))
       {
          switch (msg.message)
          {
             // Start playing from the first frame to the last, 
             // continuously repeating.
             case WM_PLAYCLIP:
                if (!cAnimCtrl.Play(0, (UINT)-1, (UINT)-1))
                   return false;
                break;
    
             // Show the first frame.
             case WM_SHOWFIRSTFRAME:
                if (!cAnimCtrl.Seek(0))
                   return false;
                cAnimCtrl.RedrawWindow();
                break;
    
             // Show the last frame.
             case WM_SHOWLASTFRAME:
                if (!cAnimCtrl.Seek((UINT)-1))
                   return false;
                cAnimCtrl.RedrawWindow();
                break;
          }
    
          TranslateMessage(&msg);
          DispatchMessage(&msg);
       }
    
       cAnimCtrl.Stop();
       cAnimCtrl.Close();
    
       return true;
    }

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480

    Re: [C++] Errore con cAnimCtrl

    Originariamente inviato da kirakira93
    Ciao ragazzi ho cercato di compilare questo codice (molto grezzo) per fare comparire un video su finestra......
    mi dice che devo usare la dll per MFC....ma se la uso mi dice che non devo includere winodows.h.....cosa posso fare?
    Mi dice ... chi? cosa? quando? dove?

    A parte questo, vedo una CreateThread ad ogni WM_PAINT ... è una cosa poco sensata ....
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    487

    xD

    Beh la cosa poco sensata è vera....xDxD
    comunque a parte questa idiozia....visual c++ non me lo lascia compilare....perchè io per usare cAnimCtrl devo includere afxcmn.h...quindi anche afx.h....il cui mi da problemi.....forse non devo usare cAnimCtrl per mostrare i video.....ma non trovo di meglio.....

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    487

    ALLORA

    allora lasciamo perdere questo codice....avete qualche altra idea per riprodurre un video avi (o non avi) su una finestra?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.