Use the API to implement the general dialog box under Windows!

xiaoxiao2021-03-06  48

Everyone will inevitably use the general dialog of Windows, such as opening, saving, font, color, printing, etc. These general dialogs can be loaded in the external control, but the control is also charged when packaging, so it will be troublesome and will increase the size of the installer. Through practice, the author summarizes the method of implementing these dialogs through the API, and write it out with you.

The program source code can go to my website to download: http://www.j2soft.cn/

Cui Moven

Email: cuizm@163.com

Define a class module, method: Engineering-> Add class module. code show as below:

Option expedition

Private Type Pointapi X As Long Y As Longend Type

Private Type Rect Left As Long Top As Long Right As Long Bottom As LONGEND TYPE

Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String Flags As Long nFileOffset As Integer nFileExtension As Integer LPSTRDEFEXT AS STRING LCUSTDATA AS Long LPFNHOOK AS Long LPTemplatenAme As Stringend Type

Private Type PRINTDLG lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long hdc As Long Flags As Long nFromPage As Integer nToPage As Integer nMinPage As Integer nMaxPage As Integer nCopies As Integer hInstance As Long lCustData As Long lpfnPrintHook As Long lpfnSetupHook As Long lpPrintTemplateName As String LpsetupTemplatenAme As String HprintTemplate As Long HsetupTemplate As Longend Type

Private Type CHOOSECOLOR lStructSize As Long hwndOwner As Long hInstance As Long rgbResult As Long lpCustColors As String Flags As Long lCustData As Long lpfnHook As Long lpTemplateName As StringEnd TypePrivate Type LOGFONT lfHeight As Long lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As BYTE LFUNDERLINE AS BYTE LFSTRIKEOUT AS BYTE LFSTRIKEOUT AS BYTE LFCHARSET AS BYTE LFOUTPRECISION AS BYTE LFCLIPPRECISION AS BYTE LFQUAL AS BYTE LFPITCHFAMILY AS BYTE LFFCENDFAMILY AS BYTE LFFCACENAME AS STRING * 31END TYPE

Private Type CHOOSEFONT lStructSize As Long hwndOwner As Long 'caller's window handle hdc As Long' printer DC / IC or NULL lpLogFont As Long iPointSize As Long '10 * size in points of selected font Flags As Long' enum. Type flags rgbColors As Long ' returned text color lCustData As Long 'data passed to hook fn. lpfnHook As Long' ptr. to hook function lpTemplateName As String 'custom template name hInstance As Long' instance handle of.EXE that 'contains cust. dlg. template lpszStyle As String' Return The Style Field Here 'Must Be Lf_FaceSize or Bigger NFONTTYPE AS INTEGER' SAME VALUE REPORTED TO The Enumfonts 'Call Back with the extra fonttype_' bits added missing_alignment as Integer nsizemin as long 'minimum pt size allowed & nsizemax as long' max pt size allowed if 'cf_limitsize is buyended Type

Private Type FINDREPLACE lStructSize As Long 'size of this struct 0x20 hwndOwner As Long' handle to owner's window hInstance As Long 'instance handle of.EXE that' contains cust. Dlg. Template Flags As Long 'one or more of the FR_ lpstrFindWhat As String 'ptr. to search string lpstrReplaceWith As String' ptr. to replace string wFindWhatLen As Integer 'size of find buffer wReplaceWithLen As Integer' size of replace buffer lCustData As Long 'data passed to hook fn. lpfnHook As Long' ptr. to hook fn . or NULL lpTemplateName As String 'custom template nameEnd TypePrivate Type PAGESETUPDLG lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long Flags As Long ptPaperSize As POINTAPI rtMinMargin As RECT rtMargin As RECT hInstance As Long lCustData As Long lpfnPageSetupHook As Lo NG LPFNPAGEPAINTHOOK AS Long LppagesetupTemplatenAme As String HpagesetupTemplate As LONGEND TYPE

