|
In your case, they should be after the #if's
don't put #include in .h files unless absolutly necessary, for example class inheritance, and non-pointer class objects.
#include "BaseClass.h"
#ifndef _SOMEOBJECT_H_
#include "SomeObject.h"
#endif
class MyClass : public BaseClass
{
SomeObject m_SomeObject;
};
the declaration of m_SomeObject could/should be replaced by
#include "BaseClass.h"
class SomeObject;
class MyClass : public BaseClass
{
SomeObject* m_SomeObject;
};
Max.
|
|
|
|
|
Gosh! I thought I was doing something wrong when I would put #includes in the cpp file!!! SO I started putting them in the .h!
So If I have a A.h and a A.cpp pair with a #include B.h in A.cpp, and I go and do a #include A.h in file C.cpp, everything will work out right?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Why should we put our #include's in .cpp files rather than .h files? (I'm a student, not a programming expert)
Blackmesa
Computer engineering student
Étudiant en génie informatique
------------------------------
|
|
|
|
|
To remove the dependencies of objects.
if in class A I have an Object O and is declared directly in the class declaration, I need to have the #include for it in the .h file.
#include "O.h"
class A
{
O m_o;
};
so, everytime that O changes ( the file is changed ) , a.cpp. and every other files that include a.h will be recompiled.
but if I have
class O;
class A
{
O* m_pO;
};
there's no dependencies in the .h file.
For small projects, it's not that important whether you put #include in the .h files, but for large projects, is can be costly.
See Large Scale C++ Software Design[^] by John Lakos, and in particular section 6.1.
Max.
|
|
|
|
|
Alright, I've looked all over the friggin place, and I'm starting to get frustrated.
All I want to do is have a control that contains rendered HTML from local text that I feed it. I won't be loading anything from the web. Just from text strings in memory.
I've tried the CHtmlView, but on creation it seems to have no document in it. After I Navigate2() some page, then I can call GetDocument() and start replacing the internal HTML. But I don't want to have to Navigate2() anywhere.
Am I completely loopy for wanting to do this?
All I need is a simple control that renders HTML from a string input. Any recommendations?
J
May the bear never have cause to eat you.
|
|
|
|
|
If using the CHtmlView, you need to Navigate to "about:blank" first, then wrench around the document. Or, my personal favorite, go to QHTM[^] and use his control.
Joel Lucsy (jjlucsy@concentric.net)
|
|
|
|
|
I'll try that "about:blank". Sounds like that's what I need. And as to wrenching around the document, is that the way to do it?
CHtmlView::GetDocument() -> IDispatch
IDispatch->QueryInterface -> IHtmlDocument3
IHtmlDocument3->documentElement -> IHtmlElement
set IHtmlElement->innerHTML
Seems convoluted.
On the other hand, QHTM looks like it solves my problem quite nicely. It will even let me do my internal navigation without having to host a custom pluggable protocol for IE...
Thanks!
J
May the bear never have cause to eat you.
|
|
|
|
|
No, you don't need to wrench to hard. I have some code that does it, but it boils down to getting the IHTMLDocument2 interface, then calling the Write method. Thats about it. My code has some other useful functions like setting the background color, overriding the opening of new windows, and so forth, but to just display a document thats all you need to do.
Joel Lucsy
|
|
|
|
|
Perfect. I knew there would be an easier way. Of course having to create a safearray for a single string seems a little extreme, but I'll give it a go.
Thanks for your help!
J
May the bear never have cause to eat you.
|
|
|
|
|
|
Yes, QHTM looks quite handy. I'm undecided as of yet whether or not I need the full IE control...
I saw the XHTMLStatic control, but it's too lite for me. I need pretty much full HTML compliance.
J
May the bear never have cause to eat you.
|
|
|
|
|
how can i set a new Registry Key with a binary or a DWORD value? I have set a String Value for a Registry Key. But I could not set for a Binary or DWORD.
Pl. give me an example coding.
vijay
|
|
|
|
|
BYTE Buffer[256] = {1, 2, 3, 4, 5, 6};
LONG nRetVal = ERROR_SUCCESS;
HKEY hKey = 0;
nRetVal = ::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\MyCompanyName"), 0, KEY_ALL_ACCESS, &hKey);
if(nRetVal != ERROR_SUCCESS)
return ::RegSetValueEx(hKey, _T("My Binary Field"), 0, REG_BINARY, Buffer, sizeof(Buffer)/ sizeof(BYTE));
return nRetVal;
|
|
|
|
|
Do you know any function to return if the app is running from a server or from the local machine ??
Thanks,
Cris.
|
|
|
|
|
what kind of application, environment, technology?
In short what info do you have, and what exactly do you want to know?
|
|
|
|
|
Is a Windows MFC Aplication, dialog based. I want to know when the app is running from another machine (server in a LAN) or from a local machine (the app located in the same machine that it is running).
Then, I need to make my app for don't run from a server, only from the local machine. Ok ??
Any idea ??
[]'s
Cris.
|
|
|
|
|
Write a DCOM app for each server you want to check and use the API I indicated yesterday?
|
|
|
|
|
If I understand correctly, you want to know whether the location of the application executable is on a network drive, or a local drive (the app wouldnt 'run' on the other machine, it is just loaded into memory on your local machine)? If this is the case then you can use GetCurrentDirectory function to retrieve the directory which the application is started in, and then GetDriveType to determine if its a network drive
|
|
|
|
|
Ok, anonymous !! This is what I was finding, the GetDriveType function !!
Thank you very much,
Cris.
|
|
|
|
|
OK I have 2 guesses on what you want
1. You want to know where the actual executable is located that is simple use ::GetModuleFileName
2. You assume there is a possibility to run application on a server and have it visible on the client. In a way, it is true. There are multiple technologies that support that
a. DCOM. That designed to be transparent to the client, so you have to investigate registry to find out if it has proxy and couple of difficult functions like CoGetCallContext, CoQueryProxyBlanket and CoGetObjectContext.
c. COM+ (MTS). See COM+ SDK on how to get Application information.
d. RPC. I am not sure, but I think it is possible to intercept use low level APIs
e. Proprietary software that uses sockets, pipes or some other communication means. Well it depends on what they are doing. Usually you need to use provided API
This is why I asked you about the condition you have. In example you gave there is probably no way to run MFC Dialog APP with no COM on the server, so it actually shows on the client.
|
|
|
|
|
You wrote:
OK I have 2 guesses on what you want
1. You want to know where the actual executable is located that is simple use ::GetModuleFileName
CRIS: Yes, I want to know exatly this. I used the GetDriveType function. It's work well. But I see the documentation and the GetModuleFileName function also works well.
Alex, thanks a lot ...
Cris.
|
|
|
|
|
I have a dll that has a dialog box defined in it. I would like to know how to use/display this box inside my main application. I have used LoadLibrary to load the dll, then called FindResource to obtain a handle to the Dialog Resource. Then I called LoadResource using the handle to the Dll and to the Dialog resource and all is fine. I just can't figure out what to do know with the GlobalHandle that is returned in LoadResource to actually display the dialog box and retrieve the data that is entered.
I am doing this in WinCE, but I would guess that the process shouldn't be too different.
Thanks,
-Eric
|
|
|
|
|
dear all,
i'm using Windows Xp pro with NTFS partition.
i've used LogonUser to get a token of a user and then I use the token in CreateProcessAsUser(...). I use flag LOGON32_LOGON_INTERACTIVE SO THERE IS NO NEED TO DUPLICATE THE TOKEN.
I've also set the reqd. previliges in the system.
but still when i try to execute a process, i get an error -> Access Denied (5).
I also tried to use function ImpersonateLoggedOnUser(..) (which was successful) but still I get the same Error while using function CreateProcess(...) after using ImpersonateLoggedOnUser(...)
I've even tried setting priviliges by code and manually in the OS
But still to find the same Error (error number 5).
In VB also i get the same problem
is it a bug!!!!!!!!!!!
any ideas!!!!!!!!!
thanx
|
|
|
|
|
I'm exploring an FTP site with a recursive function. If I use this function for local exploration, it gives me all the directories and files of a given drive. I've changed the function so it works for FTP. What happens is that I only get the listing of the first level directories, that is, the CFtpFileFind object only finds the files/directories in the root directory. Even if I do SetCurrentDirectory and build the string with which I do the first FileFind(), it always retrieves only in the first level.
To make a test, I manually set a directory (i did: SetCurrentDirectory("/NewYork")), and the CFtpFileFind still finds the files in "/" (root).
Is this a normal behavior of these kind of objects? What can I do to search for directories and files in an FTP in all the levels?
(I did this recursively and iteratively, none worked: the result is only the first level).
I'd appreciate any help.
-- narada
|
|
|
|
|
Here is a code snipped of how I do it, Note fileFound is a virtual method used by the derived class to do all the work.
Hope it helps, the code is just a quick hack, and not very tidy, as it implies it is recursive. I use it to do a tree delete on my FTP server.
void CFTPDirWalk::DirWalkRecurse(TCHAR* szFilename)
{
BOOL bKilled = FALSE,
bOK = FALSE;
CObArray objArray;
CString strDirPath = _T(""),
strBuffer = _T("");
DWORD dwLength = 0,
dwWaitResult = 0;
HINTERNET hFileFound = NULL;
TCHAR szBuffer[MAX_PATH + 1];
WIN32_FIND_DATA FindData;
WIN32_FIND_DATA *pFindData = NULL;
int nIndex = 0,
nLoop = 0,
nSlash = 0;
objArray.SetSize(0);
dwLength = MAX_PATH;
FtpGetCurrentDirectory(m_hFTPConnect, szBuffer, &dwLength);
m_dwRecureCounter++;
strDirPath = szBuffer;
nSlash = strDirPath.GetLength() - 1;
if(nSlash > 0)
if(strDirPath.GetAt(nSlash) != '/')
strDirPath += "/";
hFileFound = FtpFindFirstFile(m_hFTPConnect, szFilename, &FindData, INTERNET_FLAG_RELOAD, 2);
bOK = hFileFound ? TRUE : FALSE;
while(bOK && !bKilled)
{
dwWaitResult = WaitForSingleObject(m_hCloseDown, 0);
bKilled = dwWaitResult == WAIT_OBJECT_0 ? TRUE : FALSE;
if(bKilled)
continue;
if(!isDots(&FindData))
{
int nSize = sizeof(WIN32_FIND_DATA);
pFindData = (WIN32_FIND_DATA*) new WIN32_FIND_DATA;
ZeroMemory(pFindData, sizeof(WIN32_FIND_DATA));
CopyMemory(pFindData, &FindData, sizeof(WIN32_FIND_DATA));
sprintf(pFindData->cFileName, "%s%s", strDirPath, FindData.cFileName );
objArray.SetAtGrow(nIndex++, (CObject*) pFindData);
}
bOK = InternetFindNextFile(hFileFound, &FindData);
}
InternetCloseHandle(hFileFound);
for(nLoop = 0; nLoop < objArray.GetSize() && !bKilled; nLoop++)
{
pFindData = (WIN32_FIND_DATA*) objArray.GetAt(nLoop);
if(!pFindData)
continue;
if((pFindData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if(FtpSetCurrentDirectory(m_hFTPConnect, (LPCSTR) pFindData->cFileName))
{
dwLength = MAX_PATH;
DirWalkRecurse(szFilename);
}
}
else
{
fileFound(pFindData, m_hFTPConnect);
}
}
if(--m_dwRecureCounter > 0 && !bKilled)
{
ZeroMemory(&FindData, sizeof(WIN32_FIND_DATA));
sprintf(FindData.cFileName, strDirPath);
FindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
dirFoundExit(&FindData, m_hFTPConnect);
}
for(nLoop = 0; nLoop < objArray.GetSize(); nLoop++)
{
pFindData = (WIN32_FIND_DATA*) objArray.GetAt(nLoop);
if(pFindData)
delete pFindData;
}
}
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|