Beispiel #1
0
        //-------------------------------------------------
        // We need to tell the Win32 side of things to create an empty
        // dialog. The best way to do this is to give it a blank dialog template.
        //

        /// <summary>
        /// Get a pointer to template object
        /// </summary>
        /// <param name="cX">Page width</param>
        /// <param name="cY">Page Heitgh</param>
        /// <returns></returns>
        private IntPtr GetDialogTemplate(short cX, short cY)
        {
            // If we're already created a template, don't bother doing it again
            if (dlgTemplate != IntPtr.Zero)
            {
                return(dlgTemplate);
            }

            DLGTEMPLATE dlg = new DLGTEMPLATE();

            dlg.cx = cX;
            dlg.cy = cY;

            // Put in the standard font
            dlg.style         = DS.SETFONT;
            dlg.fontPointSize = 8;
            byte[] bFontFace = StringToByteArray("MS Shell Dlg");

            int nSize = Marshal.SizeOf(typeof(DLGTEMPLATE));

            dlgTemplate = Marshal.AllocHGlobal(nSize + bFontFace.Length);
            Marshal.StructureToPtr(dlg, dlgTemplate, false);

            // Now copy the string into the IntPtr
            Marshal.Copy(bFontFace, 0, (IntPtr)((Int64)dlgTemplate + nSize), bFontFace.Length);

            return(dlgTemplate);
        }
Beispiel #2
0
        //-------------------------------------------------
        // We need to tell the Win32 side of things to create an empty
        // dialog. The best way to do this is to give it a blank dialog template.
        //
        /// <summary>
        /// Get a pointer to template object
        /// </summary>
        /// <param name="cX">Page width</param>
        /// <param name="cY">Page Heitgh</param>
        /// <returns></returns>
        private IntPtr GetDialogTemplate(short cX, short cY)
        {
            // If we're already created a template, don't bother doing it again
            if (dlgTemplate != IntPtr.Zero) return dlgTemplate;

            DLGTEMPLATE dlg = new DLGTEMPLATE();

            dlg.cx = cX;
            dlg.cy = cY;

            // Put in the standard font
            dlg.style = DS.SETFONT;
            dlg.fontPointSize = 8;
            byte[] bFontFace = StringToByteArray("MS Shell Dlg");

            int nSize = Marshal.SizeOf(typeof(DLGTEMPLATE));
            dlgTemplate = Marshal.AllocHGlobal(nSize + bFontFace.Length);
            Marshal.StructureToPtr(dlg, dlgTemplate, false);

            // Now copy the string into the IntPtr
            Marshal.Copy(bFontFace, 0, (IntPtr)((Int64)dlgTemplate + nSize), bFontFace.Length);

            return dlgTemplate;
        }