Public Enum OFN_ALLOWMULTISELECT = & H200 OFN_CREATEPROMPT = & H2000 OFN_ENABLEHOOK OFN_ENABLETEMPLATEHANDLE = & H80 OFN_EXPLORER = & H80000 = & H20 OFN_ENABLETEMPLATE = & H40 FileFlags 'new look commdlg OFN_EXTENSIONDIFFERENT = & H400 OFN_FILEMUSTEXIST = & H1000 OFN_HIDEREADONLY = & H4 OFN_LONGNAMES = & H200000' force long names for 3.x modules OFN_NOCHANGEDIR = & H8 OFN_NODEREFERENCELINKS = & H100000 OFN_NOLONGNAMES = & H40000 'force no long names for 4.x modules OFN_NONETWORKBUTTON = & H20000 OFN_NOREADONLYRETURN = & H8000 OFN_NOTESTFILECREATE = & H10000 OFN_NOVALIDATE = & H100 OFN_OVERWRITEPROMPT = & H2 OFN_PATHMUSTEXIST = & H800 OFN_READONLY = & H1 OFN_SHAREAWARE = ​​& H4000 OFN_SHAREFALLTHROUGH = 2 OFN_SHARENOWARN = 1 OFN_SHAREWARN = 0 OFN_SHOWHELP = & H10 pd_allpages = & h0 pd_collate = & h10 pd_disableprinttofile = & h80000 PD_ENABLEPRINTHOOK = & H1000 PD_ENABLEPRINTTEMPLATE = & H4000 PD_ENABLEPRINTTEMPLATEHANDLE = & H10000 PD_ENABLESETUPHOOK = & H2000 PD_ENABLESETUPTEMPLATE = & H8000 PD_ENABLESETUPTEMPLATEHANDLE = & H20000 PD_HIDEPRINTTOFILE = & H100000 PD_NONETWORKBUTTON = & H200000 PD_NOPAGENUMS = & H8 PD_NOSELECTION = & H4 PD_NOWARNING = & H80 PD_PAGENUMS = & H2 PD_PRINTSETUP = & H40 PD_PRINTTOFILE = &

H20 PD_RETURNDC = & H100 PD_RETURNDEFAULT = & H400 PD_RETURNIC = & H200 PD_SELECTION = & H1 PD_SHOWHELP = & H800 PD_USEDEVMODECOPIES = & H40000 PD_USEDEVMODECOPIESANDCOLLATE = & H40000End EnumConst FW_NORMAL = 400Const DEFAULT_CHARSET = 1Const OUT_DEFAULT_PRECIS = 0Const CLIP_DEFAULT_PRECIS = 0Const DEFAULT_QUALITY = 0Const DEFAULT_PITCH = 0Const FF_ROMAN = 16Const GMEM_MOVEABLE = & H2Const GMEM_ZEROINIT = & H40Const CF_PRINTERFONTS = & H2Const CF_SCREENFONTS = & H1Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS) Const CF_EFFECTS = & H100 & Const CF_FORCEFONTEXIST = & H10000Const CF_INITTOLOGFONTSTRUCT = & H40 & Const CF_LIMITSIZE = & H2000 & Const REGULAR_FONTTYPE = & H400

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias ​​"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As LongPrivate Declare Function GetSaveFileName Lib "comdlg32.dll" Alias ​​"GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As LongPrivate Declare Function PrintDialog Lib "comdlg32.dll" alias "PrintDlgA" (pPrintdlg As PRINTDLG) As LongPrivate Declare Function ChooseColorDialog Lib "comdlg32.dll" alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As LongPrivate Declare Function CHOOSEFONT Lib "comdlg32.dll" alias "ChooseFontA" (pChoosefont As CHOOSEFONT) As LongPrivate Declare Function FindText Lib "comdlg32.dll" Alias ​​"FindTextA" (pFindreplace As FINDREPLACE) As LongPrivate Declare Function PAGESETUPDLG Lib "comdlg32.dll" Alias ​​"PageSetupDlgA" (pPagesetupdlg As PAGESETUPDLG) As LongPrivate Declare Function ReplaceText Lib "comdlg32.dll" ALIAS "ReplaceTexta" (PFINDREPLACE AS FINDREPLACE) AS LongPrivate Declare Function GlobalLoc LIB "Kernel32" (Byval Wflags As Long, B yVal dwBytes As Long) As LongPrivate Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As LongPrivate Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As LongPrivate Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As longprivate declare sub copymemory lib "kernel32" Alias ​​"RTLmoveMemory" (HPVDest As Any, HPVSource As Any, BYVAL CBCOPY AS Long)

'Fileopen class member variable ============================================= ======== Private m_lngHwnd As LongPrivate m_lngInstance As LongPrivate m_strFileName As StringPrivate m_strFileTitle As StringPrivate m_strInitDir As StringPrivate m_strDialogTitle As StringPrivate m_strFilter As StringPrivate m_lngFlags As Long 'Print class member variables ============ =========================================================================================00 Longprivate m_lngmaxpage as longprivate m_lngminpage as long

'Print class member variable ============================================= ======== Private m_lngcolor as long

'Font class member variable ============================================= ======== Private m_strFontName As StringPrivate m_lngFontColor As LongPrivate m_lngFontSize As LongPrivate m_lngCharSet As LongPrivate m_bolItalic As BooleanPrivate m_bolStrikeOut As BooleanPrivate m_bolUnderline As BooleanPrivate m_bolBlob As Boolean 'PageSetup class member variables ============ =========================================================================================================================00 Longprivate M_Lngmargintop As LongPrivate M_Lngmarginright As LongPrivate M_Lngmarginbottom As Long

'FileOpen class implementation =============================================== =========== Public Function ShowOpen () As Boolean Dim fName As String, sName As String, OfName As OPENFILENAME OfName.lStructSize = Len (OfName) OfName.hwndOwner = m_lngHwnd OfName.hInstance = m_lngInstance OfName. lpstrInitialDir = m_strInitDir OfName.lpstrFilter = m_strFilter OfName.lpstrFile = Space (255) & Chr (0) OfName.nMaxFile = 256 OfName.lpstrFileTitle = Space (255) & Chr (0) OfName.nMaxFileTitle = 256 OfName.lpstrTitle = m_strDialogTitle OfName .Flags = m_lngflags if getopenfilename (ofname) THEN M_STRFILENAME = $ OFNAME.LPSTRFILE M_STRFILETITETITLE = $ = true else showopen = false end ifend function

Public property get filter () AS string filter = m_strfilterend property

Public Property Let Filter (Byval VNewValue As String) M_Strfilter = Replace (VNewValue, "|", CHR (0)) & chr (0) End Property

Public property get flags () as fileflags flags = m_lngflagsend property

Public property Let Flags (Byval VNewValue As Fileflags) M_Lngflags = VNewValueEnd Property

Public property Get Dialogtitle () AS String Dialogtitle = M_STRDIALOGTILEND PROPERTY

Public Property Let Dialogtitle (Byval VNewValue As String) M_STRDIALOGTILE = VNewValueEnd Property

Public property get initdir () AS string initdir = m_strinitdirend propertypublic Property let initdir (byval vnewvalue as string) m_strinitdir = vnewvalueend property

Public Property Get FileTitle () AS String FileTitle = M_STRFileTitleend Property

Public property Let FileTitle (Byval VNewValue As String) m_strfiletitle = VNewValueEnd Property

Public property get filename () AS string filename = m_strfilenameend property

Public property Let FileName (Byval VNewValue As String) m_strfilename = VNewValueEnd Property

Public property get hwnd () as long hwnd = m_lnghwndend property

Public property let hwnd (Byval VNewValue As long) m_lnghwnd = VNewValueEnd property

Public property get instance () as long instance = m_LnginstanceEnd Property

