--------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00001 Date: 09/04/97 From: BUCKY CARR Time: 01:36pm \/To: EILEEN LOUISE (Read 5 times) Subj: String Help! BC> have the science down cold [well, most of the time]). EL> isn't that _out_ cold? ....ducking and giggling. Uhhhh, yeah, actually. Good catch. [what you said] EL> in this case i'm subbing for a software house. that is also what i EL> like best. i do not have a structure large enough to properly finesse EL> certain aspects of client handling :-) [what it means in English to me] "taking phone calls selling software... are of small body height/weight and farm out the bouncer work." BC> For you, perhaps. I don't need external pressure, though. EL> it keeps me from getting bored. Thumb screws, anyone? I ordered VB5 today. Got such a good deal on it, ordered VC++5, too. Guess I really need to bite the bullet and learn it as well. One of my previous objections to C (and what made ASM harder than it needed to be) was the lack of a development environment for C. Is the VC++ programming done in an environment such as VB5's? --- PPoint 2.00 * Origin: Vanishing Point 7198460140 Trinidad CO (1:15/7.1) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00002 Date: 09/05/97 From: HERMAN BURGERS Time: 08:12pm \/To: RANDY BIRCH (Read 5 times) Subj: Visual BASIC 5 Entry spe RANDY BIRCH wrote on 02 Sep 1997 at 18:00 to HERMAN BURGERS: RB> {Message date: 09-01-97 20:09} RB> {From: HERMAN BURGERS to ALL} RB> {Subject: Visual BASIC 5 Entry spe} HB>>So far I have seen all kinds of spec's on Visual BASIC Pro, but have been HB>>unable to get anyone to supply me with the details on VisBAS 5 Learning/E HB>>Is there anybody who has a fact file on that? HB>I am especially interested in accessing a local database using VisBAS 5, HB>similar to what I have already done in VB. RB> You will require the Pro version at least to do database work. Thanks for your reaction Randy! Unfortunately I use FidoNet, and can only E-mail on Internet, so no MS site-seeing for me.:-( But can you comment on this exerpt from a catalog I got, (and I do not know where the shops original text came from) "Pc CD-ROM Microsoft VisualBasic 5.0 Learning Edition (486/8-16MBram/25-205MB/VGA/W95,NT) Complete development environment and self-paced CD-ROM tutorial. Contains more than 20 pre-built ActiveX controls, database engine, application wizard, extensive online documentation, IntelliSense. Includes Learn Visual Basic Now CD-ROM tutorial " Does that database engine mean that there is a DataControl to put in a form? And is that database thing the 'new and improved' Access or XBASE compatible or what? The real information so far is rather limited. RB> . Randy Birch, MVP, Visual Basic RB> (1:250/350) Regards/Groeten, Herman in Barneveld, Holland herman.burgers@p2262.f804.n280.z2.elcom.org --- FMail 1.02 * Origin: Trains & Planes and other things DIGITAL (2:280/804.2262) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00003 Date: 09/05/97 From: RANDY BIRCH Time: 02:32pm \/To: STEVE WARD (Read 5 times) Subj: Printing {Message date: 09-04-97 15:57} {From: STEVE WARD to RANDY BIRCH} {Subject: Printing} > I've been working on a simple text editor and cannot get the >program to print. Can you see any reason why the following code doesn't >work? The Dialog box comes up fine, but when I OK the print job the >dialog box closes and nothing else happens. >Private Sub mnuPrint_Click() >CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums >If RichTextBox1.SelLength = 0 Then > CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages >Else > CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection >End If >CommonDialog1.ShowPrinter >RichTextBox1.SelPrint CommonDialog1.hDC >End Sub I'm not a RTF expert by any means, but if you were to add the following two lines after the Selprint statement: Print CommonDialog1.hDC Print Printer.hDC ... you'd see these are different. The help file states that selprint method takes the hDC of the printer, as in: RichTextBox1.SelPrint Printer.hDC However, I tried both your code and the line above under VB5, and both printed out to my laserjet6 with no problems. I'm sending (in another message) a Knowledge Base file for VB4-32 (which also works under VB5) that has a nice routine for printing RTF. . Randy Birch, MVP, Visual Basic Toronto, Ontario, Canada email: randy_birch@msn.com VBnet, the Developers Resource Centre http://home.sprynet.com/sprynet/rasanen --- * WR 1.31 # 323 * Windows error #2346: Only God knows what went wrong * Origin: Bits & Bytes BBS - Toronto, Ont. 416- 532-1784 1:25 (1:250/350) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00004 Date: 09/05/97 From: RANDY BIRCH Time: 02:33pm \/To: STEVE WARD (Read 5 times) Subj: Printing {Message date: 09-04-97 15:57} {From: STEVE WARD to RANDY BIRCH} {Subject: Printing} >Thanks in advance for any help. >Steve Ward How to Set Up the RichTextBox Control for WYSIWYG Printing Article ID: Q146022 1.Start a new project in the 32-bit edition (Form1 is created by default. 2.Put a command button and a RichTextBox control on Form1. 3.Add the following code to Form1: Option Explicit Private Sub Form_Load() Dim LineWidth As Long ' Initialize Form and Command button Me.Caption = "Rich Text Box WYSIWYG Printing Example" Command1.Move 10, 10, 600, 380 Command1.Caption = "&Print" ' Set the font of the RTF to a TrueType font for best results RichTextBox1.SelFontName = "Arial" RichTextBox1.SelFontSize = 10 ' Tell the RTF to base it's display off of the printer LineWidth = WYSIWYG_RTF(RichTextBox1, 1440, 1440) '1440 Twips=1 Inch ' Set the form width to match the line width Me.Width = LineWidth + 200 End Sub Private Sub Form_Resize() ' Position the RTF on form RichTextBox1.Move 100, 500, Me.ScaleWidth - 200, Me.ScaleHeight - 600 End Sub Private Sub Command1_Click() ' Print the contents of the RichTextBox with a one inch margin PrintRTF RichTextBox1, 1440, 1440, 1440, 1440 ' 1440 Twips = 1 Inch End Sub 4.Insert a new standard module into the project (Module1.bas by default.) 5.Add the following code to Module1: Option Explicit Private Type Rect Left As Long Top As Long Right As Long Bottom As Long End Type Private Type CharRange cpMin As Long ' First character of range (0 for start of doc) cpMax As Long ' Last character of range (-1 for end of doc) End Type Private Type FormatRange hdc As Long ' Actual DC to draw on hdcTarget As Long ' Target DC for determining text formatting rc As Rect ' Region of the DC to draw to (in twips) rcPage As Rect ' Region of the entire DC (page size) (in twips) chrg As CharRange ' Range of text to draw (see above declaration) End Type Private Const WM_USER As Long = &H400 Private Const EM_FORMATRANGE As Long = WM_USER + 57 Private Const EM_SETTARGETDEVICE As Long = WM_USER + 72 Private Const PHYSICALOFFSETX As Long = 112 Private Const PHYSICALOFFSETY As Long = 113 Private Declare Function GetDeviceCaps Lib "gdi32" ( _ ByVal hdc As Long, ByVal nIndex As Long) As Long Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" _ (ByVal hWnd As Long, ByVal msg As Long, ByVal wp As Long, _ lp As Any) As Long Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" _ (ByVal lpDriverName As String, ByVal lpDeviceName As String, _ ByVal lpOutput As Long, ByVal lpInitData As Long) As Long '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' WYSIWYG_RTF - Sets an RTF control to display itself the same as it ' would print on the default printer ' ' RTF - A RichTextBox control to set for WYSIWYG display. ' ' LeftMarginWidth - Width of desired left margin in twips ' ' RightMarginWidth - Width of desired right margin in twips ' ' Returns - The length of a line on the printer in twips ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function WYSIWYG_RTF(RTF As RichTextBox, LeftMarginWidth As Long, _ RightMarginWidth As Long) As Long Dim LeftOffset As Long, LeftMargin As Long, RightMargin As Long Dim LineWidth As Long Dim PrinterhDC As Long Dim r As Long ' Start a print job to initialize printer object Printer.Print Space(1) Printer.ScaleMode = vbTwips ' Get the offset to the printable area on the page in twips LeftOffset = Printer.ScaleX(GetDeviceCaps(Printer.hdc, _ PHYSICALOFFSETX), vbPixels, vbTwips) ' Calculate the Left, and Right margins LeftMargin = LeftMarginWidth - LeftOffset RightMargin = (Printer.Width - RightMarginWidth) - LeftOffset ' Calculate the line width LineWidth = RightMargin - LeftMargin ' Create an hDC on the Printer pointed to by the Printer object ' This DC needs to remain for the RTF to keep up the WYSIWYG display PrinterhDC = CreateDC(Printer.DriverName, Printer.DeviceName, 0, 0) ' Tell the RTF to base it's display off of the printer ' at the desired line width r = SendMessage(RTF.hWnd, EM_SETTARGETDEVICE, PrinterhDC, _ ByVal LineWidth) ' Abort the temporary print job used to get printer info Printer.KillDoc WYSIWYG_RTF = LineWidth End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' PrintRTF - Prints the contents of a RichTextBox control using the ' provided margins ' ' RTF - A RichTextBox control to print ' ' LeftMarginWidth - Width of desired left margin in twips ' ' TopMarginHeight - Height of desired top margin in twips ' ' RightMarginWidth - Width of desired right margin in twips ' ' BottomMarginHeight - Height of desired bottom margin in twips ' ' Notes - If you are also using WYSIWYG_RTF() on the provided RTF ' parameter you should specify the same LeftMarginWidth and ' RightMarginWidth that you used to call WYSIWYG_RTF() '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub PrintRTF(RTF As RichTextBox, LeftMarginWidth As Long, _ TopMarginHeight, RightMarginWidth, BottomMarginHeight) Dim LeftOffset As Long, TopOffset As Long Dim LeftMargin As Long, TopMargin As Long Dim RightMargin As Long, BottomMargin As Long Dim fr As FormatRange Dim rcDrawTo As Rect Dim rcPage As Rect Dim TextLength As Long Dim NextCharPosition As Long Dim r As Long ' Start a print job to get a valid Printer.hDC Printer.Print Space(1) Printer.ScaleMode = vbTwips ' Get the offsett to the printable area on the page in twips LeftOffset = Printer.ScaleX(GetDeviceCaps(Printer.hdc, _ PHYSICALOFFSETX), vbPixels, vbTwips) TopOffset = Printer.ScaleY(GetDeviceCaps(Printer.hdc, _ PHYSICALOFFSETY), vbPixels, vbTwips) ' Calculate the Left, Top, Right, and Bottom margins LeftMargin = LeftMarginWidth - LeftOffset TopMargin = TopMarginHeight - TopOffset RightMargin = (Printer.Width - RightMarginWidth) - LeftOffset BottomMargin = (Printer.Height - BottomMarginHeight) - TopOffset ' Set printable area rect rcPage.Left = 0 rcPage.Top = 0 rcPage.Right = Printer.ScaleWidth rcPage.Bottom = Printer.ScaleHeight ' Set rect in which to print (relative to printable area) rcDrawTo.Left = LeftMargin rcDrawTo.Top = TopMargin rcDrawTo.Right = RightMargin rcDrawTo.Bottom = BottomMargin ' Set up the print instructions fr.hdc = Printer.hdc ' Use the same DC for measuring and rendering fr.hdcTarget = Printer.hdc ' Point at printer hDC fr.rc = rcDrawTo ' Indicate the area on page to draw to fr.rcPage = rcPage ' Indicate entire size of page fr.chrg.cpMin = 0 ' Indicate start of text through fr.chrg.cpMax = -1 ' end of the text ' Get length of text in RTF TextLength = Len(RTF.Text) ' Loop printing each page until done Do ' Print the page by sending EM_FORMATRANGE message NextCharPosition = SendMessage(RTF.hWnd, EM_FORMATRANGE, True, fr) If NextCharPosition >= TextLength Then Exit Do 'If done then exit fr.chrg.cpMin = NextCharPosition ' Starting position for next page Printer.NewPage ' Move on to next page Printer.Print Space(1) ' Re-initialize hDC fr.hDC = Printer.hDC fr.hDCTarget = Printer.hDC Loop ' Commit the print job Printer.EndDoc ' Allow the RTF to free up memory r = SendMessage(RTF.hWnd, EM_FORMATRANGE, False, ByVal CLng(0)) End Sub 6.Save the project. 7.Run the project. 8.Enter or paste some text into the RichTextBox. 9.Press the Print command button. The printed output should word-wrap at the same locations as displayed on the screen. Also, the output should be printed with the specified one-inch margin all around. . Randy Birch, MVP, Visual Basic Toronto, Ontario, Canada email: randy_birch@msn.com VBnet, the Developers Resource Centre http://home.sprynet.com/sprynet/rasanen --- * WR 1.31 # 323 * I am Koresh of Borg. Prepare to be incinerated. * Origin: Bits & Bytes BBS - Toronto, Ont. 416- 532-1784 1:25 (1:250/350) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00005 Date: 09/05/97 From: RANDY BIRCH Time: 02:44pm \/To: BRIAN FIELDS (Read 5 times) Subj: Problem in VB/DOS (Overf {Message date: 09-04-97 13:47} {From: BRIAN FIELDS to RANDY BIRCH} {Subject: Problem in VB/DOS (Overf} RB> VB, in calculating the results to assign to Locat&, uses a temporary RB> variable. In doing so, it uses a temp of the same data type as the RB> data types in the expression to compute. In you case, because at le > To me, that seems foolish... Why select on the basis of the variables >INSIDE the equation, when it would be much easier (and much more logical) >to select a data type equal to the result type. Ah well... I'll try your >fix... It may be foolish, but its The Law. VB creates a temp variable to hold the calculations. Since it has to base this on something, it uses the 'largest' type in the expression to be calculated. Only once the temp is calculated does it attempt to assign the result to the variable you declared to hold it. Therefore, you have to assure that the temp variable is large enough to hold the result of the calculations. This is only done by assuring that one of the variables in the equasion that*will*be*first*calculated sets this run-time temp variable size. I guarantee it will work, assuming that the array holds sufficient entries. Since in your expression: Locat& = ((Index% - 1) * MaxRecs) + 1 the first calculation made is (Index% - 1), you must set Index to long: Locat& = ((Index& - 1) * MaxRecs) + 1 . Randy Birch, MVP, Visual Basic Toronto, Ontario, Canada email: randy_birch@msn.com VBnet, the Developers Resource Centre http://home.sprynet.com/sprynet/rasanen --- * WR 1.31 # 323 * It isn't whether you win or lose but how you place the bl * Origin: Bits & Bytes BBS - Toronto, Ont. 416- 532-1784 1:25 (1:250/350) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00006 Date: 09/05/97 From: RANDY BIRCH Time: 02:45pm \/To: BRIAN FIELDS (Read 5 times) Subj: Problem in VB/DOS (Overf {Message date: 09-05-97 01:07} {From: BRIAN FIELDS to MIKE SCIROCCO} {Subject: Problem in VB/DOS (Overf} > Unfortunately, the program is too large to run in the programming >environment. I tried, and I get an "Out of memory" error. The program is NOT too large; that variable to hold the resulting value in the calculation is too small. Big difference. . Randy Birch, MVP, Visual Basic Toronto, Ontario, Canada email: randy_birch@msn.com VBnet, the Developers Resource Centre http://home.sprynet.com/sprynet/rasanen --- * WR 1.31 # 323 * Are dog biscuits made from collie flour? * Origin: Bits & Bytes BBS - Toronto, Ont. 416- 532-1784 1:25 (1:250/350) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00007 Date: 09/06/97 From: GARY SONNENBERG Time: 02:25am \/To: RANDY BIRCH (Read 5 times) Subj: ICU Hi Randy, Long time no see. Since I've been going to school full time (since June) I don't get to check in here much. Good to see that your posts are getting thru again this far. For anyone who cares... I'm half way thru my 6 months of courses. I've gotten pretty good at COBOL. It's not too tough. And I've learned to hate C and C++. Sure, they're powerful etc, but...Yuk! Gimme VB! :-) I've also decided I never want to be a full time analyst or network administrator. My regrets to those of you who are. ;-) Gary --- * Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDA00008 Date: 09/06/97 From: GARY SONNENBERG Time: 02:32am \/To: STEVEN LAGER (Read 5 times) Subj: Kinda excited -=> Quoting Steven Lager to All <=- Hi Steven, SL> Well it may not be working with Visual Basic but I got offered (and SL> accepted) a job as a programmer with a leading Canadian finacial SL> planning software company. Unfortunately the first while will be Congratulations!! SL> getting up to steam using Visual FoxPro; but they are considering SL> moving to the Visual Basic enviroment in the future. In the meantime SL> if there is some-one in this echo that has worked with Visual FoxPro SL> do you think you could be of assistance if I run into problems Sorry, that's one of the few popular languages I'm _not_ learning right now. Gary --- * Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDB00000 Date: 09/05/97 From: CLINT HEYER Time: 08:17pm \/To: PHILLIP NORMAND (Read 5 times) Subj: Comercial Software I've been using the Acedemic-priced Visual Basic 4.0 for quite some time now to create shareware apps and as yet have not recieved a) a lawsuit from Microsoft b) a suit from ASP c) death threats from either of the above mentioned parties It should be fine! :) --- Maximus/2 3.01 * Origin: Galaxy GateWay! - Brisbane Valley, Qld, Aust. (3:640/230) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: EDB00001 Date: 09/05/97 From: CLINT HEYER Time: 08:24pm \/To: JIM BROADBENT (Read 5 times) Subj: VB3 OLE Jim, this is taken straight from TechNet...i've used it and it works. I hope it helps. From Clint Heyer There are situations where you'd like your program to have control over windows that do not belong to the program itself. For example, when a Visual Basic program performs OLE automation with Microsoft Word for Windows, you might want to place the Word window next to the current position of the program's window -- so that the two windows are tiled side by side. This article demonstrates how to use the Windows API SetWindowPlacement function in a tiling algorithm. MORE INFORMATION ================ The example code in this article obtains the handles of three standard applications (CALC.EXE, WRITE.EXE, and NOTEPAD.EXE) by using the FindWindow function. Then it tiles the application windows horizontally or vertically, along with the Visual Basic program's form. The handles are obtained after using the Visual Basic Shell function to launch the applications. After obtaining the handles, the example code calls the Windows API SetWindowPlacement function to size and position the top-level window. For illustration, an algorithm that tiles the windows either horizontally or vertically is called using an array of window handles. Possible Enhancement