|
Hi CPians,
Using SHBrowseForFolder, how do I start browsing from a given directory and not from the desktop ?
The pidlRoot parameter of the function seems to be the key, however I do not have the slightest idea how to deal with it. I have one MSDN example where the init directory is set to the current directory, but it uses callbacks and seems to me as using a blockbuster to catch a fly.
Any idea ?
~RaGE();
|
|
|
|
|
|
|
...probably second only to "CListBox?" as the numer one repeated question in the forum...
No, Rage, I am not critisizing you, but Microsofts Documentation in the first place
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi, excuse me that i write this question in VC++ forum, but i don have idea where to put it...
Can someone tell me from where i can find an algorithm that draws arc,when are given 3 points and radius. I mean arc(int x,int y,int x1,int y1,int x2,int y2,int radious).
I know some algorithms , for example the arc algorith of Bresenham, or the middle point algorithm, but i can not find source code. Please help me.
|
|
|
|
|
gandalf1983 wrote: Hi, excuse me that i write this question in VC++ forum
On What language do you want the source code?
However, I am giving you a link which you could follow to get your solution.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9992&lngWId=3[^]
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Hi,
I am exporting classes from a dll, and I try to avoid recompiling the world, when the dll changes. I am feeling uncertain in that point and would greatly appreciate your advice.
I reckoned the only problem would arise when classes with virtual functions would be used by the client. I set up a little experiment with 3 classes A, B and C, with 3 virtual functions each. C inherits from B and B from A.
Found..
I can not change the order of virtual functions, nor can I insert one. The vftable entries seem to be permuted resp shifted by the number of insertions.
I can insert additional code into a function, so that the function entries in the map file have shifted adresses. But still the client works without recompiling. I thought it would crash, why not does it? I thought this would result in wrong vftable entries. Are these not generated at dll compile time?
These problems only seem occur when I use pointers to instances of these classes. I.e. as long as I do not pass any instance from a dll class via reference, or make a pointer to it, I will not have to recompile the client. True?
Best regards
Werner
|
|
|
|
|
First, I'm no expert on this, so I may be wrong.
As I understand it you have three questions:
1: Why does your vtable still works although the functions in the dll have changed base adresses?
2: When are vtables generated?
3: How are dlls linked to the main app?
1: (actually ties in with two and three, but here goes) The vtable is populated at compile time. The main app calls the virtual function through the vtable, but reads the vtabel at runtime, not compile time. That's why it will work as long as the entries in the vtable doesn't change position. For instance, it's important that the adress of CYourClass::Foo is always the second entry in the vtable, but it's not important (at compile time) what the actual value of the second entry is.
2: at compile time.
3: When the app is started the dlls that it depends on are loaded (in theory, at least), and the entries into the dll are read from the export table. This is dynamic linking, where the function calls are resolved at runtime. Even though your statically link to your dll Windows will still dynamically link the dll - all the LoadLibrary and GetProcAddress calls are just done behind the scenes. So, as long as the app can find the right entries in the table the dll will work.
Why it doesn't work with function pointers is a little more unclear to me, but that will of course depend on how you construct and use the pointers.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thank you!
The vtable is populated at compile time. The main app calls the virtual function through the vtable, but reads the vtabel at runtime, not compile time.
> => when I insert a virtual function or change its position, the the client will read a wrong function address instead of the original one, if it does use the vtable.
Why it doesn't work with function pointers is a little more unclear to me, but that will of course depend on how you construct and use the pointers.
> you gave the answer. When I use a class from a dll this way
MyDllClass theClass;
theClass.aVirtualFunc(); // the vtable will not be used when calling this function (right?). It's clear, to which class aVirtualFunc refers, it can be referred to by it's export name or ordinal.
But here
MyDllBaseClass * ptheClass = new(MyDllClass);
ptheClass->aVirtualFunc(); // the vtable will be used. Beware of changing the functions position in the dll without recompiling the client. The wrong function will be used
(it happened also when I used a MyDllClass * instead of MyDllBaseClass *).
or even here, I think - and less obvious -
MyDllClass theClass;
doSomethingWith(theClass);
..
void doSomethingWith(MyDllClass & refToMyClass) {.. // because there is an implicit pointer operation.
.
Cheers Werner
|
|
|
|
|
WernerP wrote: MyDllClass theClass;
theClass.aVirtualFunc(); // the vtable will not be used when calling this function (right?). It's clear, to which class aVirtualFunc refers, it can be referred to by it's export name or ordinal.
I think the vtable will be used regardless of whether you use . or ->, but it may be implementation-specific. In any regard, you shouldn't count on it.
As cmk wrote, you have no control of the ordinals assigned to the exported functions when you use __declspec(dllexport). So the safest option is to recompile. Anyway, if you headers doesn't change it's only relinking which is pretty fast. If your headers change you need to recompile anyway.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
A dll has functions exported by ordinal, and (optionally) name.
When you create a dll you have 2 ways of exporting data/functions:
1. use an export file
Here you explicitly define the ordinal (and optionally hide the name) of the functions to be exported.
Because you control the ordinal you control any changes that occur between releases.
Usually when new functions are added you just assign them new (unused) ordinal values.
Class methods are exported using their mangled names, which makes this a tedious way of exporting class' by hand, usually you will have another program generate this file.
2. use __declspec(dllexport)
Here the compiler auto-generates the export table from all __declspec(dllexport) it finds.
You have no control over the ordinals assigned to data/functions.
I assume you are using __declspec(dllexport) statements.
What you are talking about is observing an effect and inferring a reason.
You can NOT assume your conclusions will hold for all cases - they won't.
To get the result you want you need to use an export file.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_export_functions_from_a_dll_by_ordinal_rather_than_by_name.asp[^]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks. Option 1 is tedious indeed. I have been looking for ways how to generate a def file with mangled names, they talk about using
(1) the VC++ /FAcs compiler option to get a listing
(2) the VC++ generate map file option when linking
(3) the DUMPBIN.EXE on the dll
to get the mangled names.
There is also a tool from
http://www.objmedia.demon.co.uk/freeSoftware/def32.html[^]
which creates a def file from the map file and also assigns ordinals to it. The result looks ok (but haven't yet tested compiling and linking).
regards Werner
|
|
|
|
|
The ObjMedia tool looks promising.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
How can I make the text in window titlebar in the center of titlebar, I can't find any check box in dialog properties?
|
|
|
|
|
There are no standard flags you can set to centre justify text in a title bar. If you need to do something like that then you will ahve to custom draw the caption yourself.
See the Custom caption article here at CP by David Lorde
If you vote me down, my score will only get lower
|
|
|
|
|
As far as i know there is no such method
present right now .
But can use a CString variable and then
format it according to the length of the
window.
Put this code on redraw window which will
dynamically change the caption when window
is redrawn
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
pc_dev wrote: How can I make the text in window titlebar in the center of titlebar, I can't find any check box in dialog properties?
There is no such property .. but you can centre your caption text simple mathematics... by providing extra space at start of your caption! or make your custom titlebar here is link for that :-
http://www.codeproject.com/wtl/titlebar.asp[^] [WTL]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
You may perform some calculation. For example, the following
code does it:
CString str = TEXT("My Title");
CRect rcWindow;
GetWindowRect(rcWindow);
TEXTMETRIC tm;
CDC *pdc = GetDC();
CSize szCaption = pdc->GetTextExtent(str);
pdc->GetTextMetrics(&tm);
int nAveCharWidth = pdc->GetTextExtent(" ").cx;
int x = (rcWindow.Width() / 2) - (szCaption.cx / 2);
int nWhites = x / nAveCharWidth;
CString strCaption = TEXT("");
for (int j = 0; j < nWhites; j ++)
{
strCaption += TEXT(" ");
}
strCaption += str;
ReleaseDC(pdc);
// Now strCaption will be set at the center of the title bar
SetWindowText(strCaption); // or do it yourself
--
======
Arman
|
|
|
|
|
Hi
I have a ICopyHook handler which i register for finding deletion of folders . When the folder is moved to recycle bin . The Handler is giving only the source path and i am not able to get the destination path(i.e) the path of the recycle bin . Any idea on how to get the destination path ?
Thanks in advance
|
|
|
|
|
Hi,
I want to set the focus to a CButton control.
I'm using GetDlgItem(IDC_MY_BUTTON)->SetFocus(); but it does not work.
It works for CEdit controls but not CButtons.
How can I set the focus to a CButton control?
|
|
|
|
|
actually, yes, it set the focus, but the problem is graphical (button style pb).
but i'd ask you one more thing : do you want to set the focus on the button, or change the default button ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You are correct, it does have focus, but does not accept the enter key.
I want to set the focus.
See the replys below
Many Thanks,
AORD
|
|
|
|
|
hum, it seems that what you need have been answered several ways, but at a low level...
did you try CWnd::GetDefID() ?
by using this function, the window the button is on will change its default button (it will remove the property from the last one to set it to the button you provide then). this way, you'll be able to press the "enter" key to use you button.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
AORD wrote: GetDlgItem(IDC_MY_BUTTON)->SetFocus();
Well, it wont work. I have been facing similar problems, and I go down to PostMessage() level. What you probably can do is, Get the handle of the button with which you would want to deal, and then continue by posting an appropriate message. The following code snippet should help solving your problem.
<br />
HWND hButton;<br />
GetDlgItem(ID_MYBUTTON, &hButton); <br />
::PostMessage(hButton, BN_SETFOCUS, 1, 0);<br />
Regards,
Rajesh R. Subramanian,
Cyberscape Multimeida Limited,
Bombay, India.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
See my answers down ...
SkyWalker
-- modified at 11:46 Monday 14th November, 2005
|
|
|
|