News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Changing the DC of a window

Started by gabor, July 12, 2007, 12:43:19 PM

Previous topic - Next topic

gabor

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

TNick

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

zooba

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

gabor

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

gabor

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.


Greets, Gábor

ramguru

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 :)

zooba

Ah, I see. Looks nice. Good work  :U

gabor

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