kipnis@janus.Berkeley.EDU (Gary Kipnis) (12/20/89)
Hi, is it possible to draw inside a dialog box, i.e. I want to draw a blue rectangle inside a dialog box and change its color according to dialog commands, but for some reason every time I try to draw it I get nothing, here is what I do: case WM_INITDIALOG: hDC = GetDC(hDlg); . . Rectangle(hDC, x1, y1, x2, y2); Thank you, gary
bturner@hpcvlx.cv.hp.com (Bill Turner) (12/21/89)
> Hi, is it possible to draw inside a dialog box, i.e. I want to draw a > blue rectangle inside a dialog box and change its color according to dialog > commands, but for some reason every time I try to draw it I get nothing, > here is what I do: > case WM_INITDIALOG: > hDC = GetDC(hDlg); > . > . > > Rectangle(hDC, x1, y1, x2, y2); You probably want to handle the WM_PAINT message. WM_INITDIALOG just says that all the windows related to the dialog have been created, but they haven't been displayed yet. Another possibility is to create a window class that simply draws itself with a specified color, and use that as a field in the dialog box: CONTROL text, id, YOUR_CLASS, style, x, y, w, h --Bill Turner (bturner@hp-pcd.hp.com) HP Corvallis Information Systems
papa@pollux.usc.edu (Marco Papa) (12/21/89)
In article <33325@ucbvax.BERKELEY.EDU> kipnis@janus.Berkeley.EDU (Gary Kipnis) writes: >Hi, is it possible to draw inside a dialog box, i.e. I want to draw a >blue rectangle inside a dialog box and change its color according to dialog >commands, but for some reason every time I try to draw it I get nothing, >here is what I do: >case WM_INITDIALOG: > hDC = GetDC(hDlg); > . > . > > Rectangle(hDC, x1, y1, x2, y2); > Sure. A full example is on p. 429-433 of Programming Windows, by C. Petzold. The sequence he uses goes like this: hDC = GetDC(hWnd); GetClientRect (hWnd, &rect); hBrush = CreateSolidBrish(...); hBrush = SelectObject(hDC, hBrush); Rectangle(hDC, rect.left, ...); DeleteObject(SelectObject(hDC, hBrush)); ReleaseDC(hWnd, hFC); -- Marco -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= "Xerox sues somebody for copying?" -- David Letterman -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
brent@well.UUCP (Brent Southard) (12/21/89)
In article <33325@ucbvax.BERKELEY.EDU> kipnis@janus.Berkeley.EDU (Gary Kipnis) writes: >Hi, is it possible to draw inside a dialog box, i.e. I want to draw a >blue rectangle inside a dialog box and change its color according to dialog >commands, but for some reason every time I try to draw it I get nothing, An easier way to do this might be to create a static rectangular control in the dialog editor. You could then get the control's DC via the call hDC = GetDC(GetDlgItem(hDlg, ID_CONTROL)); Then you could paint your control's window and validate it when necessary. You may need to subclass it to catch the WM_PAINT messages, too. -brent -- brent southard (313) 656-8349 | usenet: ...!well!brent ImageTech Corp (313) 362-3141 | "When frog licking is outlawed, only outlaws will lick frogs."