DX in a window thats in a window

Started by
8 comments, last by steg 19 years, 8 months ago
Hi again, another odd request that google isnt being forthcoming with..... I realized that since everything is a window (a button, a picture, a checkbox, etc.... all windows, right?), then if all windows have a HWND, and all directX needs in order to draw something is a handle (a HWND) to something, you *should* be able to draw a (for example) rotating cube on a button, or draw the scene in a picture and have controlls outside it. So my question is : how do you make a picture area? btw, I dont know MFC, or really any code for any controlls... still googling tho... -Jason
normal_toes@hotmail.com
Advertisement
You don't need MFC, or whatever library. All you need is the Win32 API and a dialog-building tool. There's one that comes with VC++, but you can even code a dialog-script. Clicky
Just use a static control.
and if you do use mfc, it's as simple as two functions, GetDlgItem and GetSafeHwnd to retrieve the window handle for that control
Also, keep in mind D3D uses *TWO* hWnds. The presentparams one is the the render window, the CreateDevice() one is the focus window, which must be a top level window, not a child.
Needless to say but it is even easier in plain Win32 API since you just have to call GetDlgItem() - this will return either a valid HWND or NULL.
Quote:Original post by Emmanuel Deloget
Needless to say but it is even easier in plain Win32 API since you just have to call GetDlgItem() - this will return either a valid HWND or NULL.

Yup. Win32 isn't much harder than MFC. A bit cleaner though.
Quote:Original post by Pipo DeClown
Yup. Win32 isn't much harder than MFC. A bit cleaner though.


The API isn't harder, but using MFC more than halves the time you spend coding, usually. Atleast once you get to know MFC, and get used to working with it.
*around it.

;)
.sigMarginally offended by this post? Rate me down.
MFC is an encapsulation of the Win32 API, therefore imo making it much easier to use. I use MFC all the time in work for our apps, although for game dev, I do tend to go the Win32 API way and use STL. Note that you can still directly call win32 api calls from MFC apps, there is nothing wrong with doing this, it is good practice though to put the scope operator before any of the win32 api calls, example :

::GetDlgItem(IDC_EDITBOX);

::SendMessage(hWnd, WM_CLOSE, 0, 0);

Using memory variables and data exchange in mfc to point to controls is much cleaner than GetDlgItem imo, thus you could just do :

m_EditBox.SetWindowText(_T("Hello"));

instead of :

GetDlgItem(IDC_EDITBOX)->SetWindowText(_T("Hello"));

It also saves having to cast in many situations.

Putting a rotating cube on a button control would require you do to a custom owner drawn button.

If it isn't working, take a bath, have a think and try again...

This topic is closed to new replies.

Advertisement