|
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++
|
|
|
|
|
Thanks for prompt reply!
You are absolutely correct, and I am having difficulty doing this. I am declaring the structure outside of WinMain and I am setting the values in my message loop. I thought that would take care of the scoping issue. What am I missing?
|
|
|
|
|
Can you show the code (or equivalent)?
Here's a simple example - it's a silly example since the thread proc has
direct access to the global struct object, but hopefully it
shows you a way to pass a pointer to the thread proc...
#include <process.h>
struct MyThreadParams
{
int a;
int b;
int c;
};
MyThreadParams GlobalThreadParams;
unsigned __stdcall WorkerThreadProc(void *lpParameter)
{
MyThreadParams *pThreadParams = (MyThreadParams *)lpParameter;
return 0;
}
int SomeFunc()
{
GlobalThreadParams.a = 0;
GlobalThreadParams.b = 1;
GlobalThreadParams.c = 2;
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, &GlobalThreadParams, 0, NULL);
if (hThread)
{
::CloseHandle(hThread);
}
...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Errr, just a stupid question: what's the point of passing a pointer to a global structure ? Your thread can access it directly
|
|
|
|
|
I try a stupid answer: the thread hasn't to know it is working on global scope. I mean, you may have two or three of such structs and the thread is designed to work always on a single one, then you select the proper one on thread call (i.e. something similar to a master/slave approach to threading).
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]
|
|
|
|
|
If you look closely, I stated:
"...it's a silly example since the thread proc has
direct access to the global struct object, but hopefully it
shows you a way to pass a pointer to the thread proc..."
So, basically, it's because I was too lazy to type a more
robust example
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: If you look closely
Ha ! That was the problem, I knew it
|
|
|
|
|
Cedric Moonen wrote: I knew it
I knew it too, because I now have my CPMRU
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|