|
What exactly is a "regular" Dll? And what is a "Extension" Dll? Please explain, this wording is strange to me.
|
|
|
|
|
|
Considering the original question (VB6.DLL) I would not think he was able to build an "extension" dll. and also not an "regular" dll. There is an codeproject article (I my memory is ok) about creating non-ActiveX Dlls with Vb6, but I would guess he talked about an ActiveX Dll. Nothing with your C++ stuff ...
And, in fact, I used VB6.DLL with C# and it works great.
|
|
|
|
|
VB6 can only build COM-based .DLL files (ActiveX). It cannot build a library, or extension, or anything else for that matter.
Well, that's mostly true anyway. You can coerce a library .DLL out of VB6, but you have to hack it together.
|
|
|
|
|
Have a look at COM Interop.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I have a splitbutton toolbar control that doesn't seem to work right.
The BackColor property can be set and read, but doesn't show up on the control itself. I have an image with transparency, and no matter which way I change the backcolor (programmatically or in the properties), it uses the regular control color. I even checked the designer code, and the color is there.
Anyway, I'm trying to implement the last chosen color for font and hiliting (the way Word/Wordpad does for their controls. Thought I'd try the background color first. Does anyone know of any code to alter a portion of the image itself?
I know there's the wordpad sample, but it's a variety of C. Maybe I can convert it (if I can find it)modified on Saturday, March 13, 2010 5:09 PM
|
|
|
|
|
Figured out how to alter an existing image. Pretty simple really.
This colors the last 4 lines of the image itself. This of course only works for a 16 x 16 image, but can easily be changed for different placement and image size.
Since I have 2 controls in 3 different places, I just do:
instance.Image = ColorImage(instance.Image, newColor)
Private Function ColorImage(ByRef theImage As System.Drawing.Bitmap, _
ByRef theColor As System.Drawing.Color) _
As System.Drawing.Bitmap
Dim x, y As Integer
For y = 12 To 15
For x = 0 To 15
theImage.SetPixel(x, y, theColor)
Next
Next
ColorImage = theImage
End Function
|
|
|
|
|
I have done alot of profiling and much reworking to my application but it is still too slow.
The place that seems to be the problem now is in InializeComponent().
The form is rather large with MANY controls but they are all needed because of the organization of the app.
Any suggestions are very welcome thank you.Humble Programmer
|
|
|
|
|
InitializeComponent is generated by Visual Designer, so you can't really change it directly.
AFAIK Designer takes care of suspending and resuming layout when appropriate.
You can keep it fast by:
- not having dozens of Controls; you should not show 100 Controls all at once to the poor user, and you should not create, add, populate, Controls that aren't directly visible (e.g. on other tab pages);
- not adding data immediately upon Form creation; i.e. not populating Controls that need a lot of information such as ListBox, ComboBox, TreeView, PictureBox; you could postpone that till the Form is shown, and even then a background thread might be helping out (beware illegal cross-thread operations).
- not having a background image;
- not playing with transparency.
|
|
|
|
|
I think this may be more of the problem.
Just FYI I inherited this code...
These are all class level variables...
They are used in many different ways throughout the class.
The reason it was done this way is obvious he wanted to be able to keep the forms so that he could check if they were loaded before reloading them.
My question is, is there a way that I can keep these available to all mentioned code without the huge performance hit when creating this class?
Private lClientNumber As Long ' the uniquenumber that was passed from the calling program
' ' This is the ClientNumber.
Private tPassedMode As String ' mode we are in "ADD", "EDIT", "VIEW"
'
Private bInquireOnly As Boolean
Private bDataChanged As Boolean
Private bFieldChanged As Boolean
Private bExistingRecord As Boolean
Private myCommand As New MySqlCommand
Private tVarArray(100, 3) As String
'
Private lStateNum() As Long
Private lSCNumber() As Long
Private lRaceNumber() As Long
Private lLanguageNumber() As Long
Private lLegalStatusNumber() As Long
Private lMaritalStatusNumber() As Long
Private lGender() As Long
Private lCountyOfResidence() As Long
'
Private ClientDatesAnnuals As frmClientDatesAnnuals = frmClientDatesAnnuals
Private ClientContacts As frmClientContacts = frmClientContacts
Private ClientPickups As frmClientPickups = frmClientPickups
Private ClientDatesIPPIFSP As frmClientDatesIPPIFSP = frmClientDatesIPPIFSP
Private ClientDatesPsyc As frmClientDatesPsyc = frmClientDatesPsyc
Private ClientDayHab As frmClientDayHab = frmClientDayHab
Private ClientDietary As frmClientDietary = frmClientDietary
Private ClientExtendedCare As frmClientExtCare = frmClientExtCare
Private ClientFileStorage As frmClientFileStorage = frmClientFileStorage
Private ClientFinancialScreen As frmClientFinancialScreen = frmClientFinancialScreen
Private ClientFirstConnection As frmClientFrstConn = frmClientFrstConn
Private ClientHearScreen As frmClientHearingScreening = frmClientHearingScreening
Private ClientIdentification As frmClientIdentification = frmClientIdentification
Private ClientIndividualCounseling As frmClientIndivCounsel = frmClientIndivCounsel
Private ClientImmunizations As frmClientImmunizations = frmClientImmunizations
Private ClientMedical As frmClientMedical = frmClientMedical
Private Notes As sha_frmNotes = sha_frmNotes
Private ClientPublicSchool As frmClientPublicSchool = frmClientPublicSchool
Private ClientTherapyOT As frmClientTherapyOT = frmClientTherapyOT
Private ClientTherapyST As frmClientTherapyST = frmClientTherapyST
Private ClientTherapyPT As frmClientTherapyPT = frmClientTherapyPT
Private ClientTransportation As frmClientTransportation = frmClientTransportation
Private ClientVisionScreen As frmClientVisionScreening = frmClientVisionScreening
Private ClientConsentToInvite As New frmClientConsentToInvite
Private RefDates As frmRefDates = frmRefDates
Private RefDetails As frmRefDetails = frmRefDetails
Private RefEvals As frmRefEvals = frmRefEvals
Humble Programmer
|
|
|
|
|
Also so that he can check if there is saved data on the other forms when they close the main form . Humble Programmer
|
|
|
|
|
I see a lot of form referencing variables. You did not specify where that code resides, but having a "Private" attribute they must be class members. Furthermore (I'm no VB.NET expert) I'm afraid
x As frmX=frmX calls the frmX constructor, so all these forms get instantiated right away, as soon as the containing class is being instantiated. That is horrible as it delays everything, and probably isn't needed at all, the app probably is never going to need ALL those forms, and certainly not right away.
What needs to be done is organize lazy instantiation. The easiest way to do that is by using properties. Something like (not tested):
Private hiddenX as frmX
Property X as frmX
If hiddenX isNothing
hiddenX=new frmX
Endif
Return hiddenX
End Property
That way, the remainder of the code can reference X as before, however the form will be instantiated only the first time X gets referenced. From then on, X behaves as before, remains alive (in hiddenX), etc.
|
|
|
|
|
OMG you are a life saver that it dropped the percentage of time for execution from 4.0% .42... for that line
Dude you want a job???
This has been the bane of my existence for a while lol.
So very awesome thank you very very much.
Anyone interested here is the actual working VB code.
Private ClientDatesAnnuals As frmClientDatesAnnuals
Private ReadOnly Property DateAnnuals() As frmClientDatesAnnuals
Get
If ClientDatesAnnuals Is Nothing Then
ClientDatesAnnuals = New frmClientDatesAnnuals
End If
Return ClientDatesAnnuals
End Get
End Property
Humble Programmer
|
|
|
|
|
Here are some examples of the use of the form objects in the class.
Private Sub frmClientCommon1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' close any sub forms that are open ...
If fbFormInstanceExists(ClientContacts) Then
If ClientContacts.bDataChangeStatus Then
MsgBox("Information Has Been Changed On The 'Client Emergency Contacts' Screen, But Has Not Been Saved. " & _
"Please save the information on this form prior to closing.", MsgBoxStyle.Exclamation, Me.Text)
ClientContacts.TopMost = True
e.Cancel = True
Exit Sub
Else
ClientContacts.Close()
ClientContacts.Dispose()
End If
End If
End Sub
Private Sub sHandleCommand(ByVal sender As Object, ByVal e As CommandClickEventArgs)
Select Case e.Command.Text
Case "Emergency Contacts"
If Not fbFormInstanceExists(ClientContacts) Then
ClientContacts = New frmClientContacts
End If
ClientContacts.tMode = tPassedMode
ClientContacts.lClientUniqueNumber = lClientNumber
ClientContacts.tClientName = ftFormatClientName(txtFirstName.Text, _
txtMiddleName.Text, txtLastName.Text, "2")
Me.Cursor = Cursors.WaitCursor
ClientContacts.Show()
ClientContacts.BringToFront()
Case "BLAH"
'Same stuff different form
Case "BLah2" 'etc
End Select Humble Programmer
|
|
|
|
|
Can anyone know how to make a relational query in vb.net?
thanks!
-robayas
|
|
|
|
|
You're going to have to explain a bit more than that. Which database are you using? Are you using LINQ? Relating a couple of DataTable objects? What?
|
|
|
|
|
We're using access database and we are not familiar with LINQ.
What we are planning is to use Access SQL. Like CREATE VIEW or like that.
Do you have any good idea or suggestion to solve our problem.
Thank you in advance. =)
-rob00
|
|
|
|
|
Use the query designer in Access then either cut and paste the SQL code generated in your VB.NET program, or save the query in Access and perform your SELECT, INSERT DELETE command upon the Access Query.
Research the System.Data.Oledb namespace, in particular the OleDbConnection, OleDbCommand, OleDbDataReader and the OleDbDataAdaptor classes.Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
And research the limitaions of SQL. Access does not support real stored procedures nor named parameters in parameterized queries.
|
|
|
|
|
When the following code is executed.
Dim strPrint As New StringBuilder
For Me.counter = 0 To 19
strPrint.Append(writeline(Me.counter) & vbCrLf)
Next Me.counter
'e.Graphics.DrawString(strPrint.ToString, printFont, System.Drawing.Brushes.Black, 10, 10)
If System.IO.File.Exists(SaveFileDialog1.FileName) Then
printfile = File.OpenText(SaveFileDialog1.FileName)
printfile = System.IO.File.OpenText(SaveFileDialog1.FileName)
Do Until printfile.Peek = -1
menuitem(printcounter) = printfile.ReadLine
e.Graphics.DrawString(printfile.ReadToEnd, printFont, _
System.Drawing.Brushes.Black, 10, 10)
printcounter = printcounter + 1
Loop
printfile.Close()
End If
It does not print the in the same way on how it looks in notepad. Any Ideas. You can get writeline code on the forum discussion title "writing to text file" Any ideas how to resolve issues.
issues as has been resolved by changing the font name..modified on Friday, March 12, 2010 9:16 PM
|
|
|
|
|
Hi,
1.
Daniel Engelkes wrote: It does not print the in the same way on how it looks in notepad
is not a symptom we can work on. What does it do, and how is that different from what you want/expect?
2.
A do-loop containing printfile.ReadToEnd will iterate only once. Your first line goes to "menuitem", everything else goes to "DrawString", there isn't a second iteration.
3.
Most often, the correct way to print a number of lines is by having a loop, where each iteration prints one line of text, at a different location; so you need to have coordinates (x,y) which change as you iterate your loop.
4.
Very likely, I haven't checked that part of your code: in order to write a number of strings to a text file, there is no need to concatenate the text and write all in one go. One can:
- either use a FileStream and the WriteLine method;
- or fill a string array and use File.WriteAllLines().
|
|
|
|
|
I would load the file into a List or similar collection (coll ) off String Array objects and then iterate through the collection, setting the x,y coordinates as appropriate:
'Read each line into an array and then put each array into a Generic.List(Of Array)
' Then do something like this in the PrintPage Event...
Dim l As Single = e.MarginBounds.Left ' Left margin
Dim y as Single = e.MarginBounds.Top ' Top margin
Dim h as Integer = 18 ' Row Height
Dim ws() As Single = {100, 50, 50, 50) ' Column widths
Dim sfs() As StringFormat = {StringFomat.Alignment.Far, StrngFormat.Alignment.Centre, _
StringFormat.Alignment.Near, StringFormat.Far}
Dim cuRow As Integer = 0
Dim linesReq As Integer = coll.Count - 1
Dim fnt as New Font("Courier New", 10, FontStype.Regular)
Dim pageline as Integer = 1
Dim linesPerPage as Integer = Math.Floor((e.MarginBounds.Bottom-y)/h)
For i as Integer = curRow to coll.Count -1
Do While (pageLine <= linesPerPage) And (curRow <= linesReq)
PrintText(e, coll.Item(curRow), l, y, ws, h, fnt, Brushes.Black, sfs())
y += h
pageLine += 1
curRow += 1
Loop
If (cuRow > linesReq)
Exit For
End If
Next i
...
Private Sub PrintText(ByVal e as PrintPageEventArgs, txtArray As Array, _
ByVal l as Single, ByVal y as Single, ByVal ws As Array, _
ByVal h As Single, ByVal fnt As Font, ByVal br as Brush, _
ByVal sfs As Array)
For i as Integer = 0 To txtArray.Count - 1
e.Graphics.DrawString(txtArray(i), l, y, ws(i), h, fnt, br, sfs(i))
l += ws(i)
Next
End Sub
<edited because="" i="" was="" drinking="" when="" wrote="" the="" reply="" -="" probably="" won't="" compile="" but="" you="" get="" idea="">I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
modified on Friday, March 12, 2010 3:28 AM
|
|
|
|
|
How you read or write the file has nothing to do with how it prints.
Are you using the same font?
How are you handling the PrintDocument events for new Pages etc.?
Do you have the margins set up the same as notepad does?
The questions are endless.
|
|
|
|
|
when I write to the file this is the format
Menu Items Qty Unit Cost Total Cost
---------- --- --------- ----------
cheeseburger 0 $5.00 $0.00
onion rings 0 $6.00 $0.00
chicken sdwch 0 $5.00 $0.00
milk shake 0 $2.00 $0.00
mexican rice 0 $5.00 $0.00
quasidella 0 $2.00 $0.00
shrimp cocktail 0 $5.00 $0.00
lasagne 0 $3.00 $0.00
spagehtti 0 $5.00 $0.00
cake 1 $2.00 $2.00
cookies 1 $6.00 $6.00
OrderTotal:$8.00
DrinkTotal:$0.00
---------------
SubTotal:$8.00
Tax Amount:$0.60
---------------
Grand Total:$8.60
but when I print the document from the program it end up like this
MenuItemsQty Unit Cost Total Cost
---------- --- --------- ----------
cheeseburger 0 $5.00 $0.00
onion rings 0 $6.00 $0.00
chicken sdwch 0 $5.00 $0.00
milk shake 0 $2.00 $0.00
mexican rice 0 $5.00 $0.00
quasidella 0 $2.00 $0.00
shrimp cocktail 0 $5.00 $0.00
lasagne 0 $3.00 $0.00
spagehtti 0 $5.00 $0.00
cake 1 $2.00 $2.00
cookies 1 $6.00 $6.00
it needs the same format. any ideas.
|
|
|
|
|
Ha, we finally got a symptom. Seems you want columnar results without using one DrawString for each cell. So you are relying on tabs (very difficult) or on spaces to get data formatted in columns. Unless you print individual cells, you need to choose a non-proportional or monospaced font, such as Courier New, and NOT a proportional font such as Arial. (If you choose Arial in Notepad, the data will look bad too!)
|
|
|
|
|