|
Hello friends~
I have some questions about MFC.
During I wrote the code, the error was occuring about this.
I use Visual studio 2005. I found many imformation. It's not occur at Visual studio 6.0.
And I use UNICODE.
Plz, help me. I didn't resolve this for 1 hour.
I found MSDN, and Search many sites, but I didn't resolve.
It doesn't not work.
fp = fopen(pDlg.GetPathName(), _T("r"));
fp = fopen(pDlg.GetPathName(), _T("rb"));
//////////////////////////////////////////
FILE *fp;
fp = fopen(pDlg.GetPathName(), "r");
//////////////////////////////////////////
FILE *fp;
fp = fopen(pDlg.GetPathName(), "w");
//////////////////////////////////////////
------ Build started: Project: MFC_4_2, Configuration: Debug Win32 ------
Compiling...
MFC_4_2Dlg.cpp
d:\data\programing\c++\sc\mfc\mfc_4_2\mfc_4_2dlg.cpp(238) : error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
d:\data\programing\c++\sc\mfc\mfc_4_2\mfc_4_2dlg.cpp(261) : error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Build log was saved at "file://d:\Data\Programing\C++\sc\MFC\MFC_4_2\Debug\BuildLog.htm"
MFC_4_2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
Use _tfopen , for instance:
FILE *fp;
fp = _tfopen(pDlg.GetPathName(), _T("r"));
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for your help...
But Another error is occured.
I don't know why this error was occured.
Actually, I found the solution but this error was occured.
Do you know why this error occur ??
------ Build started: Project: MFC_4_2, Configuration: Debug Win32 ------
Linking...
MFC_4_2Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CAboutDlg::GetMessageMap(void)const " (?GetMessageMap@CAboutDlg@@MBEPBUAFX_MSGMAP@@XZ)
D:\Data\Programing\C++\sc\MFC\MFC_4_2\Debug\MFC_4_2.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://d:\Data\Programing\C++\sc\MFC\MFC_4_2\Debug\BuildLog.htm"
MFC_4_2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
Hi, this is a linking problem. You are trying to access CAboutDlg::GetMessageMap witch is not have been implemented. Try defined it and you will get reed of this compiler error message.
Regards,
Mihai Moga
|
|
|
|
|
Thanks for your help...
but I didn't understand your message.
How to define it ??
My CAboutDlg source is added.
plz check this.
i'm spend time for 2 days about this. help me.
//////////////////////////////////////////////////////////////////////////////////
// MFC_4_2Dlg.cpp
//
#include "stdafx.h"
#include "MFC_4_2.h"
#include "MFC_4_2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV
protected:
DECLARE_MESSAGE_MAP()
public:
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
// CMFC_4_2Dlg
CMFC_4_2Dlg::CMFC_4_2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFC_4_2Dlg::IDD, pParent)
, m_strProdName(_T(""))
, m_strProdCode(_T(""))
, m_UnitCost(0)
, m_nQuantity(0)
, m_nTotalCost(0)
, m_strInfo(_T(""))
, m_bCodeViewed(FALSE)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bCodeViewed = FALSE;
}
void CMFC_4_2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_NAME, m_strProdName);
DDX_Text(pDX, IDC_EDIT_CODE, m_strProdCode);
DDX_Text(pDX, IDC_EDIT_UNIT_COST, m_UnitCost);
DDX_Text(pDX, IDC_EDIT_QUANTITY, m_nQuantity);
DDX_Text(pDX, IDC_EDIT_TOTAL_COST, m_nTotalCost);
DDX_Text(pDX, IDC_EDIT_INFO, m_strInfo);
}
BEGIN_MESSAGE_MAP(CMFC_4_2Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_EN_CHANGE(IDC_EDIT_NAME, &CMFC_4_2Dlg::OnEnChangeEditName)
ON_EN_CHANGE(IDC_EDIT_CODE, &CMFC_4_2Dlg::OnEnChangeEditCode)
ON_EN_CHANGE(IDC_EDIT_UNIT_COST, &CMFC_4_2Dlg::OnEnChangeEditUnitCost)
ON_EN_CHANGE(IDC_EDIT_QUANTITY, &CMFC_4_2Dlg::OnEnChangeEditQuantity)
ON_BN_CLICKED(IDC_SAVE, &CMFC_4_2Dlg::OnBnClickedSave)
ON_BN_CLICKED(IDC_OPEN, &CMFC_4_2Dlg::OnBnClickedOpen)
ON_BN_CLICKED(IDC_VIEW, &CMFC_4_2Dlg::OnBnClickedView)
END_MESSAGE_MAP()
// CMFC_4_2Dlg
BOOL CMFC_4_2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
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);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
return TRUE;
}
void CMFC_4_2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CMFC_4_2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
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;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CMFC_4_2Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CMFC_4_2Dlg::UpdateStockInfo(void)
{
UpdateData(TRUE);
m_nTotalCost = m_UnitCost * m_nQuantity;
m_strInfo.Format(_T("name : %s \r\n\r\n code : %s \r\n\r\n price : %d \r\n\r\n amount : %d \r\n\r\n total : %d \r\n\r\n"),m_strProdName, m_strProdCode, m_UnitCost, m_nQuantity, m_nTotalCost);
UpdateData(FALSE);
}
void CMFC_4_2Dlg::OnEnChangeEditName()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateStockInfo();
}
void CMFC_4_2Dlg::OnEnChangeEditCode()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateStockInfo();
}
void CMFC_4_2Dlg::OnEnChangeEditUnitCost()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateStockInfo();
}
void CMFC_4_2Dlg::OnEnChangeEditQuantity()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateStockInfo();
}
void CMFC_4_2Dlg::OnBnClickedSave()
{
// TODO: Add your control notification handler code here
char Filter[] = "p42 File(*.p42) | *.p42 | All(*.*) | *.* |";
CFileDialog pDlg(FALSE, _T("p42 file(*.p42)"), _T("*.p42"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, (LPCTSTR)Filter, NULL);
UpdateData(TRUE);
if(!m_strProdName.IsEmpty() && !m_strProdCode.IsEmpty() && (m_UnitCost >0) && (m_nQuantity > 0) && (m_nTotalCost > 0))
{
if(pDlg.DoModal() == IDOK)
{
FILE *fp;
// fp = _tfopen(pDlg.GetPathName(), _T("w"));
fp = fopen(pDlg.GetPathName(), _T("w"));
fprintf(fp, "%s\n%s\n%d\n%d\n%d", m_strProdName, m_strProdCode, m_UnitCost, m_nQuantity, m_nTotalCost);
fclose(fp);
}
}
else
{
AfxMessageBox(_T("input your imformation : "));
}
}
void CMFC_4_2Dlg::OnBnClickedOpen()
{
// TODO: Add your control notification handler code here
char Filter[] = "p42 File(*.p42) | *.p42 | All(*.*) | *.* |";
CFileDialog pDlg(TRUE, _T("p42 file(*.p42)"), _T("*.p42"), OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, (LPCTSTR)Filter, NULL);
if(pDlg.DoModal() == IDOK)
{
FILE *fp;
// fp = _tfopen(pDlg.GetPathName(), _T("r"));
fp = fopen(pDlg.GetPathName(), _T("r"));
fscanf(fp, "%s\n", m_strProdName);
fscanf(fp, "%s\n", m_strProdCode);
fscanf(fp, "%d\n%d\n%d", &m_UnitCost, &m_nQuantity, &m_nTotalCost);
UpdateData(FALSE);
UpdateStockInfo();
fclose(fp);
}
}
void CMFC_4_2Dlg::OnBnClickedView()
{
// TODO: Add your control notification handler code here
if(!m_bCodeViewed)
{
m_dlgCodeTable.Create(IDD_DIALOG_CODETABLE, this);
CRect rectMain, rectCodeTable;
GetWindowRect(&rectMain);
m_dlgCodeTable.GetWindowRect(&rectCodeTable);
m_dlgCodeTable.MoveWindow(rectMain.right, rectMain.top, rectMain.Width(), rectMain.Height());
m_dlgCodeTable.ShowWindow(SW_SHOW);
m_bCodeViewed = TRUE;
}
else
{
m_dlgCodeTable.ShowWindow(SW_HIDE);
m_dlgCodeTable.DestroyWindow();
m_bCodeViewed = FALSE;
}
}
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
Hi!
I'm developing an app that should capture stream from a webcam, capture audio, mux it in a FLV(maybe other container, e.g. mp4) and then stream it over a network. As I found in MS SDK, I can do it using a DirectShow, but the only option I have is to write a muxed stream to a file. So is there any options to write it to a memory buffer for furhter writing to a socket?
Ofcourse there are some tricks like a continuous reading from a muxed file, but it looks too ugly.
Another question is - can I split icoming muxed stream into frames? I mean if I have a 24 fps live source, is it possible to capture a muxed frame (audio + video), so I could drop some frames in case there is a really bad latency.
Thanks in advance!
|
|
|
|
|
If you want to write your own communication code, you can use custom DirectShow filters to
access the streams.
Real time multimedia streaming is no simple task. The most difficult issues IMO are dealing
with jitter and clock drift.
The Windows Media Format SDK has the ability to stream over a network and it integrates with
DirectShow relatively easily. There are some issues there. First, by definition, it works
mostly with Windows Media Format (ASF) streams. Second, there's no low-latency audio codecs
suitable for real-time communications (low latency/low bandwidth).
Ethemind wrote: can I split icoming muxed stream into frames? I mean if I have a 24 fps live source, is it possible to capture a muxed frame (audio + video), so I could drop some frames in case there is a really bad latency.
You have no choice. To deal with jitter and clock drift, you'll HAVE to add/remove samples in realtime to keep
everything in sync.
Just my 2 cents,
Mark
|
|
|
|
|
Hi,
I am createing new ListBox on dialog box at runtime.
it's creating fine but I want to handle the events over that.
I want to Handle event as
ON_LBN_SELCHANGE(IDC_PREVIEW_LIST, OnSelchangeList)
in message map.
but id IDC_PREVIEW_LIST is passed by me at run time in as
CListBox m_PreviewList;
m_PreviewList.Create(WS_CHILD|LVS_ICON|WS_VISIBLE|WS_BORDER|LBS_OWNERDRAWFIXED|LBS_MULTICOLUMN, rect, this, IDC_PREVIEW_LIST);
and it's not know in messge map.
So please guid me how to handle dynamically created window events.
|
|
|
|
|
|
Please can you explain with simple code?
|
|
|
|
|
Handling events of dynamically created controls are not that hard. It should work. Please ensure that IDC_PREVIEW_LIST is #define-d in some header file and included in this source file.
Do more work
Make more mistakes
Learn more things
|
|
|
|
|
You can declare each event that you need for your dynamic listbox on the message map.
|
|
|
|
|
Hi all,
I have made a dialog based application.
In that i have made a static text box. What i want to know is how to increase font size of text written in static text box....
Thanks in advanvce
|
|
|
|
|
What is static Text Box?
Nigah M Manzoor
|
|
|
|
|
Hi, please have a look to Hans Dietrich's XColorStatic[^] class.
Regards,
Mihai Moga
|
|
|
|
|
I assume that you are mentioning about changing the font size of the STATIC control. You can simply use SetFont() function on the Static controls.
CFont font;
font.CreateFont( 50, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, _T("Times New Roman") );
CWnd* pWnd = GetDlgItem( IDC_STATIC1 );
if( pWnd )
{
pWnd->SetFont( &font );
font.Detach();
}
Do more work
Make more mistakes
Learn more things
modified on Saturday, June 28, 2008 12:15 PM
|
|
|
|
|
I think this[^] article is helpfuls for you.
|
|
|
|
|
Hi
I have been writing this piece of code which will search for all the possible video capture devices on the machine using the Windows DirectShow API.
But no matter what I do I can't get this block of code to return the list of devices in a suitable format back to my VB.NET code.
I keep getting the error pInvoke Restriction:Can't return a variant.
Is there away to convert possibly the variant to a char array, and return the array back to the vb.NET GUI?
The code I have is as follows :
extern "C" __declspec(dllexport) VARIANT __cdecl getDevice()
{
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
reinterpret_cast<void**>(&pDevEnum));
if (SUCCEEDED(hr))
{
hr = pDevEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory,
&pEnum, 0);
}
while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
{
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void**)(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
extern VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
pPropBag->Release();
pMoniker->Release();
}
return varName;
}
Any feedback would be greatly appreciated
Cheers
Boyindie
|
|
|
|
|
hi,,,,,
I have Pixel information for all letters in one Font(xxxxx Font).
I want to make BITMAP FONT using pixel information....
How can i move forward!!!!!!
Any sugestions!!!
Thank u....
|
|
|
|
|
|
How? =/
I'd appreciate a tut or an article...
Fratelli
|
|
|
|
|
|
Sorry about the delay in the response, but I didn't receive an e-mail notification of your reply. What I'd like to know is a way to profile C++ code using VS 2005.. Can't find a nice tutorial =)
Best regards
Fratelli
|
|
|
|
|
How to connect sql server using ODBC in a MFC application?
Sql server is on the another computer in the same LAN.
|
|
|
|
|
|