Graphics in MDI Forms

Graphics in MDI Forms

To use a bitmap or other graphics in the client space of MDI forms,the only trick is getting the hWnd for that window so that you can useGDI functions on it. The key is understanding that the client space isthe first child (in Windows-speak, not MDI-speak) of the MDI form.
Get the handle via the GetWindow API call with the GW_CHILD constant.You create a MDIForm_Paint event with a subclassing control such as MsgHookfrom Visual Basic How To, Second Edition by Zane Thomas, RobertArnson, and Mitchell Waite (Waite Group Press). When the WM_PAINT messageis intercepted, call your routines to BitBlt a BMP or draw other graphicsin the client space. When WM_ERASEBKGND message is intercepted, preventit from being passed on to VB (all subclassing controls use slightly differentterminology for this). If you’re using MsgHook, put the statements belowin the MDI form’s Form_Load event. To see this and other MDI techniquesin action, download MDIDMO.ZIP from either the MSBASIC or VBPJ forums onCompuServe and try out the demonstrations.

 MsgHook1.HwndHook = (GetWindow(Me.hWnd, GW_CHILD)) MsgHook1.Message(WM_PAINT) = True MsgHook1.Message(WM_ERASEBKGND) = True 
See also  5 Tips for Working With an Onsite Interpreter

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist