|
|
If you expect an answer within four minutes, you'll need to register so I get an email to say you replied to my post.
Have you tried #import ? Did you check the error ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
excuse me on my nervous and on my stupid question :
How can I use at #import ?
Can you write me a line code for example ?
|
|
|
|
|
No worries - questions are what this area is for. If you read the lounge at the moment, I've commented there on my feelings regarding anonymous posts, but I'm still glad to help if I can.
You can access your ATL object in one of two ways. First you can do the #include thing, which gives you named guids and the headers you need, so you can do what you've tried. #import looks like this:
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace named_guids
This imports the type libray, the options I specified mean there is no namespace ( for example if I import ADO without this option I need to using namespace ADO;, or ADO:: everything. ), and give me those named guids. They also give me smart pointers I can use to easily create things and not worry about releasing them.
Like so:
IEnumSAFileEntryPtr pIEnumDB;
ISAFileDBPtr pIFind(__uuidof(SAFileDB));
HRESULT hr;
try
{
if (pIFind == NULL) return;
if(FAILED(pIFind->Connect(m_DBPath)))
{
AfxMessageBox("Failed To Connect");
return;
}
hr = pIFind->GetDatabase(&pIEnumDB);
pIFind->CloseDB();
}
catch (...)
{
pIFind->CloseDB();
AfxMessageBox("Error reading dabatase");
return;
}
These are blocks of code from my current home project, and they all work nicely. The smart pointers are the interface name with Ptr after them, and IEnumSAFileEntryPtr is an enumeration object, created later. The line ISAFileDBPtr pIFind(__uuidof(SAFileDB)); creates the object in my smart pointer - much nicer, doncha think ?
Try that and let me know how you go. If hr still fails, find out what the value is ( in terms of what error it is reporting )
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you !
But I dont find in my computer the path: ...ATL\SADatabase\SADatabase.tlb
So what is your mean in the line :
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace named_guids
|
|
|
|
|
OK, you're a beginner.
That is the path to *my* type library, you need the path to *your* type library. The same as the path to the files you #included previously.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Just because it compiles doesn't mean it works.
You do need to bracket the void**
hr = CoCreateInstance(CLSID_CIQS, NULL,CLSCTX_ALL,IID_ICIQ, (void**)&pHello);
Also what is the value of hr? I case you don't know you can format HRESULTS in the watch window to help decypher them. i.e. hr,hr shows as S_OK (or E_FAIL, etc).
|
|
|
|
|
I want to define a CString in a DLL file so I can share the data.
I simple use the String Table in DLL project, with the value IDS_STRING1 1.
I use the statement
#define IDS_STRING1 1
in the project to which I want to add the DLL. And I also add the .Lib file and the .dll file to the destination project.
But the method does not work.
How to resolve the trouble?
Thanks.
Maer
|
|
|
|
|
Well there are a lot of methods for sharing data between DLL's..but in your case why don't you export a function from the DLL which will return a pointer to the string..
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Hard work has a future payoff. Laziness pays off now.
|
|
|
|
|
Thanks pal.
Your method works, I know. I have used your method before, the method I am using now is a new one that I have never used.
I just want to have a try. : )
Best regards.
Maer
|
|
|
|
|
First, I am not really sure, whether You can use value 1 for string. There a table is somewhere in MSDN which shows ranges for data types stored in resources.
If You want to load this string from dll, You've got 2 solutions:
1) dynamically load dll, by using LoadLibrary(), then LoadString with instance argument pointing to that dll.
There is also an option to create resource only dll. Search for "resource only dll" string in MSDN to read about it.
2) Generate lib and dll, link mentioned lib into the exe, and simply call "LoadString". But, the resource numbers must be unique (at least in type and number). And as I wrote before, try using higher number, for instance: 10000.
According to MSDN documentation:
Prefix Resource Type Valid Range
IDR_ multiple 1 -> 0x6FFF
IDD_ dialog templates 1 -> 0x6FFF
IDC_,IDI_,IDB_ cursors, icons, bitmaps 1 -> 0x6FFF
IDS_, IDP_ general strings 1 -> 0x7FFF
ID_ commands 0x8000 -> 0xDFFF
IDC_ controls 8 -> 0xDFFF
Reasons for these range limits:
By convention, the ID value of 0 is not used.
Windows implementation limitations restrict true resource IDs to be less than or equal to 0x7FFF.
MFC's internal framework implementations reserve several ranges: 0xE000->0xEFFF and 0x7000->0x7FFF.
Several Windows system commands use the range of 0xF000 -> 0xFFFF.
Control IDs of 1->7 are reserved by IDOK, IDCANCEL, and so on.
The range of 0x8000->0xFFFF for strings is reserved for menu prompts for commands
mukkie
|
|
|
|
|
Hi, mukkie!
Thanks for your reply.
I have checked my two projects, the identifier 1 for string is unique.
My question is how can I define a string with the String Table in a DLL so other program can use. I do not want to simply use a function to return a string.
Can you help?
Best regards,
Maer
|
|
|
|
|
If you go to ms word and insert a symbol, there exists the character of a dot. It's not a period, it's a vertically centered dot that's kinda bigger than a period.
How can I get this as a CString? Something like:
CString symbol = char(?????);
How do you find this value? I looked all over MSDN and I can't find it.
Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
The ANSI character 183 (decimal) is a vertically centered dot.
If you are using any peculiar fonts or what not, you may have problems.
|
|
|
|
|
Hi,
I am displaying a java servlet in my CHtmlView window. So the URL i am specifying in the Navigate2 directs to a servlet where I am using Apache JServ as the server.
The problem that I am getting is that, after I continuously keep loading/refreshing a page for some 10/15 times in the window, my Apache is getting hung. Did anyone face a similar problem, or have any ideas for this.
Thanks,
Korimilli
|
|
|
|
|
Have anyone measured performance data for MFC and STL containers using VC6? If yes, which is faster? I like the STL containers better, but am not certain about the performance implications of porting an application that uses MFC containers, basically Maps and Lists.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Well, I haven't done any empirical tests, but here are a couple of issues you need to consider:
1.) Unless something is terribly wrong, linked lists will be comparable between the two. They are both implemented as doubly-linked lists.
2.) In MFC, CMap is implemented as a hash map, whereas std::map<> has looser constraints on time complexity, and is usually implemented as some sort of binary tree (red-black is a common one). This has all sorts of ramifications, as you might imagine. In essence, do not treat CMap and std::map as representing the same data structure, they do not. If you want an STL-like hash map (which is NOT part of the standard yet), try STLPort 4.5, which works on VC++, and includes a std::hash_map class.
3.) Different STL implementations could have dramatically different performance. The best example I can think of is std::list<>::size(). The standard does NOTsay that this has to be O(1) complexity (only that it should), and in fact, STLPort implements it as O(n). However, the standard Microsoft/Dinkumware STL implementation implements it in O(1) time. So you have to be very careful.
I would always use the STL containers, MFC is a decade old antique, which is only useful for user interface work. Personally, I use STLPort 4.5, the standard STL that comes with MSVC is disgusting.
|
|
|
|
|
Hi,
I'm having difficulties testing if Active Desktop is enabled. I have so far devised three functions for determining if it is enabled :
BOOL CActiveDesktop::IsEnabledInShell()
{
BOOL bActiveDesktop = FALSE;
HWND hWindow;
// get the handle of Program Manager window
hWindow = FindWindowEx(0, 0, "Progman", "");
// search for its child SHELLDLL_DefView window
if(hWindow)
{
hWindow = FindWindowEx(hWindow, 0, "SHELLDLL_DefView", "");
// finally, search for the Internet Explorer_Server grandchild window
if(hWindow)
{
// if this call returns a non-zero handle, the computer
// is using ActiveDesktop
if(FindWindowEx(hWindow, 0, "Internet Explorer_Server", ""))
{
bActiveDesktop = TRUE;
}
}
}
return bActiveDesktop;
}
// This method checks the registry Explorer\ShellState key to determine whether
// or not the Active Desktop is currently enabled
// The 4th byte is examined.
// For NT4 - if the byte is 0x13 it is assumed that Active Desktop is enabled
// For W2K - if the byte is 0x73 it is assumed that Active Desktop is enabled
// Other - if the byte is 0x63 it is assumed that Active Desktop is enabled
BOOL CActiveDesktop::IsEnabledInRegistry()
{
BOOL bInstalled = FALSE;
DWORD dwType;
DWORD dwMaxValueData;
HKEY hkey;
if(this->IsInstalled())
{
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS)
{
// query value first time around to determine length of data
if(RegQueryValueEx(hkey, "ShellState", 0, &dwType, 0, &dwMaxValueData) == ERROR_SUCCESS)
{
LPBYTE pRegBytes = new BYTE[dwMaxValueData];
if(pRegBytes == NULL)
{
return FALSE;
}
if(RegQueryValueEx(hkey, "ShellState", NULL, &dwType, pRegBytes, &dwMaxValueData) == ERROR_SUCCESS)
{
unsigned char desktopMode = *(pRegBytes+4);
CString s;
s.Format("ShellState is [0x%x][0x%x][0x%x][0x%x][0x%x]", *(pRegBytes), *(pRegBytes+1), *(pRegBytes+2), *(pRegBytes+3), *(pRegBytes+4));
LOG(s);
delete[] pRegBytes;
CWindowsVersion winVers;
if(winVers.IsWindowsNT4())
{
if(desktopMode == 0x13)
{
LOG("Active Desktop Enabled on Windows NT4");
return TRUE;
}
}
else
if(winVers.IsWindows2000())
{
if(desktopMode == 0x73)
{
LOG("Active Desktop Enabled on Windows 2000");
return TRUE;
}
}
else
{
if(desktopMode == 0x63)
{
LOG("Active Desktop Enabled on Windows 9x / Windows Me");
return TRUE;
}
}
}
}
}
}
return FALSE;
}
// Determine if Active Desktop is enabled. SHGetSettings is apparently
// more reliable than IActiveDesktop::GetDesktopItemOptions, which can
// report incorrectly during the middle of ApplyChanges!
BOOL CActiveDesktop::IsEnabled()
{
BOOL bResult = FALSE;
if(this->IsInstalled())
{
typedef ULONG (FAR PASCAL FnShGetSettings)(SHELLFLAGSTATE* pFlagState, DWORD dwFlags);
HINSTANCE hLib = ::LoadLibrary(_T("SHELL32.DLL"));
if(hLib != NULL)
{
FnShGetSettings* pfnShGetSettings = (FnShGetSettings*) ::GetProcAddress(hLib, _T("SHGetSettings"));
if(pfnShGetSettings != NULL)
{
SHELLFLAGSTATE sfs;
pfnShGetSettings(&sfs,SSF_DESKTOPHTML);
bResult = sfs.fDesktopHTML;
}
::FreeLibrary(hLib);
}
}
return bResult;
}
Each of these have worked on different machines at differnet times. Currently on my home machine (win me), NONE of them work - my ShellState 4th byte is 0x61 and all other determinations return FALSE;
Any ideas on a FAIL SAFE method of checking this across platforms (or one platform would be a start !)
Thanks
Jase
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows
Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com
|
|
|
|
|
Try SHGetSettings with SSF_DESKTOPHTML flag.
|
|
|
|
|
I have, and whats more i quoted it in my code example. It is the third method i have displayed.
It isn't a very reliable method.
Any other ideas?
Jase
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows
Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com
|
|
|
|
|
I have a tree descended from CTreeCtrl displaying text only.
I am using CustomDraw to colour the text of items.
I find I cannot see the text when the item is clicked. This is most obvious where I have not changed the colour from normal.
How do I implement the standard inversion of colour of the text to allow it to be visible.
Sara
|
|
|
|
|
If I understand, when you click on an item, the background goes the same colour as the text ? I'd say because you're drawing the text yourself, you need to check if you're drawing the current selection and change the text colour accordingly.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
How would I use this in a Dialog app. I.E. I need to have it navigate to "res://about.html".
-Matt Newman
-Matt Newman
|
|
|
|
|
Assuming you have inserted the control into your dialog and let the class wizard build a member variable like m_Browser.
m_Browser.Navigate( "res://about.html");
Should do it.
|
|
|
|
|
Thanks I couldn't find an appropriate command or whatever. Thanks
-Matt Newman
-Matt Newman
|
|
|
|
|