|
Cool, Rajkumar! Great!!
A question about http://msdn2.microsoft.com/en-us/library/aa271769(VS.60).aspx[^],
Seem if we do not use dllimport there will be one more level of indirection and the root cause is we do not know the address of function from IAT if we do not use dllimport, right?
What is the obstacle of blocking the approach (not using dllimport) from knowing the function address in IAT? From the MSDN, I can not see why if we use dllimport, the IAT can be known and if we do not use IAT the address is not known.
I think the IAT is contained in the import library file (.lib file), and whether or not we are using dllimport, it is input to linker, right (so it is always known)?
regards,
George
|
|
|
|
|
|
Thanks Rajkumar!
regards,
George
|
|
|
|
|
Importing by ordinal is faster as it simply uses the ordinal as an index into an array of function pointers (well RVAs actually) instead of performing a binary search on function names. That said, I doubt that importing by name is a problem for many applications.
Steve
|
|
|
|
|
Thanks Steve,
My question is answered.
regards,
George
|
|
|
|
|
Hello everyone,
I think there is only one COM CreateInstance method, which belongs to IClassFactory interface.
Is there another CreateInstance method, which does not belongs to any class/interface and belongs to the COM global library function (like CoCreateInstance)?
thanks in advance,
George
|
|
|
|
|
Sorry?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Sorry for what? I have not made myself understood, CPallini?
regards,
George
|
|
|
|
|
George_George wrote: I have not made myself understood, CPallini?
Yes. At least I cannot undersatnd what you're asking for.
As you already know CoCreateInstance is simply a shortcut for the sequence
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory, &pCF);
hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj)
pCF->Release();
That, in turn, shows CoGetClassObject , another function of the COM library.
Bottom line, COM library provide a set of standard functions (such as CoInitialize , CoCreateInstance , ...). Does that make you wonder?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
My question is, for COM defined functions (including the functions in COM defined interface and class) -- which are not used defined functions, beyond the CreateInstance function in IClassFactory, are there another function which has exact the same name of CreateInstance?
Let me know if I have not made myself understood.
regards,
George
|
|
|
|
|
hi
iam working with some dialog applications in VC++.iam facing a problem in one of the application i have developed a dialog application and it was running fine then i want to exetend the funcationality so i have added few more controls to it and added member variables to those controls then i have executed the application and it was not running.when i removed those member variables it was running.what may be the problem? please can anyone solve this probelm.
sathish
|
|
|
|
|
Which kind of controls did you add ?
|
|
|
|
|
In addition to Cedric's answer...
Have you tried adding them one by one?
Is the dialog able to create, or is it failing? If it fails in debug mode, then single step through and see where it fails.
If it fails on dialog creation, then you can set a no-fail-create style for the dialog in the dialog editor. That may help you narrow down the fault.
Are you using custom classes for the control's you're adding, and have you registered that class before you create the dialog?
For all we know, you've got a bug in the code handling those controls - the only way to find out is to debug your application.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
If you add the DS_NOFAILCREATE style to the dialog, does it display then?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
As I am using CScrollView in my application, I have called SetScrollSizes() in my override of OnInitialUpdate(). However, I get an assertion when I check the mapping mode. The code is as below:-
SetScrollSizes(MM_LOMETRIC,TotalSize);
CDC* pDC;
pDC = GetDC();
int iMapMode;
iMapMode = pDC->GetMapMode();
ASSERT(iMapMode == MM_LOMETRIC);
I'm sure that there is a simple answer to this !!!
Doug
|
|
|
|
|
Probably because iMapMode != MM_LOMETRIC for your freshly obtained client DC.
There's no reason iMapMode == MM_LOMETRIC unless you set
the mapping mode to MM_LOMETRIC for the DC. This will be done for you
in the CPaintDC that is passed to the OnDraw() method of the view class,
so there your assert should succeed.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Isn't it amazing (and humiliating ! ) how obvious something really is when someone else points it out !!! Thanks Mark !
Doug
|
|
|
|
|
Heh - nah it's not that obvious....The docs aren't real clear on
this if I remember right. The source code is better documentation.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
pretty daft question; because I know I saw an answer somewhere to that question.
Howdy'
I'm creating a dialog application; when the application starts, I automatically launch a "lengthy" process (loading data and stuff).
I am calling that process at the end of OnInitDialog ; so the dialog is not displayed until the process is finished.
Is there a message or technique to know that the dialog is actually display before starting my lengthy process ?
Or what can I google for ?
Thanks.
|
|
|
|
|
That's been discussed many times with many different solutions
I'd wait until the first WM_PAINT message then post a private message
to the dialog. In response to that message, start the lengthy process.
Your lengthy process should be on a separate thread so this wouldn't be an issue,
and it's just good form
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Your lengthy process should be on a separate thread so this wouldn't be an issue
Yeah, I know, I know!
Thanks Mark.
|
|
|
|
|
Well, you can always yield to the system periodically during the lengthy
process by pumping out any pending messages
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just define an application message:
#define WM_STARTMYPROCESSINGTASK (WM_APP+1)
Then at the end of your OnInitDialog() method, use PostMessage(WM_STARTMYPROCESSINGTASK). Add a handler for this message and in that handler, start the worker thread.
|
|
|
|
|
I am writting an application that needs to create a thread, I have no problem if I only want to pass a handle, however I need to pass several parameters to the thread. I tried creating a structure to no avail, I also tried passing the address of the variable structure with the same results.
Can I create handle to a structure, or what options do I have?
I also wonder if the values in the parameters the thread uses will change if my application changes them.
This newbie, thanks you in advance for your help.
|
|
|
|
|
Passing a pointer to a structure/class object should work fine.
You need to make sure that pointer and the object it points to
stays in scope. The struct/class object can be on the heap, or
it can be a global object, or a member of another struct/class
object that stays in scope.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|