|
-
Jun 28th, 2010, 12:39 PM
#1
Thread Starter
Lively Member
Print SSTAB Contents
Hello guys!
I wasn't able to find a solution for this one. I've search everywhere.
I have a SSTAB control with 4 tabs. Now i wan't to print the 4 tabs with just a single button. Can somebody guide me to the right direction?
The tab contains so many controls like 20+ option button, 600+ checkboxes, 600+ labels, text boxes, etc.
I want that SSTAB (4 tabs) to be printed out.
Thanks.
-
Jun 28th, 2010, 01:11 PM
#2
Re: Print SSTAB Contents
Erro
This is a start, at least
It will list all controls on the form, and put them in an array
Code:
Dim Control As Control
nn = Me.Controls.Count
Dim aCON
ReDim aCON(nn - 1)
t1 = 0
For Each Control In Me.Controls
aCON(t1) = Control.Name
t1 = t1 + 1
Next Control
As to listing only those on the SSTab,
I'm working on that .. 
Spoo
-
Jun 28th, 2010, 03:16 PM
#3
Re: Print SSTAB Contents
Erro
I think I got it.
This will create a 1-D array.
Code:
Sub Command1_Click()
ListControls "SSTab1" ' change as req'd
End Sub
'---------------------------------------------------------
Sub ListControls(conName)
Dim Ctl As Control
Dim aCtl(3000) ' ie, oversized !!
nn = 0
For Each Ctl In Controls
If Ctl.Container.Name = conName Then ' ie, "SSTab1"
aCtl(nn) = Ctl.Name
aCtl(nn) = aCtl(nn) + "---" + Trim(GetCtlIndex(Ctl))
nn = nn + 1
End If
Next
End Sub
'---------------------------------------------------------
Function GetCtlIndex(Ctl As Control)
z1 = Ctl.Name ' just to test
z2 = Ctl.Index ' real deal
' return value
GetCtlIndex = z2
End Function
The output will look something like this:
Code:
aCtl(0) "opButton3---3"
aCtl(1) "opButton3---2"
aCtl(2) "opButton3---1"
aCtl(3) "opButton3---0"
aCtl(4) "opButton1---3"
aCtl(5) "opButton1---2"
aCtl(6) "opButton1---1"
aCtl(7) "opButton1---0"
aCtl(8) "Command1---0
Each array element contains the control name and index number
Modify as desired.
Hope this helps
Spoo
-
Jul 1st, 2010, 01:22 AM
#4
Thread Starter
Lively Member
Re: Print SSTAB Contents
Thanks for the help but is it possible to use like print screen SSTab1 and send it to the printer?
-
Jul 1st, 2010, 02:01 AM
#5
Re: Print SSTAB Contents
Maybe use PrintWindow?
Example, copy a tab including controls as an image to a picture box.
Code:
Option Explicit
Private Declare Function PrintWindow Lib "User32.dll" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long
Private Sub Form_Load()
PicTemp.Appearance = 0
PicTemp.BorderStyle = 0
PicTemp.AutoRedraw = True
' PicTemp.Visible = False
End Sub
Private Sub Command1_Click()
SSTab1.Tab = 1 ' set to tab 1
DoEvents
With PicTemp
.Width = SSTab1.Width ' match size
.Height = SSTab1.Height
PrintWindow SSTab1.hWnd, PicTemp.hDC, 0 ' copy as image
.Refresh
End With
End Sub
Last edited by Edgemeal; Jul 1st, 2010 at 02:07 AM.
-
Jul 1st, 2010, 02:23 AM
#6
Thread Starter
Lively Member
Re: Print SSTAB Contents
thanks for the code. But i have 4 tabs and the print button is on the 4th tab. Do that code needs the focus of the whole form to work? If i press the print button on the 4th tab, can it print the all the contents on the first tab?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|