|
WTL doesn't have a CFile class. If you want to use MFC and WTL together, start a new MFC project, add support for ATL in the wizard, then add the WTL headers manually to stdafx.h.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Background:
I've finally feel comfortable with c++ programming and now i want to get into 2D Game Programming. I'm using the free Borland compiler from the Command Prompt for my studies and so that makes it even harder.
Problem:
Since I'm trying to learn, the best way is to study the code and learn from it, however, all the DirectDraw/DirectX examples are written in VC++.
Question:
Can I implement DirectX, create a GUI, and use ATL/WTL/STL libraries to create 2D games such as Tetris using this compiler?
Follow-up Challenge:
If someone is movated to do so, can I just see a "skeliton" window using Direct X and DirectDraw in a GUI window using ATL/WTL/STL?
Summary:
Also, If I don't know what I'm talking about feel free to call me an idiot but if you do, also please correct me.
When in doubt, shout it out because the worst that could happen is waking up with a headache and a hospital bill.
|
|
|
|
|
How can I manipulate BSTR typed string in ATL3COM?
Can I convert it to some manipulateable String type?
If yes in which?
Kindly guide me.
Kind Regards
Atif
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
You may want to use the following functions to convert from/to char*/BSTR:
_com_util::ConvertBSTRToString(BSTR pSrc)<br />
_com_util::ConvertStringToBSTR(const char *pSrc)
Hope this helps.
-Tareq
|
|
|
|
|
|
Hi all,
I have a question, if you have some solutions, please advice me.
How to download a file without common file download dialog
I heard some people that you should do it, you have to
develop IE plugin. I investigated, knew that I have to use ATL.
Please advice me, how to, sample program, API ...
Thank you in advance for your kindness.
Best Regards,
yu-yu
|
|
|
|
|
|
HI Mike,
I think this situation,
A client perform click on HTML.
Usually, user execute 2 actions.
1.one download file dialog display, and click button.
2.another file dialog display and set directory and file name,
and download it.
This precondition is to decide download directory and file name.
I would like to download without 2 actions.
is it possible to do it ?
Best Regards,
yu-yu
|
|
|
|
|
|
Hi Mike,
Yes, I think so.
But, I memorise some virus situation.
When we click HTML infected virus, it download client
not to notice user, but it cause IE's security hall.
When I develop plugin that have mouse click event control
functin using ATL, this problem is solved.
But I have not skill to develop it still.
Do you think about it ?
Best Regards,
yu-yu
|
|
|
|
|
Hi All,
I am in the process of developing an ATL/COM extension for an application in which I have embedded the Windows Media Player ocx COM Control into an ATLDialog object. How do I get control of this object so that I can change the video being displayed? I guess if it was a CDialog I could use the appwizard to map the control to member variable. How do I do this for an ATL Dialog?
Do I get the handle and then ......
You help would be greatly appreciated
cheers
Bryce
|
|
|
|
|
Hi ,
U can use GetDlgItem(IDC_MEDIACONTROL1) , this will return u the handle of the media control window
now create a CWnd object attach this media control handle .
HWND hwn=GetDlgItem(IDC_MEDIACONTROL1)
CWnd * wnd=new CWnd();l
wnd->Attach(hwn);
then call wnd->GetControlUnknown()..this will return u the IUnknown Pointer.
Using this pointer query for other media control interfaces..and enjoy coding
byee..hope this solves ur problem
'
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi Abhishek,
Thankyou for your help.
I have done what you said above, but need a little more guidance. When you say at the end "Using this pointer query for other media control interfaces..and enjoy coding"... what is the other media control interfaces? What interfaces/objects should I be aiming to query too...?
I want to be able to do something like....
HWND hwn=GetDlgItem(IDC_MEDIACONTROL1)
CWnd * wnd=new CWnd();
wnd->Attach(hwn);
IUnknownPtr pUnknown;
pUnknown = GetControlUnknown();
//.......
//Query interface to some type of MediaPlayer object
IMediaPlayerPtr pMyPretendMediaPlayerObject; //any ideas on the correct interface?
pMyPretendMediaPlayerObject->Open("The path to the file I want");
pMyPretendMediaPlayerObject->Play();
//.......
Does the logic for this seem ok.... or could you point me to somewhere I could read up on this.
thanks for your help
cheers
Bryce
|
|
|
|
|
Hi once again, sorry for not making myself so clear..
actually i mean
using that IUnknown Pointer
like
IUnknown *unk=wnd->GetControlUnknown();
Query for other interfaces like this
IMediaPlayer *mediaplayer
unk->QueryInterface(IID_IMediaPlayer,(void **)&mediaplayer);
in the same way all other interfaces that Windows Media Control Supports ..u can see supported interface in VB Object Browser(by addding Control in a VB and browse that object .using utility object browser).
So ...tell me if it worked..and i am making myself clear!!
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi Abhishek,
Yep looking at the VB object browser was a good idea.
I have foudn one reason why it was not possible working.... I forgot to import the ocx object definition for the MediaPlayer (msdxm.ocx).
However, when I define the IMediaPlayer the compiler doesn't have a clue about what to do.
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'IMediaPlayer' : undeclared identifier
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'mediaplayer' : undeclared identifier
C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : warning C4552: '*' : operator has no effect; expected operator with side-effect
I getting pretty frustrated why it seems so complex to something that should be simple.
I am relatively new to ATL MFC etc.... but this should be a walk in the park.
thanks for your help
cheers
Bryce
|
|
|
|
|
|
Hi Michael,
Thanks for the pointer to your articles! nice to read the background info on why certain things have to be done.
The WTL example that you posted was with a com server (.exe). Does having my extension with activex control change many things if it is in a DLL?
Cheers
Bryce
|
|
|
|
|
|
The Windows Media Player SDK has an example of this called "WMPML" which can be downloaded with the SDK at www.windowsmedia.com
It implements a big CAxDialog, but it doesn't compile! I haven't bothered trying to fix it, but it's probably what you're looking for.
Ryan
|
|
|
|
|
Are collections and containers created on the heap or the stack? IOW, do they persist or do they disappear after leaving the function in which they were created (understood that they weren't written out to a file or a database, etc.)?
If I need to defined more explicitly what I mean by "created", it would have to combine them being instantiated and populated.
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
In STL, the base container is allocated as you would expect, either on the stack or on the heap. The elements, however, are allocated on the heap (usually from a memory pool, but you can supply your own allocator).
When the destructor for an STL container is called, it calls the destructor for all contained elements and frees the memory. Note that this does not mean that if you have a collection of pointers that the memory they point to will be deleted; you'll need to delete those yourself.
- Mike
|
|
|
|
|
Thanks for replying.
When is the destructor for the container called? Is it an automatic thing, or would you have to purposely call it (other than when it's done automatically for you upon exiting the program)?
If the elements are on the heap, then by doing an "erase()" you would purposely be deleting the elements (etc.), but if no such function were used, then the container and its elements should persist.
Both the vector and the map containers are defined in the same class, and instantiated in the same function. However, they were populated in different functions, but when they met back up together, the "size()" of the map showed zero (even though the class object in which they reside was still alive and no "erase()" function was used).
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
When is the destructor for the container called? Is it an automatic thing, or would you have to purposely call it (other than when it's done automatically for you upon exiting the program)?
The destructor for any type in C++ is called (implicitly):
- For stack-allocated objects, it's called when the object goes out of scope.
- For heap-allocated objects, it's called when you use
delete on it.
So, for example:
void foo() {
std::vector<MyClass> myvec;
myvec.push_back(MyClass());
myvec.push_back(MyClass());
myvec.push_back(MyClass());
} myvec is destroyed at the end of the function since it is allocated on the stack. Each of its elements is also destroyed since they are not pointers. (Also I should note that when adding items to an STL container, the items are always added by copying, so each of those calls to push_back() is actually creating a new instance of MyClass , adding a copy of that instance, then destroying the original instance).
A couple more examples to illustrate the point:
void foo() {
std::vector<MyClass*> myvec;
myvec.push_back(new MyClass());
myvec.push_back(new MyClass());
myvec.push_back(new MyClass());
}
void foo() {
std::vector<MyClass> *myvec =
new std::vector<MyClass>();
myvec->push_back(MyClass());
myvec->push_back(MyClass());
myvec->push_back(MyClass());
} WREY wrote:
Both the vector and the map containers are defined in the same class, and instantiated in the same function. However, they were populated in different functions, but when they met back up together, the "size()" of the map showed zero (even though the class object in which they reside was still alive and no "erase()" function was used).
I'd have to see the code, or at least a minimal test case that illustrates the problem.
- Mike
|
|
|
|
|
Thanks for replying.
Your statements provided both fundamental clarity and meaningful directions to the issue at hand. I can sense a solution not far off.
Thanks again!
William
Fortes in fide et opere!
|
|
|
|
|
Does anybody have an idea what is this new command line argument "-Embedding" an Atl Server/Service gets invoked with, if you access a com object hosted in a NT Service/Server. This only start happening after I have installed the very latest sevice update from Microsoft last week. The MSDN failed to mention anything about it.
Regards to all
Ian Ferreira
Technical Director
IPWorks (Pty) Ltd
Cape Town
South Africa
|
|
|
|