|
monsieur_jj wrote: How about now?
Are you limited to just using C++ code (i.e., can you use OLE or MFC)?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I can only use c++ and boost libraries.
I can use this bit of code from tokenizer class of boost:
std::string strRaw = date;
std::string strItem, strTemp;
tokenizer<> tok(strRaw);
for(tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg)
{
strItem= *beg;
}
I am just not sure how to use it
Thanks a lot
Jj
|
|
|
|
|
Hi all,
This is what i have done:
string ArrMonth[] = {"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"};
string ArrDays[] = {"sun","mon","tue","wed","thu","fri","sat"};
string ArrTimeZone[] = {"atl","est","cst","mst","pst","ala","haw", "edt", "cdt", "mdt", "pdt"};
string strDays, strMonth, strTime, strTimeZone, strYear, tempDate, dateFinal, lwrFilename, tempYear;
int i = 0, j = 0, k = 0, Year, DateNum;
stringstream out;
bool full = false;
char TempStr[500] = {L'\0'};
strcpy(TempStr, date.c_str());
lwrFilename = _strlwr(TempStr);
date = lwrFilename;
size_t foundTime, foundZone;
std::string strRaw = date;
std::string strItem, strTemp;
boost::escaped_list_separator<char> esc('\\',' ',':\\');
tokenizer<escaped_list_separator<char>> tok(strRaw,esc);
for(tokenizer<escaped_list_separator<char>>::iterator beg=tok.begin(); beg!=tok.end();++beg)
{
strItem= *beg;
Year = atoi(strItem.c_str());
DateNum = atoi(strItem.c_str());
foundTime=strItem.find(":");
foundZone=strItem.find("+");
if(!(strItem.empty())){
for(i=0; i<12; i++)
{
if(i<7){
if((strItem == ArrDays[i])&&(strDays.empty()))
{
strDays = ArrDays[i];
break;
}
}
if((i<12)&&(strItem == ArrMonth[i])&&(strMonth.empty()))
{
strMonth = ArrMonth[i];
break;
}
if(i<11){
if((strItem == ArrTimeZone[i])&&(strTimeZone.empty()))
{
strTimeZone = ArrTimeZone[i];
break;
}
}
if((foundZone!=string::npos)&&(strTimeZone.empty()))
{
strTimeZone = strItem;
break;
}
if((foundTime!=string::npos)&&(strTime.empty()))
{
strTime = strItem;
break;
}
if(Year>1980&&(strYear.empty()))
{
strYear = strItem;
break;
}
if((DateNum>0) && (DateNum<32) &&(tempDate.empty()))
{
tempDate = strItem;
break;
}
}
}
}
dateFinal.append(strDays);
dateFinal.append(", ");
dateFinal.append(tempDate);
dateFinal.append(" ");
dateFinal.append(strMonth);
dateFinal.append(" ");
dateFinal.append(strYear);
dateFinal.append(" ");
dateFinal.append(strTime);
dateFinal.append(" ");
dateFinal.append(strTimeZone);
return dateFinal;
Do you think this is more efficient?
Thanks,
Jj
|
|
|
|
|
monsieur_jj wrote:
Do you think this is more efficient?
Without trying it, I don't know. Does it handle all of the possible date formats?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
It works even if i rearrange the string into different formats. I am just thinking what if the time is missing or the timezone or the date.
thanks,
Jj
|
|
|
|
|
Hello all,
im doing some kind of research about how to insert/inject a piece of my own code into a running 3D application...
The ideia is to execute a piece of code, right after a 3D screen refresh completes...
IE:
I have this game running, i start my inject application that will load into memory, find my game address,
and then find the update routine/call, and then inject a piece of code.
I dont know how to locate that call, and how to inject the code ( if that can be done... )
Once i tried using the base Windows draw/write on screen... it works.. but the draw keeps flashing because its not synchronized with the 3d application....
All of this using c++ API..
Sounds strange, any idea would be great!
Thanks!
(sorry my english!)
|
|
|
|
|
To make it easier, how can i just write into another process memory ?
Or would be usefull to, how to make another process load one of my DLL's ?
thanks
|
|
|
|
|
While Microsoft would like us all to be using Vista and Windows Server 2008, there are still a lot of people using Windows 98. For some apps, it's quite easy to write it with support for Win 98.
From memory, I think the latest version that can be used to target Win98 and above is VC++2005 without installing any SDK (ie. the last SDK to support Win 98 (XP SP2 or Server 2003 RS or SP1, I think) had older compilers and libs).
Microsoft have removed all references to Windows 95/98/Me onm their site and MSDN Library 2008 so it's no longer possible to tell which version of the SDK was the last that supported targeting Win 95 and above.
Am I correct ?
Is there any way to install VC++ SP1 but keep support for Win9x targets ?
|
|
|
|
|
Hello
I want to build an audio processing application using ISampleGrabber interface.
1. How can I learn sampling rates of audio streams ? Its callback function gives me "SampleTime"s and
size of buffers. I guess I can get sampling rate as kbps. By the way after I get sampling rate as kbps
how can I express in Hz\kHz ?
2. I know that your buffer size must be power of 2 to implement FFT algorithm ( at least Radix2 , I'm new on that area).
So size of buffers ISamplegrabber gives are not always (almost never) powers of 2. So how should I handle
this problem ?
3.Callback function gives a buffer of samples as BYTE* (array of unsigned chars).
So to make an audio process , how should I get double or float values instead of unsigned chars ?
For example should it be like this ? :
double realSampleValue -> pBuffer[0].......pBuffer[7] ( Here I mean to make this programtically using bit operators)
Thank you very much...
|
|
|
|
|
Akin Ocal wrote: How can I learn sampling rates of audio streams ?
If you use the sample callback, you'll get a new media type with the sample
every time it changes. You can also get the media type on the sample grabber filter's
input pin after the graph is built.
It sounds like you're using the buffered callback, which isn't recommended.
You'll have better results using the sample callback. You'll get even better results
if you implement your own grabber filter.
Akin Ocal wrote: 2. I know that your buffer size must be power of 2 to implement FFT algorithm ( at least Radix2 , I'm new on that area).
So size of buffers ISamplegrabber gives are not always (almost never) powers of 2. So how should I handle
this problem ?
You'll need to buffer enough data to feed your processing algorithm if necessary. That's dependent on your
implementation.
Akin Ocal wrote: 3.Callback function gives a buffer of samples as BYTE* (array of unsigned chars).
So to make an audio process , how should I get double or float values instead of unsigned chars ?
You need to convert the PCM sample data to whatever format your processing code needs.
For example, you may need to convert signed 16-bit PCM samples to doubles between -1.0 and 1.0.
Your code will need to do that math.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Akin Ocal wrote: I guess I can get sampling rate as kbps. By the way after I get sampling rate as kbps
how can I express in Hz\kHz ?
I forgot about this question...
When you get the media format from the filter, ISample, or graph, you will have a WAVEFORMATEX
structure. In that structure is a nSamplesPerSec member. That value is in Hz, and when divided by 1000,
KHz.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you very much indeed...
|
|
|
|
|
Thank you very much for your answers. But I have some questions again :
1. I can succesfully get AM_MEDIA_TYPE from output pin of my source filter (I use audio files as sources
in my case ) But unfotunately I cannot get pbFormat even formattype of AM_MEDIA_TYPE
(pbFormat -> bad pointer, formattype-> GUID_NULL )
I use the code below to get AM_MEDIA_TYPE , I can get other parameters succesfully
BOOL MyClass::GetMediaTypeOfConnectedPin (IBaseFilter* pFilter,PIN_DIRECTION pDir,AM_MEDIA_TYPE* pMediaType,int index)
{
HRESULT hr ;
IPin* fPin ;
hr = this->GetPin(pFilter,pDir,index,&fPin);
if(hr != S_OK ) return FALSE ;
if ( (fPin->ConnectionMediaType(pMediaType)) != S_OK) return FALSE ;
if ( pMediaType->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX* temp = (WAVEFORMATEX*) malloc(sizeof(WAVEFORMATEX));
temp = ( WAVEFORMATEX *)pMediaType->pbFormat;
...
free(temp);
}
return TRUE ;
}
2. What is the order of samples if there are 2 channels. For example is it something like :
Left Channel -> pBuffer[0] ... pBuffer[n/2]
Right Channel -> pBuffer[n/2+1] .... pBuffer[n]
or
Left Channel-> pBuffer[even_indexes]
Right Channel -> pBuffer[odd_indexes]
3. After I get my samples as WORDs(unsigned shorts) , what should I do to get floats from them ?
Thank you very much
Regards
|
|
|
|
|
Hi together,
i coded a project (SDI) with an editbox in the toolbar.
By pressing enter the value in the edit will be shown in a msgbox(with a lot of help of Mr. Salesbery ).
In my project the document will hande the datas an the view will show them !
Now i have to pass the value in the editbox to the view.cpp in order to show them !
But this won't work
Here are some codes;
#pragma once
class CMyEdit : public CEdit
{
public:
CMyEdit();
~CMyEdit();
BOOL PreTranslateMessage(MSG* pMsg);
CString m_MyEditAusgabe;
protected:
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "MyEdit.h"
#include "Test.h"
#include "NEW_cLoadFile.h"
CMyEdit::CMyEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
END_MESSAGE_MAP()
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
NEW_cLoadFile mlf;
cTest test;
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
CString cstrNumber;
GetWindowText(cstrNumber);
test.testFunktion(cstrNumber);
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
The view.cpp:
#include "stdafx.h"
#include "NonButton Ctrl in ToolBar 1.h"
#include "MyEdit.h"
#include "NonButton Ctrl in ToolBar 1Doc.h"
#include "NonButton Ctrl in ToolBar 1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CNonButtonCtrlinToolBar1View, CView)
BEGIN_MESSAGE_MAP(CNonButtonCtrlinToolBar1View, CView)
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
CNonButtonCtrlinToolBar1View::CNonButtonCtrlinToolBar1View()
{
}
CNonButtonCtrlinToolBar1View::~CNonButtonCtrlinToolBar1View()
{
}
BOOL CNonButtonCtrlinToolBar1View::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
void CNonButtonCtrlinToolBar1View::OnDraw(CDC* pDC)
{
CNonButtonCtrlinToolBar1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
BOOL CNonButtonCtrlinToolBar1View::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CNonButtonCtrlinToolBar1View::OnBeginPrinting(CDC* , CPrintInfo* )
{
}
void CNonButtonCtrlinToolBar1View::OnEndPrinting(CDC* , CPrintInfo* )
{
}
#ifdef _DEBUG
void CNonButtonCtrlinToolBar1View::AssertValid() const
{
CView::AssertValid();
}
void CNonButtonCtrlinToolBar1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNonButtonCtrlinToolBar1Doc* CNonButtonCtrlinToolBar1View::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNonButtonCtrlinToolBar1Doc)));
return (CNonButtonCtrlinToolBar1Doc*)m_pDocument;
}
#endif //_DEBUG
void CNonButtonCtrlinToolBar1View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
}
If you need more i attached a small codesnippet !
http://www.filehosting.at/files/download.php?file=611b6c1fd8ef7b65080cbd12624d1421
I really hope you can help me
Many thanx fo yor help
Best regards
Croc
|
|
|
|
|
CrocodileBuck wrote: test.testFunktion(cstrNumber);
What is this?
I'm not seeing any code that attempts to notify the view of
the enter key being pressed in the edit control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mr.Salsbery,
i tried to include the view in the MyEdit.cpp and then to pass the value to the OnUpdate
I tried different possibilities but no one worked, so i cleaned up the functions !
I know that i have to notify the view, i've read it in the book from swanke but i don't know how to do that ?
Thanx for your help
best regards
Croc
|
|
|
|
|
P.S.:
I also tried this
void CNonButtonCtrlinToolBar1View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (VK_RETURN)
{
MessageBox("test","test",MB_OK);
}
CView::OnChar(nChar, nRepCnt, nFlags);
}
I think that thie code will work but there is still don't know how to notify the view in the right way
Thanx for your help
hopefully
croc
|
|
|
|
|
OK,
OnChar is the wrong way !
Could anybody help me ???
Thanx for your help
Best regards
Croc
|
|
|
|
|
Hi,
is my question too stupid, too difficult or have i made mistakes in my posting ?
Thanx for your help
Best regards
Croc
|
|
|
|
|
There are another options as different time zones, people works or sleeps and so on. Be patient. Somebody will help you
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Plus if you reply to your own posts, I never get an email notifying me that you posted
You have the enter key event at the edit control class.
Now you need to somehow relay that info to the view.
There's an infinite amount of ways to do that.
The easiest thing to do would be to post a user-defined message to the parent of the edit control's parent.
You could also post the message to the app's main window - depends on your window hierarchy.
Let's say your window hierarchy is like this:
FrameWindow
ToolBar
Edit Control
View
To get a message to the view from the edit control, post the message to the parent of the edit control's parent,
which is the frame window. Add a handler for the message in the framewindow class. In that handler, GetActiveView()
can be used to get the view window to forward the message on to.
That's one example using window messages.
Another alternative is to pass window object pointers down to the edit control at creation time, and
call methods of the window class directly from the edit control class. This solution is much less elegant
because it binds a bunch of window classes together in a way they can't be reused easily...not a good
object-oriented design.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi. Mr Salsbery ,
thanx for your reply , i will try the first option now !
Thank for your help
Best regards Croc
|
|
|
|
|
Hi Mr. Salsbery,
my new MyEdit.cpp :
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
NEW_cLoadFile mlf;
cTest test;
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
CView* pView = (((CMainFrame*)AfxGetMainWnd())->GetActiveView());
pView->SendMessage(WM_SETTEXT,0,'test');
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
And here is the View.cpp of the project:
.
.
.
.
.
void CNonButtonCtrlinToolBar1View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CString text;
MessageBox(text,text,MB_OK);
}
This won't work
Unfortunately i don't know much about the message handling in the mfc
Could yo perhaps correct the code ???
P.S.:i really forgot the time zone
Thanx for your help
Best regards
Croc
|
|
|
|
|
You should probably be sending a user-defined message.
The receiving window will need to have a handler for that user-defined message.
CrocodileBuck wrote: Unfortunately i don't know much about the message handling in the mfc
It's actually Windows messaging - that's essential knowledge for Windows programming.
I'd definitely recommend studying that and knowing it if you're going to do Windows GUI programming
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Was wondering when someone gets the THREAD_ATTACH message (sine my app has lots of threads)
Is there anyway of finding out information/identify about this thread.. Thread Name would be nice
I guess I could do GetCurrenThread that gives me the thread name....
|
|
|
|
|