Public Property Let Instance (Byval VNewValue As Long M_Lnginstance = VNewValueEnd Property

'FileSave class realization ============================================== =========== Public Function ShowSave () As Boolean Dim fName As String, sName As String, OfName As OPENFILENAME OfName.lStructSize = Len (OfName) OfName.hwndOwner = m_lngHwnd OfName.hInstance = m_lngInstance OfName. lpstrInitialDir = m_strInitDir OfName.lpstrFilter = m_strFilter OfName.lpstrFile = Space (255) & Chr (0) OfName.nMaxFile = 256 OfName.lpstrFileTitle = Space (255) & Chr (0) OfName.nMaxFileTitle = 256 OfName.lpstrTitle = m_strDialogTitle OfName .Flags = m_lngflags if getSavefilename (OFNAME) THEN M_STRFILENAME = $ OFNAME.LPSTRFILE M_STRFILETILETIL = ofname.lpstrfileTitleshowsave = true else showsave = false end ifend function

'Print class realizes ============================================== =========== Public Function ShowPrint () As Boolean Dim PrtDlg As PRINTDLG PrtDlg.lStructSize = Len (PrtDlg) PrtDlg.hwndOwner = m_lngHwnd PrtDlg.hInstance = m_lngInstance PrtDlg.nCopies = m_lngCopies PrtDlg.nFromPage = m_lngFromPage PrtDlg.nMaxPage = m_lngMaxPage PrtDlg.nMinPage = m_lngMinPage PrtDlg.nToPage = m_lngToPage PrtDlg.Flags = m_lngFlags If PrintDialog (PrtDlg) Then m_lngCopies = PrtDlg.nCopies m_lngFromPage = PrtDlg.nFromPage m_lngMaxPage = PrtDlg.nMaxPage m_lngMinPage = PrtDlg.nMinPage m_lngToPage = PrtDlg. NTOPAGESHOWPRINT = True else showprint = false end iFend function

Public property Get Copies () as long copies = m_lngcopiesend property

Public Property Let Copies (Byval VNewValue As Long M_Lngcopies = VNewValueEnd Property

Public property get fromPage () as long home = m_lngfromPagend Property

Public Property Let Home (Byval VNewValue As LONG) M_LNGFROMPAGE = VNewValueEnd Property

Public property get top topage () as long topage = m_lngtopageend property

Public Property Let Topage (Byval VNewValue As Long) M_Lngtopage = VNewValueEnd Property

Public property get maxpage () as long maxpage = m_lngmaxpagend property

Public Property Let MaxPage (Byval VNewValue As Long) M_Lngmaxpage = VNewValueEnd Property

Public property get minpage () as long minpage = m_lngminPagend property = VNEWVALUEEND PROPERTYPA

'ChoosecolorDialog class realization =============================================== =========== Public Function showcolor () AS Boolean Dim I as INTEGER DIM CLRDLG As Choosecolor, CustomColors () AS BYTE

Redim CustomColors (0 to 63) AS Byte for i = lbound (Customcolors) To Ubound (Customcolors) Customcolors (i) = 0 Next I

ClrDlg.lStructSize = Len (ClrDlg) ClrDlg.hwndOwner = m_lngHwnd ClrDlg.hInstance = m_lngInstance ClrDlg.lpCustColors = StrConv (CustomColors, vbUnicode) If ChooseColorDialog (ClrDlg) Then m_lngColor = ClrDlg.rgbResult CustomColors = StrConv (ClrDlg.lpCustColors, vbFromUnicode)

Showcolor = true else showcolor = false end ifend function

Public property Get Color () As long color = m_lngcolorend property

Public Property Let Color (Byval VNewValue As Long) M_LngColor = VNewValueEnd Property

'Font category =============================================== ========== p Boolean DIM CF AS Choosefont, LFONT AS LOGFONT, HMEM As Long, Pmem as Long Dim FontName As String, RetVal As Long LFont.Lfheight = 0 'DETERMINE DEFAULT height lfont.lfWidth = 0 'determine default width lfont.lfEscapement = 0' angle between baseline and escapement vector lfont.lfOrientation = 0 'angle between baseline and orientation vector lfont.lfWeight = FW_NORMAL' normal weight Ie Not bold lfont.lfCharSet = DEFAULT_CHARSET 'use default character set lfont.lfOutPrecision = OUT_DEFAULT_PRECIS' default precision mapping lfont.lfClipPrecision = CLIP_DEFAULT_PRECIS 'default clipping precision lfont.lfQuality = DEFAULT_QUALITY' default quality setting lfont.lfPitchAndFamily = DEFAULT_PITCH Or FF_ROMAN 'default pitch, proportional with serifs lfont.lfFaceName = "Times New Roman" & vbnullchar 'String Must Be Null-Terminated' Create the memory block which will act as the LOGFONT structure buffer. HMem = GlobalAlloc (GMEM_MOVEABLE Or GMEM_ZEROINIT, Len (lfont)) pMem = GlobalLock (hMem) 'lock and get pointer CopyMemory ByVal pMem, lfont, Len (lfont)' copy structure's Contents Into Block 'Initialize Dialog Box: Screen and Printer Fonts, Point Size Between 10 and 72. Cf.lstructSize =

Len (cf) 'size of structure cf.hwndOwner = m_lngHwnd' window Form1 is opening this dialog box cf.hdc = Printer.hdc 'device context of default printer (using VB's mechanism) cf.lpLogFont = pMem' pointer to LOGFONT memory block buffer cf.iPointSize = 120 '12 point font (in units of 1/10 point) cf.Flags = CF_BOTH Or CF_EFFECTS Or CF_FORCEFONTEXIST Or CF_INITTOLOGFONTSTRUCT Or CF_LIMITSIZE cf.rgbColors = RGB (0, 0, 0)' black cf.nFontType = REGULAR_FONTTYPE 'regular font type Ie Not bold or anything cf.nSizeMin = 1' minimum point size cf.nSizeMax = 72 'maximum point size' Now, call the function. If successful, copy the LOGFONT structure back into the structure 'and then print out the attributes we mentioned earlier that the user selected. If CHOOSEFONT (cf) Then 'success CopyMemory lfont, ByVal pMem, Len (lfont)' copy memory back 'Now make the fixed-length string holding the font name into a "normal" String. m_strFontName = Left (lfont.lfFaceName, InStr (lfont.lfFaceName, vbNullChar) - 1) m_lngFontColor = cf.rgbColors m_lngFontSize = cf.iPointSize / 10 m_lngCharSet = lfont.lfCharSet m_bolItalic = lfont.lfItalic = 255 m_bolStrikeOut = lfont.lfStrikeOut = 1 M_BolunderLine = LFONT.LFunderLine = 1 m_bolblob = lfont.lfweight> = 700 showfont = true else showfont = false endiff = fallocate the memory block wE CREATED EARLIER. Note That Must '

be done whether the function succeeded or not. retval = GlobalUnlock (hMem) 'destroy pointer, unlock block retval = GlobalFree (hMem)' free the allocated memoryEnd FunctionPublic Property Get FontName () As String FontName = m_strFontNameEnd Property

Public Property Let FontName (Byval VNewValue As String) m_strfontname = VNewValueEnd Property

Public property get fontcolor () as long fontcolor = m_lngfontcolorend property

Public Property Let Fontcolor (Byval VNewValue As Long M_LngfontColor = VNewValueEnd Property

Public property get fontsize () as long fontsize = m_lngfontsizeend print

Public Property Let Fontsize (Byval VNewValue As Long M_Lngfontsize = VNewValueEnd Property

Public property get charset () as long charset = m_lngcharstend print

Public property Let Charset (Byval VNewValue As Long) M_Lngcharset = VNewValueEnd Property

Public property get italic () as boolean italic = m_bolitalicnd property

Public property let italic (byval vnewvalue as boolean) m_bolitalic = vnewvalueend property

Public property get strikeout () as boolean strikeout = m_bolstrikeoutend protety

Public property let strikeout (byval vnewvalue as boolean) m_bolstrikeout = vnewvalueend property

Public property get underline () as boolean underline = m_bolunderlineend property

Public property let underline (byval vnewvalue as boolean) m_bolunderline = vnewvalueend property

Public property get fontblob () as boolean fontblob = m_bolblobend property

Public property let fontblob (byval vnewvalue as boolean) m_bolblob = vnewvalueend property

'Find class realization ============================================== =========== Public Function ShowFind () As Boolean Dim lFind As FINDREPLACElFind.lStructSize = Len (lFind) lFind.hwndOwner = m_lngHwnd lFind.hInstance = m_lngInstance lFind.wFindWhatLen = 255 'If FindText (lFind) Then 'showfind = true' else 'showfind = false' end ifend function

'Replace class implementation ============================================== =========== Public function showreplace () AS Boolean Dim LFIND AS FINDREPLACE

lFind.lStructSize = Len (lFind) lFind.hwndOwner = m_lngHwnd lFind.hInstance = m_lngInstance lFind.wFindWhatLen = 255 If ReplaceText (lFind) Then ShowReplace = True Else ShowReplace = False End IfEnd Function

'Replace class implementation ============================================== =========== Public Function showpagesetup () As Boolean Dim Lpagesetup as PagesetUpdlg

lPageSetup.lStructSize = Len (lPageSetup) lPageSetup.hwndOwner = m_lngHwnd lPageSetup.hInstance = m_lngInstanceIf PAGESETUPDLG (lPageSetup) Then m_lngPaperWidth = lPageSetup.ptPaperSize.x m_lngPaperHeight = lPageSetup.ptPaperSize.y m_lngMarginLeft = lPageSetup.rtMargin.Left m_lngMarginTop = lPageSetup.rtMargin. Top M_Lngmarginright = lpagesetup.rtmargin.right m_lngmarginbottom = lpagesetup.rtmargin.bottom showpagesetup = true else showpagesetup = false end ifend functionion

Public property get paperWidth () as long paperWidth = m_lngpaperwidthend property

Public Property Let PaperWidth (Byval VNewValue As Long) M_LngpaperWidth = VNewValueEnd Property

Public property Get PaperHeight () as long paperHeight = m_LngpaperHeightens Property

Public Property Let PaperHeight (Byval VNewValue As Long) M_LngpaperHeight = VNewValueEnd Property

Public property get marginleft () as long marginleft = m_lngmarginleftend product

Public property let marginleft (Byval VNewValue as long) m_lngmarginleft = VNewValueEnd Property

Public property get margintop () as long margintop = m_lngmargintopend Property

Public property let margintop (Byval VNewValue as long) m_lngmargintop = VNewValueEnd Property

Public property get marginright () as long marginright = m_lngmarginrightend print

Public Property Let Marginright (Byval VNewValue As Long M_LngMarginright = VNewValueEnd Property

Public property get marginbottom () as long marginbottom = m_lngmarginbottomend property

Public property let marginbottom (Byval VNewValue As Long) M_LngMarginbottom = VNewValueEnd property Adds six buttons in the window, used to implement calls these general dialogs, the code is as follows:

Option expedition

DIM DLG AS CDIALOG

Private Sub Command1_Click () dlg.Hwnd = Hwnd dlg.Filter = ". WORD documents | * .doc; * html" dlg.Flags = OFN_ALLOWMULTISELECT OFN_EXPLORER OFN_PATHMUSTEXIST dlg.InitDir = "D: /" dlg.DialogTitle = "(豪) Open the document ... "if dlg.showopen kilbox dlg.filename msgbox dlg.filetitle end ifend sub

Private Sub Command2_Click () dlg.Hwnd = Hwnd dlg.Filter = ". WORD documents | * .doc; * html" dlg.Flags = OFN_ALLOWMULTISELECT OFN_EXPLORER OFN_PATHMUSTEXIST dlg.InitDir = "D: /" dlg.DialogTitle = "(豪) Save Documents ... "if Dlg.Showsave The Msgbox Dlg.FileName Msgbox Dlg.FileTitle End IFEnd Sub

Private Sub Command3_Click () dlg.Hwnd = Hwnd dlg.Flags = PD_SELECTION PD_USEDEVMODECOPIES If dlg.ShowPrint Then MsgBox "Copies:" & dlg.Copies & vbCrLf & _ "FromPage:" & dlg.FromPage & vbCrLf & _ "ToPage: "& DLG.TOPAGE & VBCRLF & _MAXPAGE:" & DLG.MAXPAGE & VBCRLF & _ "MINPAGE:" & DLG.MINPAGE END IFEND SUB

PRIVATE SUB Command4_Click () DLG.HWND = HWND IF DLG.SHOWCOLOR THEN BACKCOLOR = DLG.COLOR END IFEND SUB

Private Sub Command5_Click () dlg.Hwnd = Hwnd If dlg.ShowFont Then MsgBox "FontName:" & dlg.FontName & vbCrLf & _ "FontColor:" & dlg.FontColor & vbCrLf & _ "FontSize:" & dlg.FontSize & vbCrLf & _ "& DLG.CHARSET & VBCRLF & _" Italic: "& Dlg.italic & VBCRLF & _" strikeout: "& DLG.Strikeout & Vbcrlf & _" underline: "& Dlg.underline & Vbcrf & _ "BLOB:" & DLG.FONTBLOB END IFEND SUBPRIVATE SUB Command6_click () DLG.HWND = HWND IF DLG.SHOWFIND THEN End IFEND SUB

Private Sub Command7_Click () dlg.Hwnd = Hwnd If dlg.ShowPageSetup Then MsgBox "PageWeight:" & dlg.PaperWidth & vbCrLf & _ "PageHeight:" & dlg.PaperHeight & vbCrLf & _ "MarginLeft:" & dlg.MarginLeft & vbCrLf & _ "Margintop:" & Dlg.Margintop & Vbrlf & _ "Marginright:" & DLG.Marginright & VbRLF & _ "Marginbottom:" & DLG.Marginbottom end iFend Sub

Private sub fascist8_click () dlg.hwnd = hWnd if Dlg.ShowReplace Then End IFEND SUB

Private sub form_load () set dlg = new cDialogend SUB

Private Sub Form_Queryunload (Cancel AS Integer, UnloadMode As Integer) Set DLG = Nothingend Sub

As long as you add this in the project, you can use it, you can use the external controls, save some controls when installing, and set the space! !

转载请注明原文地址:https://www.9cbs.com/read-116102.html

New Post(0)