|
I've got the specified registry key, but it does not contain an entry for the corresponding CSIDL_APPDATA...
Is there another way?
Thanks
--
Maxime Labelle
maxime.labelle@freesurf.fr
|
|
|
|
|
I uses SHBrowseForFolder on workstations so I need to call SHGetPathFromIDList (way down in the code...). Is that one available to you?
namespace {
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM , LPARAM lpData) {
if(uMsg == BFFM_INITIALIZED) {
if(lpData) {
SendMessage(hwnd, BFFM_SETSELECTION, 1, lpData);
}
}
return 0;
}
}
extern "C" int PickDir(const HWND hwnd, const char* pszSource, char* pszNew){
TCHAR display_name[_MAX_PATH] = _T("");
if(pszSource) strcpy(display_name, pszSource);
HLOCAL hl(0);
BROWSEINFO bi;
memset(&bi, 0x00, sizeof(bi));
bi.hwndOwner = hwnd;
bi.pszDisplayName = display_name;
bi.lpszTitle = _T("Välj bibliotek");
bi.ulFlags = BIF_BROWSEINCLUDEFILES + BIF_EDITBOX + BIF_RETURNONLYFSDIRS + BIF_NEWDIALOGSTYLE + BIF_UAHINT;
if(pszSource && *pszSource) {
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)(hl = LocalAlloc(LPTR, strlen(pszSource) + 1));
CopyMemory(hl, pszSource, strlen(pszSource) + 1);
}
LPITEMIDLIST pidl(SHBrowseForFolder(&bi));
if(hl) {
LocalFree(hl);
}
if(pidl) {
if(SHGetPathFromIDList(pidl, display_name)) {
strcpy(pszNew, display_name);
return TRUE;
}
}
return FALSE;
}
-- modified at 4:26 Wednesday 12th July, 2006
|
|
|
|
|
Yes, it seems that this function is available...
Besides, it returns the correct result.
Now, the question is, why did my code do wrong, because I could not get the correct result. For instance, your suggestion shown below works like a charm:
hResult = ::SHGetPathFromIDListW(pIDL, lpszPath);
if (FAILED(hResult))
break;
Whereas, the code I was using does not :
IShellFolder* pIShellFolder = 0;
hResult = ::SHGetDesktopFolder(&pIShellFolder);
if (FAILED(hResult))
break;
STRRET strInfo;
strInfo.uType = STRRET_OFFSET;
hResult = pIShellFolder->GetDisplayNameOf(pIDL, SHGDN_NORMAL, &strInfo);
if (FAILED(hResult)) {
pIShellFolder->Release();
break;
}
hResult = ::StrRetToBuf(&strInfo, pIDL, lpszPath, MAX_PATH);
if (FAILED(hResult))
break;
Has anybody any hints ?
Cheers.
Maxime.
--
Maxime Labelle
maxime.labelle@freesurf.fr
|
|
|
|
|
Dear Sir,
Up to now i have not realised to preview all i print(using non Doc/view system). Now I resume to learn again this .
After reading KOAY KAY HOE article and examples, i thing that what is previewing is only controls or dialog.
But what to do if I click on the button and need to preview this text " HELLO THE WORLD" for example.
I learn my self
|
|
|
|
|
Hi,
In my vc++ application I am using Access as the database(connected using DAO). The database and tables are created during runtime.
I name the table depending upon the name the user enters. Now the problem is that if he enters a name with spaces, an errors occurs because of the SELECT sql
Say the name is : tara m
SELECT * FROM tara m
causes an error 'Syntax error in FROM clause'
But the table gets created with the correct name.
I tried putting the table name bet ' ', but it says "wrong formating in querry"
Would you be knowing the right way of doing this. Or I must ask the user to type the name without spaces?
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
I'm no SQL expert, but I think you can enclose the table name with square brackets.
SELECT * FROM [tara m]
(Still not sure why you're creating a table for each name though...)
You might post this question in the SQL forum.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Thank you. I shall check out the square brackets.
Steve Echols wrote: (Still not sure why you're creating a table for each name though...)
Well, the program is such that certain set of 'budget' data should be in one table. And when the user creates another 'budget' a new table with the new budget name has to be created. So if the user wants to delete the old 'budget' all I have to do is delete the table with that name. Makes life easy for me!
Fortitudine Vincimus!
|
|
|
|
|
It worked! Thanks a billion!!
Fortitudine Vincimus!
|
|
|
|
|
even though using brackets solve your problem, having spaces in a sql element is bad design matter. you should avoid doing so (bu replacing spaces with underscores for example).
moreover, the fact the brackets work is because you use MS SQL Server. a Oracle database wont allow you to do such a thing.
ps, this is a SQL question, which has no relation at all with C/C++. next time, ,ask the right forum !!
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
|
It is a Window Style that is supported by "some" Windows Controls.
When set the control sends owner draw messages that can be used to customize the UI of the control to a degree while still leveraging the other behavior and messages of the control.
The owner draw behavior is different for the controls, like Button is different from ListView.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Owner draw feature allows the customizing the existing controls or lets drawing the control from the scratch.
Currently, the following controls support OwnerDraw functionality:
Buttons
ComboBoxes
ListBoxes
ListView controls
Menus
Static controls
Tab controls
Whenever the item must be drawn Windows sends the WM_DRAWITEM message to the window procedure of the item’s owner window. This message contains a pointer to
a DRAWITEMSTRUCT structure.The application can customize the controls by handling this message.
Thanks
|
|
|
|
|
|
I'm trying a double indirect look-up table for some function pointer in my app (yep, I have good reason).
I'm trying to use std::map for the table but (because of the double indirection) I need to use a "std::map*"
Which I don't know how to map[index] (with a pointer)
Now perhaps I'm misusing it, I'm not sure (I know nothing of STL and I have some problem understanding its header)
Anyway here is my code (problem explained in red), if you could give me some tips.....
static std::map<const char*, SEL> map_sels;
static std::map<OClass, std::map<SEL, IMP>*> map_imps;
void id::GetImpAlways(const char* name, SEL& sel, IMP& imp)
{
if( !_handle )
throw gcnew ObjectDisposedException(Class()->Name);
if(map_sels.find(name) == map_sels.end())
{
sel = sel_register_name(name);
map_sels[name] = sel;
}
else
{
sel = map_sels[name];
}
std::map<SEL, IMP> * class_imps; <font color="red">
if(map_imps.find(_handle->class_pointer) == map_imps.end())
{
class_imps = new std::map<SEL, IMP>();
map_imps[_handle->class_pointer] = class_imps;
}
else
{
class_imps = map_imps[_handle->class_pointer];
}
if(class_imps->find(sel) == class_imps->end())
{
imp = get_imp(_handle->class_pointer, sel);
if( !imp )
throw gcnew ObjectiveCException("No such method");
class_imps[sel] = imp; <font color="red">
}
else
{
imp = class_imps[sel]; <font color="red">
}
}
<pre>
|
|
|
|
|
Have you tried dereferencing the pointer like:
*class_imps[sel] = imp;<br />
<br />
and <br />
<br />
imp = *class_imps[sel];
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I am afraid it will create a copy or affect a copy.
I need to alter the static global variable!!
I hate this stupid C++ copy policy, I need to affect the real shared object!!
|
|
|
|
|
Yeah, I agree. I use pointers for storing my objects in containers (right or wrong), just because I know (or think I know) there's only one instance of my object lying around.
I think these classes are good for simple intrinsic types, like ints, etc., but get kind of irritating when you have to define copy, less than and assignment operators for your classes. Just my opinion, of course.....
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
BTW, never mind my problem.
The program crash at the first line:
if(map_sels.find(name) == map_sels.end())
How do I do?
I have a home made C hashtable possibly I should use it instead :-/
|
|
|
|
|
Never mind STL...
I can't even add an element, it throws exception like:
at std._Tree<std::_Tmap_traits<void *,void *,std::less<void *>,std::allocator<std::pair<void * const,void *> >,0> >._Lbound(_Tree<std::_Tmap_traits<void \*\,void \*\,std::less<void \*>\,std::allocator<std::pair<void \* const\,void \*> <\,0> >* , Void** _Keyval)
at std.map<void *,void *,std::less<void *>,std::allocator<std::pair<void * const,void *> > >.[](map<void \*\,void \*\,std::less<void \*>\,std::allocator<std::pair<void \* const\,void \*> > >* , Void** _Keyval)
And what is it supposed to mean?
I just try to run this simple code:
static std::map<void*, void*> map_sels;
map_sels[(void*)name] = (void*)sel;
I dropped it, I will use my C Hashtable.
At least it is simple to use, make no copy and no fuss!...
-- modified at 2:17 Wednesday 12th July, 2006
|
|
|
|
|
Your problem has nothing to do with maps: it's a simple pointer error. Here's the relevant bits of your code:
std::map<SEL, IMP> * class_imps;
class_imps[sel] = imp;
class_imps is a pointer but you're using it as if it was a map . This should look like this:
(*class_imps)[sel] = imp;
Here's an example to make this clearer:
class Foo
{
void Bar();
};
void SomeFunction()
{
Foo *pFoo = new Foo();
pFoo.Bar();
delete pFoo;
}
Steve
-- modified at 3:01 Wednesday 12th July, 2006
PS: Use typedef s instead or repeating the long map types all over the place.
|
|
|
|
|
I knew I was calling the operator on an invalid object.
But I don't want to use "plain object" (as opposed to pointer).
if I do that, as far as I know, I will work with copy of the object, not the real object.
And I don't care about the life of the copies!
Anyway I dropped STL and used my own C implementation of hashtable.
No copy, no fuss...
|
|
|
|
|
I didn't suggest you not use a pointer. I suggested you don't confuse the pointer with what it points to. You done this:
class_imps[sel] = imp;
I suggested you do this:
(*class_imps)[sel] = imp;
In the first you're not even using the map, you're using a pointer to a map. In the second you're using the map and the only thing copied is imp when the map makes a copy to store. Given that the map 's mapped type is IMP this is exactly right.
Steve
|
|
|
|
|
You misunderstood what I said. I said the same thing as you!
That's understandable, as I probably confused you is when I implyed that (*class_imps) was making a copy.
Of course it doesn't, silly me!
Too late I am using my C Hashtable now.
It works well and there is absolutely no copy whatsover (whereas std::map use some sort of default allocator as far as I know).
beside I was not able to use it at all!
example:
std::map<void*, void*> map;
map[(void*)1] = (void*) 2;
is throwing some mysterious (and C++) looking exception.
|
|
|
|
|
Super Lloyd wrote: It works well and there is absolutely no copy whatsover
You're wrong there. If it stores pointers then the pointers are copied; same as with a map of pointers. If it stores IMP s then the IMP must be copied; again the same as a map of IMP s.
I tried your code and it works fine. Here's what I tested:
#include <map>
#include <iostream>
int main(int argc, char *argv[])
{
using namespace std;
typedef map<void*, void*> VoidStar2VoidStarMap;
VoidStar2VoidStarMap MyMap;
MyMap[reinterpret_cast<void*>(0)] = reinterpret_cast<void*>(1);
cout << MyMap[reinterpret_cast<void*>(0)] << endl;
return 0;
}
The reinterpret_cast<void*> is the same as the (void*) cast in your code. I make it a rule never to use C-style casts.
You're using managed C++ aren't you? I use unmanaged C++ - I don't approve of managed C++.
Steve
|
|
|
|
|
Stephen Hewitt wrote: You're wrong there. If it stores pointers then the pointers are copied; same as with a map of pointers. If it stores IMPs then the IMP must be copied; again the same as a map of IMPs.
Hum.. you're right....
Stephen Hewitt wrote: I tried your code and it works fine.
does it?
Stephen Hewitt wrote: You're using managed C++ aren't you? I use unmanaged C++ - I don't approve of managed C++.
I confess that I'm not that at ease with native C++.
I jumped from C to C#/Managed C++ (well I did some ObjectiveC & Java too)
But everytime I should do pure C++ brrr....
Not too mention that code that did compile in 1995 no longer compiled in 1998! (yes this way! not the opposite!)
And that GCC and CL don't support the same set of C++
Beside many tests failed to prove to me that C++ perform that much faster, so why bother
|
|
|
|
|