The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: gabor on July 12, 2007, 12:43:19 PM

Title: Changing the DC of a window
Post by: gabor on July 12, 2007, 12:43:19 PM
Hi!

This might be a strange question but might a be usefull idea too. I'd like to have a windows-standard Settings dialog on a DDraw surface.
This means, I want to leave all the painting and monitoring of the controls on Win32, so that I don't have to bother with customizing their WndProcs to get them to paint themself on the surface instead of the their respective DCs.
I thought I wouldn't change anything around the WM_PAINT messages, instead I would substitute the DC of the window (the dialog) by a memory DC I create via CreateCompatibleDC on receiving WM_CREATE/WM_INITDIALOG. So far I couldn't find any API calls to let me specify a DC for a window (like SetWindowLong lets me specify a WndProc for a window).

I welcome every idea that could solve either this DC substitution or my original task that is to get the controls of a dialog paint themselves on the DDraw surface.
I have a strange feeling that I am trying to complicate an easy task again....  :bg

Thanks, and greets
Gábor
Title: Re: Changing the DC of a window
Post by: TNick on July 17, 2007, 11:40:24 AM
Hello, Gabor!

Maybe I don't understand the question properly, but "the DDraw surface" isn't a window, too? And if it is, then you should create by hand (i.e. by using CreateWindow) the controls using that handle as parent. Still, if all this is true, I am not shore if Command / Notification messages would go the right way ...

Nick
Title: Re: Changing the DC of a window
Post by: zooba on July 17, 2007, 12:07:10 PM
You could try creating the window separately, then whenever it paints you copy (BitBlt) it into DirectDraw. I don't know of any (robust) way of changing a window's device context.

Is there any reason you can't simply use a real window on top of the DirectDraw window? Using a modal dialog box will prevent the user changing back to your main application without closing it.

Cheers,

Zooba :U
Title: Re: Changing the DC of a window
Post by: gabor on July 17, 2007, 11:11:13 PM
Hi!

Thanks for the replies.
My goal is to create a method to put conventional windows controls on the directDraw surface AND make the controls work.
To put a control onto the surface can be achieved by the WM_PRINT message, but the controls won't work.
It looks like the surface covering the window's client area (where normally the controls are) doesn't allow access to the controls.

I'll investigate this further...

Greets, Gábor
Title: Re: Changing the DC of a window
Post by: gabor on July 18, 2007, 07:49:54 PM
Hi!

I thought I share my final results.
The idea comes from Ultrano and is very simple. The main window that has the direct draw surface must have the WS_CLIPCHILDREN style. The dialog I display is a modeless dialog and the child of the main window. Thus the DX surface will be clipped where the dialog is to be painted. This works in full screen mode too.

Here is a picture to illustrate what I was looking for. The black area is a ddraw7 surface, the dialog box is just an average win32 dialog created with a resource editor.
The dialog remains on the screen when I change to full-screen mode.
(http://members.chello.hu/nemeth.gabor1/fire.jpg)

Greets, Gábor
Title: Re: Changing the DC of a window
Post by: ramguru on July 18, 2007, 07:56:34 PM
This is great, gabor. Can I look at your source-code, I was thinking about simple particle system (2D preferably in GDI), something to put in about box :)
Title: Re: Changing the DC of a window
Post by: zooba on July 19, 2007, 07:51:50 AM
Ah, I see. Looks nice. Good work  :U
Title: Re: Changing the DC of a window
Post by: gabor on July 26, 2007, 06:48:19 AM
Hello friends!

I'll post the source a bit later, becouse I have to clean it up. I also want to add 2 important modifications.

Greets, Gábor