|
Clifford Hall wrote:
ALSO is there any info on getting JPEGs to be loaded as well???
Read the FAQ.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I'm am just starting to learn Visual C++ and I'm having difficulties understanding how to implement certain concepts. What I'm trying understand is how a veiw/doc program works, especially how to transfer information from a modal dialog box created in a view section to a CArray in a Document section. I'm also having problems on how to use a spin control and list box in a dialog box.
Does anyone have a very basic demo program that will show me how to get information between these sections (doc and view) and how to use some of the basic features of a dialog box (ie list box, spin control, etc)?
Thanks
Ed
|
|
|
|
|
First of all, you'll find long term that std::Vector is a much better container than CArray, which was written only to be used while the STL was finalised. Check out my STL 101 articles for more info.
Secondly, the way to get info out of a modal dialog is to stuff it out of the controls ( which are destroyed ) into a container ( CArray or vector are fine ) and then read that from the dialog object after the modal loop has ended. The variables continue to exist, but the windows (controls) have been desroyed.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Where can I find your STL 101 articles?
Which is better for intensive number crunching? (Vectors or Carray)
Can a vector hold a custom structure?
|
|
|
|
|
In the STL section.
I tried this yesterday with no success, but hopefully here is a link to my vector article, which is at http://www.codeproject.com/vcpp/stl/STL101.asp (just in case it didn't work again ).
ed1 wrote:
Which is better for intensive number crunching? (Vectors or Carray)
Vector, only because the STL comes with a ton of algorithms, which have been written to be as optimised as possible.
ed1 wrote:
Can a vector hold a custom structure?
Absolutely, but you'll need to read my article on function objects to see how to use custom objects with the algorithms. Of course CArray has no algorithms at all, so it's hardly a bad thing, in fact you'll find it amazingly powerful.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
There are some good posts here on the board, but nothing really answers my question.
Say I have an object foo, and a function called DoSomethingWithFoo( IDispatch** val ), it seems a bit of a pain to have to use the IDispatch interface when I would like to just pass the object in. Sureley there is an easy way? To make this clearer:
I have a pointer MyFoo*. I want to call a method bar, which does something with foo objects. Unfortunateley, we only have a bar( IDispatch* ). It seems a pain to pass in an IDispatch pointer, then to use idispatch->Invoke, simply to call the method I want, especially when I have lots of methods to call-
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&df=6&app=50&tid=82458&select=82458#xx82482xx
If this isnt clear please say-!
Thanks in advance
MO
|
|
|
|
|
If I understand you well:
IDispatch *pD;
MyFoo *pMf;
pMf->QueryInterface(IID_IDispatch, &pD);
Bar(pD);
pD->Release();
If this is not the answer you're looking for, please explain a little more.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Im not sure if thats what Im after, although Im experiemting now.... ill put it another way:
I have:
Member *myMember;
and a function:
MyClass::getMemberDetails( idispatch **val )
It would be cool if I could just go:
myClassObj.getMemberDetails( &myMember )
But instead I have to do this:
IDispatch *d;
myClassObj.getMemberDetails( &d )
So now the IDispatch item is pointing to the object I want, nameley a Member.
However, to invoke member funcitons on this new member, I have to use IDispatch::invoke, and all of the things which go with it (which I discovered on another post.) Id love to avoid doing all of this....
Hope thats clearer - and your help is much apprecaited on this!!!
|
|
|
|
|
Can you post a code sample? I'm not exactly sure what you asking. Is MyFoo* an interface, or more precisely a pointer to an interface or just a pointer to an instance of a concrete class?
|
|
|
|
|
sorry in the code sample above, member is an interface...!
|
|
|
|
|
Then I think you should be able to what your trying to do. As long as Member inherits from IDispatch, then the compiler will implicitly convert from an IDispatch pointer to an Member pointer. Is it not working?
|
|
|
|
|
What happens if you do this:
IMember *myMember = NULL;
myClassObj.getMemberDetails(&myMember )
|
|
|
|
|
If I just use my interface instead of idispatch:
cannot convert parameter 1 from 'struct IMessengerContacts ** ' to 'struct IDispatch ** '
If I add a cast, it compiles, but subsequent use of the pointer crashes it.... Here is the actual code:
IMessenger *msger;
IMessengerContact *pContact;
IMessengerContacts *pContacts;
IDispatch* id;
long pCount = 0;
hr = CoCreateInstance( CLSID_Messenger, NULL, CLSCTX_INPROC_SERVER, IID_IMessenger, (LPVOID*) &msger );
hr = msger->get_MyContacts( (IDISPATCH**) &pContacts );
pContacts->get_Count( &pCount );
I dont think I can use mine instead, as my object doesnt inherit from IDispatch, it implements it....
Thanks again
|
|
|
|
|
Is the line where it wont compile:
hr = msger->get_MyContacts( &pContacts );
This compiles, but the following line crashes:
hr = msger->get_MyContacts( (IDISPATCH**) &pContacts );
pContacts->get_Count( &pCount );
|
|
|
|
|
as my object doesnt inherit from IDispatch, it implements it
Shouldn't you be inherting from IDispatch and implementing it's methods?
|
|
|
|
|
Apologies, it does already:
IMessengerContacts : public IDispatch
Any ideas why it wont let me pass in an IMessengerContacts??? Hmmm
|
|
|
|
|
I think what I said earlier would only work if your method looked like this :
Messenger::get_MyContacts(IDispatch);
instead of:
Messenger::get_MyContacts(IDispatch*);
I think your gonna have to do this...
IMessenger *msger = NULL;
IMessengerContact *pContact = NULL;
IMessengerContacts *pContacts = NULL;
IDispatch* id = NULL;
long pCount = 0;
hr = CoCreateInstance( CLSID_Messenger, NULL, CLSCTX_INPROC_SERVER, IID_IMessenger, (LPVOID*) &msger );
hr = msger->get_MyContacts( &id );
hr = id->QueryInterface( IID_Contacts, &pContacts );
pContacts->get_Count( &pCount );
...
Ahhh, the joys of COM....
|
|
|
|
|
Thanks, you are a star!! This is basically what the first guy was trying to tell me, but I was too daft to realise
I feel that I understand COM a lot more now after fiddling around with this stuff for the lsat 9 hours !!!
Thanku!
|
|
|
|
|
I'd like to include the formatting rebar in a dialog box I'm creating. Does anyone have a sample of this? Maybe this might be an idea for an article?
The formatting rebar I'm talking about is featured in many MS editor based programs, such as MS Word, or Frontpage, and includes font selection, point selection, bold italic and underline selection etc.
Many thanx,
funbag
skydiving....if at first you don't succeed, you're fecked!
|
|
|
|
|
If I recall correctly, on the MSDN Help there is an example of an application similar to WordPad, maybe you can look it up there.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Couple of questions regarding PropertySheet Wizards:
- Is there a way to remove the upper right corner close button on the wizard pages?
- Is there a way to make one of the pages smaller? My first page in the dialog editor is smaller than the second. When I run the code, both pages are made the same size. I suspect the PropertyPage class sizes all the pages to the size of the largest page. I would like to make my first page the same size that is shown in the dialog editor.
Thanks in advance,
Bob
|
|
|
|
|
I try to set the focus to a control in a dialog window. I do this by calling
SetFocus to the object associated in the end of InitDialog().
But the result is nop. The focus is owned by other control and it doesn't
seem to be happy to renounce.
What is the solution?
rechi
|
|
|
|
|
Have you seen this comment at the end of the OnInitDialog() ?
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Unfortunately, it doesn't.
rechi
|
|
|
|
|
is it possible to create a new shared folder using VC++/MFC..so that files from this folder can be accessed from another machine?
anyhelp will be appreciated!
|
|
|
|