begin process at 2012 05 29 09:48:06
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C++ & C++ .NET

 > 

Divers

 > 

Débutant(e)

 > 

interface graphique mfc


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

interface graphique mfc

mercredi 18 mai 2011 à 17:12:45 | interface graphique mfc

infoYESMINE

Salut

j'ai un code c++ ( interface graphique ) qui contient un bouton "open image" et qui affiche cette image dans une nouvelle fenetre nommé "Original image" .
je veux bien que l'affichage soit dans la meme interface dans une zone dédiée à une image .

s'il vous plait , est-ce que vous pouvez m'aider pour refaire le meme travail mais cette fois çi sur un vidéo et non pas sur une image .

merci d'avance
Code C/C++ :
// cvisionDlg.cpp : implementation file
//

#include "stdafx.h"
#include "cvision.h"
#include "cvisionDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CString mesg;
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// CcvisionDlg dialog

CcvisionDlg::CcvisionDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CcvisionDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CcvisionDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
//DDX_Control(pDX, IDC_EDITB, m_editB);
}

BEGIN_MESSAGE_MAP(CcvisionDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, &CcvisionDlg::OnOpen)
	ON_BN_CLICKED(IDOK, &CcvisionDlg::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CcvisionDlg::OnBnClickedCancel)
	ON_EN_CHANGE(IDC_EDIT1, &CcvisionDlg::OnEnChangeEdit1)
END_MESSAGE_MAP()

// CcvisionDlg message handlers

BOOL CcvisionDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
    cvNamedWindow( "Original Image");   // create the window on which
  	   								    // the image will be displayed

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CcvisionDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CcvisionDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CcvisionDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CcvisionDlg::OnOpen()
{
  CFileDialog dlg(TRUE, _T("*.bmp"), NULL,
    OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY,
    _T("image files (*.bmp; *.jpg) |*.bmp;*.jpg|All Files (*.*)|*.*||"),NULL);

  dlg.m_ofn.lpstrTitle= _T("Open Image");

  if (dlg.DoModal() == IDOK) {

    CString path= dlg.GetPathName();  // contain the selected filename

	IplImage *image;				  // This is image pointer

	image= cvLoadImage(path);             // load the image
	cvShowImage("Original Image", image); // display it
  }
}

void CcvisionDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	cvDestroyAllWindows();
	OnOK();
}

void CcvisionDlg::OnBnClickedCancel()
{
	// TODO: Add your control notification handler code here
	cvDestroyAllWindows();
	OnCancel();
}

void CcvisionDlg::OnEnChangeEdit1()
{
	// TODO:  S'il s'agit d'un contrôle RICHEDIT, le contrôle
	// n'enverra la notification que si vous substituez la fonction CDialog::OnInitDialog()
	// et l'appel CRichEditCtrl().SetEventMask()
	// avec l'indicateur ENM_CHANGE ajouté au masque grâce à l'opérateur OR.

	// TODO:  Ajoutez ici le code de votre gestionnaire de notification de contrôle
}


Code C/C++ :
// cvision.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "cvision.h"
#include "cvisionDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CcvisionApp

BEGIN_MESSAGE_MAP(CcvisionApp, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CcvisionApp construction

CcvisionApp::CcvisionApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CcvisionApp object

CcvisionApp theApp;


// CcvisionApp initialization

BOOL CcvisionApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	CcvisionDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

Code C/C++ :
// cvisionDlg.h : header file
//

#pragma once

#include "highgui.h"

// CcvisionDlg dialog
class CcvisionDlg : public CDialog
{
// Construction
public:
	CcvisionDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_CVISION_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnOpen();
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedCancel();
	afx_msg void OnEnChangeEdit1();
};
Code C/C++ :
// cvision.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
	#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"		// main symbols


// CcvisionApp:
// See cvision.cpp for the implementation of this class
//

class CcvisionApp : public CWinApp
{
public:
	CcvisionApp();

// Overrides
	public:
	virtual BOOL InitInstance();

// Implementation

	DECLARE_MESSAGE_MAP()
};

extern CcvisionApp theApp;

Code C/C++ :
//Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by cvision.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_CVISION_DIALOG              102
#define IDR_MAINFRAME                   128
#define IDC_BUTTON1                     1000
#define IDC_EDIT1                       1001

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1002
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif








Cette discussion est classée dans : code, image, void, define, ccvisiondlg


Répondre à ce message

Sujets en rapport avec ce message

imprimer et image en c++ [ par naney ] je voudre un code source qui me montre comment imprimer et un autre qui me montre comment inserais une image en c++ (n'importe quel format d'image) ex #define [ par ifren ] bonjour,j'ai ces deux code #ifndef LFAdbuf #define LFAdbuf LFA::__instance()->__buffer="" #endif // LFAdbufet j'ai un autre code #define LFAdbu printf de #define [ par Manson ] Bonjour,voila j'ai un #define qui se presente sous cette forme :#define FILEVER 1,2,3,4Je ne peux absoluement pas changer son format.< Bitwise-inclusive-OR assignement [ par Duc ] voila un morceau de code pour expliquer mon probléme:#define VALUE_1 101<font color=blu Question idiote a propos des tableaux 3D [ par boulfrite ] Salut...J'ai une question un peu idiote : Est-ce que unsigned char image [256][256][3];est la meme chose que<table border= Lib SDL -> probleme d'images [ par zmc ] bonjour, je debute plus ou moins en SDL, et je n'ai pas réussi a afficher un sprites (animé ou non) sur une image de fond. Selon la méthode que j'empl Problème afficher une image au demarrage [ par Fly57 ] Bonjour tout le monde ,j'ai trouvé ce que je cherchais à faire c'ets à dire afficher une image au demarrage de mon programme, à l'adresse suivante :<a code source traitement d'image [ par ceya ] Bonjour à tous, Je cherche un code source sur la quantification vectorielle et sur l'inversion d'une image. Tout ça pour des images bmp avec des nive Mettre une image sur un bouton [ par patatedu65 ] Bonjour!! quelqu'un peut il me dire comment peut on mettre une image en .bmp sur un bouton sous VC++ ??? Du code du code!!! :-DBTS Info Indus (2ème a Affichage d'image en builder C++ 6 [ par benche78 ] Bonjour, je débute en C++ builder et j'aimerai faire "clignoter" une image en utilisant la propriété visible.voici mon code mis dans un timer: void _


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales