|
When I use this function,I get some tousle code.This following is my code.
Anyone can help me and give me some advice?
CInternetSession* cis=new CInternetSession;
CHttpConnection* pHttpCon=cis->GetHttpConnection(_T("192.168.0.17"),INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE,8007);
CHttpFile * pFile;
//pFile=pHttpCon->OpenRequest(CHttpConnection::HTTP_VERB_GET,_T("/a.xml"));
// pFile->SendRequest();
pFile=(CHttpFile *)cis->OpenURL(_T("Http://192.168.0.17:8007/a.xml"),1,INTERNET_FLAG_TRANSFER_ASCII);
CString szSession,szResult("\0");
while(pFile->ReadString(szSession)!=FALSE)
{
szResult=szResult+szSession;
}
//DWORD dwRet;
//pFile->QueryInfoStatusCode(dwRet);
//if (dwRet == HTTP_STATUS_OK)
//{
// pFile->ReadString(szSession);
// }
MessageBox(szResult);
//int n=szSession.Find(_T("Session"));
// if(n==-1)
// MessageBox(_T("Not Find Session"));
pFile->Close();
pFile = NULL;
delete pFile;
pHttpCon->Close();
pHttpCon = NULL;
delete pHttpCon;
cis->Close();
cis = NULL;
delete cis;
|
|
|
|
|
I can see that you use _T(), are you using UNICODE strings?
If you are, it don't work. If you send and receive UNICODE strings, the data you receive is just crap...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
But how can I use the OpenURL() function?Can you give me a sample?
When I try this, I get a error "URL not use a discriminating protocol"
pFile=(CHttpFile *)cis->OpenURL((LPCTSTR)("http://192.168.0.17:8007/a.XML"));
|
|
|
|
|
Thank you.
I have resolved this question by using Function Read() instead of ReadString();P
|
|
|
|
|
OK, I need for my application to catch data in an excel database. So, I know th methode to get data, but when I try to compile my application I have this kind of error message:
"error C2501:'_RecorsetPtr':missing storage-class or type specifier"
what do I have to do to repair this error?
thanks for your help.
Gerald
|
|
|
|
|
> what do I have to do to repair this error?
At least post the line rejected by compiler.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You have that error because the storage class does not exist. You would need to add a "d" to that storage class for it to find it. The storage class is
_RecordsetPtr
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
What grid does a guru use for manipulating a table(adding,inserting,deleting)?
I use "DBgrid" and "Remote Data" but i dont have a good control of them. For example i dont know how to catch the exceptions like somebody insert a string in a integer field and many more. There is only VB grid documentation and i dont manage VB. There are not many examples too...
If you know VC documentation or source codes about DBGrid,DataGrid, Remote Data or ADO Data let me know, please.
If you integrate the one of the CodeGuru grids in databases (not only for retrieve records) please help me. I can deal with ADO and ODBC.
Whats your advise, dear guru?
Thanks!
|
|
|
|
|
Why not a grid written in C and OleDB/ODBC as DB support? Implement into a DLL a window (not especially an ActiveX), export Register/Unregister from this dll, properties and methods (as every ATL/MFC-like wizard do) as (example):
BOOL
GridCtl_GetColumns(
IN HWND hwndCtl,
OUT PGRIDCOLUMNS **ppColumns
);
etc., implement your own paint for header, lines, columns, cells etc.?
The DB support: you can choose from the myriad of DB interfaces available (starting from ODBC and DB-Library and ending with OleDB, ADO, DAO, Newton binome of A,D and O - - ) and create another dll (or in the same) where you implement the "data source": in the same way, register, unregister, general properties (Server/Source, Catalog/Database etc.), methods/properties (IsBOF, IsEOF, NextRow, Query, Cancel, SetSql, RowCount, GetSql etc.), eventually expose a little rectangle with rewind, back button, in the middle a static with some informations (Connected, Row n Of N etc.) and ending with next/forward buttons (something like: "<< < Row 1 of 10 > >>").
If you need an activex, ok, the ATL object wizard should be a good starting point. Implement what you need (connection points, sinks, events, all the usual stuff).
Frankly, I have seen many controls, from simple windows to ActiveX. But I never seen a grid or a data source to like. So I decided to wrote my controls (including grid) in C. It works, until now.
(RO: Mai pe romaneste: ce faci cu mina ta... )
Cristian 'Sardaukar' Amarie
|
|
|
|
|
I seem to have stubled across my second bug (in about 8 hours worth of using this compiler).
Now, I've always used what I believed to be the standard way of throwing class exceptions (as shown in Stroustrup):
<br />
class AWobbley {<br />
char *m_msg;<br />
public:<br />
AWobbley(const char *msg);<br />
...<br />
<br />
};<br />
<br />
...<br />
<br />
throw AWobbley("AGHRR!");<br />
...<br />
<br />
catch (AWobbley &e) {<br />
... do something with e.m_msg<br />
}<br />
<br />
The problem came up when the exception class stored a dynamically constructed message and, thus, needed a destructor to delete it. In VC++ this destructor is called before the exception handler is entered. This, of course, completely messes up the whole technique.
I haven't yet found a bug report on the Microsoft site. Anyone else with this problem?
Yes, of course there are work arrounds like passing a pointer to a newed object and deleting it at the bottom of the exception handler, but it's ugly and something I wouldn't want to keep for another compiler.
|
|
|
|
|
You need to add the copy constructor to AWobbley and program will behave as expected. If you comment out AWobbley(const AWobbley &a), you'll see two dtor calls and only one ctor - looks like a bug. And the funniest thing is that program doesn't call copy ctor when it is defined.
class AWobbley
{
public:
AWobbley() { printf("def ctor\n"); }
AWobbley(const char *msg) : m_msg(msg) { printf("ctor\n");}
AWobbley(const AWobbley &a) { printf("copy ctor\n"); m_msg = a.m_msg; }
~AWobbley() { printf("dtor\n"); }
void print() { printf("%s\n", m_msg); }
private:
const char *m_msg;
};
void main( void )
{
try
{
throw AWobbley("AGHRR!");
}
catch (AWobbley &e)
{
printf("exception handler\n");
e.print();
}
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Now that is weird. I'd say definitely a compiler bug. Thanks for the work arround.
|
|
|
|
|
The stuff that happens without copy ctor looks like bug. Behavior with copy ctor defined may be optimization - the exception object is created 'in-place' once.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Somewhere: "SetTimer(1,10,0);"
10 means the function below is called in every "10 miliseconds"
void CDDDView::OnTimer(UINT nIDEvent)
{
if (nIDEvent==1)
{
//draw a bitmap in different points to simulate an animation
}
}
10 miliseconds is too less for a Pentium II ,so the bitmap cant redraw at every 10 miliseconds.
NOW, THE EXCITING PART:
I have a CTreeCtrl in my view. When i move the mouse over the tree the bitmap redraw 3 times faster!!!!!!!!!
Is there a guru on Earth to explain this???
PS: if somebody wants to see the application i'll send by e-mail. It is my graduated project.
Sorry for not a good English.
|
|
|
|
|
> "SetTimer(1,10,0);" 10 means the function below is called in
> every "10 miliseconds"
No. Windows timers use INT 8 interrupt internally, which fires at 18.2 Hz. The minimal elapsed time is about 55 ms, even if you pass 10 to SetTimer. And, OnTimer is not guaranteed to be called when time elapses - WM_TIMER messages are posted to the message queue and have the lowest priority.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Ok! Ok!
I think i didn't make myself clear!
In my view derived class i have a bitmap who redraws in VM_TIMER handle.I have a tree control, and a multiline edit control too.
Normaly, the bitmap move on the screen with a speed lets say "x".
WHEN I MOVE THE MOUSE OVER THE TREE CONTROL, OR WHEN I SELECT THE TEXT WITHIN A MULTIEDIT CONTROL (FROM MY CView DERIVED CLASS) THE BITMAP MOVES WITH A SPEED "3*x". I KNOW THIS SOUNDS WEIRD!
Why? Why? Why?
|
|
|
|
|
The Windows scheduler boosts the priority of the thread that owns the window, when a window receives input, such as timer messages, mouse messages, or keyboard input. Priority boost gives more processor time and your bitmap is redrawn faster.
BTW: Do you really think that SCREAMING makes you more readable?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
And how comes in the following cases the bitmap doesn't move faster and implicitly Windows scheduler doesnt boost the priority of my thread?
1)Put all my fingers on the keyboard.
2)Click the mouse 5 times a second OUT OF THE TREE and OUT OF THE EDIT CONTROL.
Does Windows scheduler boost the priority of my thread ONLY when my view receives messages from the child windows? How can you explain that?
For you it seems all right. For me not.
Sorry for screaming.
|
|
|
|
|
> And how comes in the following cases the bitmap doesn't move
> faster and implicitly Windows scheduler doesnt boost the
> priority of my thread?
I have no idea - maybe your WM_KEYDOWN handler is glacially slow. You can use Performance Monitor to check what's going on with the priority base/boost. Anyway, if you want smoothly animated bitmap in your program, you'll have to create a separate "painter" thread.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The problem is when you move your mouse, you are probably causing a an invalidate on the tree control, which means you are forcing events to repaint you window, this will be as fast as you pc can handle.
SetTimer ( ... ) & OnTimer ( ... )== 55 milli seconds is the fasters you can do.
Now using an idle loop you can go as fast as you like (Idle Loop Processing in MSDN)
BOOL bDoingBackgroundProcessing = TRUE;
while ( bDoingBackgroundProcessing )
{
MSG msg;
while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if ( !PumpMessage( ) )
{
bDoingBackgroundProcessing = FALSE;
::PostQuitMessage( );
break;
}
}
// let MFC do its idle processing
LONG lIdle = 0;
while ( AfxGetApp()->OnIdle(lIdle++ ) )
{
// Do nothing
}
// Now you can check if at least 10 ms have passed if so do paint, if not loop
}
|
|
|
|
|
> The problem is when you move your mouse, you are probably
> causing a an invalidate on the tree control
It's not the default Windows behavior. Tree control isn't invalidated when mouse moves over it, even with TVS_TRACKSELECT style set, unless application calls InvalidateRect 'manually' in response to WM_MOUSEMOVE.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I had a go at writing a class that takes an optional member pointer as an argument. It's
along the lines of
<br />
class AttributeInt {<br />
char * CXMLNode::*m_units;<br />
<br />
...<br />
<br />
public:<br />
AttributeInt (... , char * CXMLNode::*units = NULL) : .. ,m_units(units)<br />
<br />
According to the debugger this sticks 0xffffffff into the member if no parameter is given (I'd expected 0, but I suppose it's conceivable 0 might be a valid offset).
The question is, how do I test for this, preferably in a portable way.
I've tried
m_units == NULL (never succeeds)
m_units == (char * CXMLNode::*)-lL (won't compile)
|
|
|
|
|
This works for me (VC6 SP5). Pointer to member representation set to "Best case always" in Settings/C++/C++ language.
class CXMLNode
{
public:
char *p1;
char *p2;
};
class AttributeInt
{
char * CXMLNode::*m_units;
public:
AttributeInt(char * CXMLNode::*units = NULL) : m_units(units) {}
void test()
{
if (m_units == NULL)
{
printf("m_units is NULL\n");
}
else
{
printf("m_units is not NULL\n");
}
}
};
void main( void )
{
AttributeInt a;
a.test();
AttributeInt b(&CXMLNode::p1);
b.test();
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
i want to get realtime audio data with g723.1 format.how to set g723.1?
//how to set these code
wfx.wFormatTag = ;
wfx.nChannels =
wfx.nSamplesPerSec =
wfx.wBitsPerSample =
wfx.nBlockAlign = ;
wfx.nAvgBytesPerSec = ;
wfx.cbSize = 0;
|
|
|
|
|
I think it`s not possible to put a G723-Stream directly to the input of the wave-device because you have to decode it first.
Anyway the parameters of an decoded G723 usually are:
8kHz / Mono / 16Bit
|
|
|
|