|
|
Hi, Oliver.
You can declare functions outside of your class just as you did in C, and they'll be globally available.
Additionally, there are times when you might want the function to be a member of your class, but you wish to avoid the implicit "this" param, such as when you're creating a callback function. In this case, you can declare the function static, and call it with explcit scope resolution, i.e. CMyClass::GlobalFunction(param1, param1).
The same applies to variables. You can declare them outside of a class (I typically use the g_ with the Hungarian to know that it's global, i.e. CString g_strText). You can also make them static members of your class, which for instance is the method employed in CFile for the open and create mode flages (CFile::modeRead, etc.).
Hope this helps.
|
|
|
|
|
When using CHttpConnection in my MFC program, is there a way to make the connection to Proxy server persistent instead of closing after every request? Or can I have to manually put the field into the header. For example I have:
------------------------- SAMPLE CODE ------------------------
CInternetSession session;
CHttpConnection* pConnection = NULL;
CHttpFile* pFile1 = NULL;
CString strHeaders = _T("Content-Type: image/jpeg\r\nProxy-Connection: Keep-Alive\r\nUser-Agent: MyProgram/1.0\r\n");
char buffer[BUFSIZZ];
UINT nBytesRead;
pConnection = session.GetHttpConnection("www.test.com", (INTERNET_PORT)80 );
for (i = 0; i < 30; i++) {
pFile1 = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, "/", NULL, 1, NULL, NULL, INTERNET_FLAG_DONT_CACHE);
pFile1->SendRequest(strHeaders);
nBytesRead = 0;
nBytesRead = pFile1->Read(buffer, BUFSIZZ - 1);
buffer[nBytesRead] = '\0';
pFile1->Close();
delete pFile1;
}
------------------------------------------------------------------
However, when I run the code and do "netstat" I couldn't see any TCP connection with the proxy, even though the number of bytes read was non zero.
Btw, I noticed that the header produced using CHttpConnection/CHttpFile (captured using ethereal) says it's HTTP 1.0 instead of 1.1, will this create any problems with proxy server?
|
|
|
|
|
Using Windows 2000, Excel 2000, VC++ 6 sp 6,I'm having trouble with an Excel automation function (SetValue()) that throws an exception whenever I use the VT_UI2 type. Size of array doesn't matter. Always works fine for VT_R4.
CXLRange range;
VARIANT v;
VariantInit(&v);
LPDISPATCH pDisp = worksheet.Range(v1, v2);
range.AttachDispatch(pDisp);
SAFEARRAYBOUND rgsabound[2];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nXLRows;
rgsabound[1].lLbound = 0;
rgsabound[1].cElements = nXLCols;
VARTYPE vType = pTable->GetVariantType(0);
SAFEARRAY FAR* psa = SafeArrayCreate(vType, 2, rgsabound);
if( psa )
{
V_VT(&v) = vType|VT_ARRAY;
V_ARRAY(&v) = psa;
LPSTR pData;
HRESULT hr = SafeArrayAccessData( psa, (void**)&pData );
if( SUCCEEDED(hr) )
{
VARIANT vData;
VariantInit(&vData);
int nSize = CFldPath::GetVariantSize(vType);
for( int nCol=0; nCol<nXLCols; nCol++ )
{
for( int nRow=0; nRow < nXLRows; nRow++ )
{
vData = pTable->GetElementValue( nCol, nRow );
if (2 == nSize)
memmove(pData, &vData.uiVal, nSize);
else
memmove( pData, &vData.lVal, nSize );
pData += nSize;
}
}
SafeArrayUnaccessData(psa);
range.SetValue(v);
VariantClear(&v);
}
}
}
Any help appreciated.
|
|
|
|
|
What exception is thrown? Where in the code?
Steve
|
|
|
|
|
Thanks for your reply.
It happens when SetValue() is called. The code jumps to the function
// invoke standard method given IDispatch parameters/return value, etc.
SCODE CCmdTarget::CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags,
VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr)
in the MFC file oledisp1.cpp. There is a TRY on line 987. This would indicate that there's something wrong with the VARIANT v going into SetValue(v). However, I don't know what that would be. v.vt = 0x2012, which just indicates an array of VT_UI2. There's no problem when I use floating numbers and v.vt = 0x2004.
|
|
|
|
|
Hi All
Does anyone know how i can set the focus of another application from within my application ?
for example, from within my application if the user selected a certain option it would (providing it was open)
maximise say Ms Word and bring that to the forefront of the screen
I hope that makes sense
thanks
Simon
|
|
|
|
|
use
FindWindow();// get the handle to the word application
SetwindowPos() ;// bring the word aplication to the front
nave
|
|
|
|
|
You need to know application name and use FindWindow for get CWnd or HWND to window then you can set focus on it.
|
|
|
|
|
I'm trying to develop a class that takes a query and exports the result in a certain way.
I can use CRecordset::GetODBCFieldInfo() to find out what kind of data i have for a certain field and then format it like i need (mm.dd.yyyy for date fields for example) but how can i find if the curent field is null? Is there another way than casting it to a string and seeing if the value is ""?
I can't figure out how isFieldNull works..can anyone help?
|
|
|
|
|
|
I did that before posting the question...
|
|
|
|
|
I search a way to determine the memory which is on the graphic card installed.
Thanks for help.
|
|
|
|
|
Check out the Win32_VideoController class.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
I think the Alt-Tab window only shows the stuff on the taskbar. Windows only appear on the taskbar if they have the WS_EX_APPWINDOW extended style set. So that might be the place to start.
|
|
|
|
|
Hey guys, I was wondering when we use these parameters (int argc, char *argv[]) in a main function? I have no clue why they use it....
Thanks in advance
void main (int argc, char *argv[]) {<br />
<br />
..........<br />
.........<br />
<br />
}
|
|
|
|
|
They are used for command line parameters. argc tells you how many elements are in the argv array. argv holds the space-delimited strings.
Say you write a program that will write out a given string X number of times and you want to allow the user to determine what the string is and how many times by passing in command line parameters:
MyEcho.exe 5 Hello!
argc would be 3 (1 for the module name, and then the parameters).
argv would hold the parameters to parse for the program.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
For command line arguments.
Basically, if you have an executable named "app.exe" and you a the command line like this:
app.exe your_arg1 your_arg2
then argc is 3, argv[1] is "your_arg1" and argv[2] is "your_arg2".
Note that argv[0] is always "app.exe".
Best,
Jun
|
|
|
|
|
See here.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi All
Does anyone know the best way to check if another application is running ?
I need to check from one application to see if another is open, perhaps by checking in task manager
but im not sure how to go about this
Anyone any ideas ??
Simon
|
|
|
|
|
|
You can also use the Process32First() /Process32Next() pair.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hi
I am reading an article.
It is about COM.http://www.codeproject.com/com/comintro.asp
<br />
HRESULT hr;<br />
IShellLink* pISL;<br />
<br />
hr = CoCreateInstance ( CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(void**) &pISL );
<br />
if ( SUCCEEDED ( hr ) )<br />
{<br />
}<br />
else<br />
{<br />
}<br />
Here pISL is a pointer to pointer.But in that definition what is the role of '&'?
Is pISL is a reference type or it is address operator.If it is adress i don't understand the meaning of such a definition.
CAn you please explain?
|
|
|
|