[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
I have got the following code (dont know if its right!) but cant seem to get the second bit to work, or indeed how to load an image on the fly.
class-id. Form1 as "ToolTip.Form1" is partial
inherits type "System.Windows.Forms.Form".
environment division.
configuration section.
repository.
class cImage as "System.Drawing.Image"
.
object.
working-storage section.
01 ws-cImage cImage.
method-id. NEW.
procedure division.
invoke self::"InitializeComponent"
goback.
end method NEW.
method-id. "Form1_Load" final private.
procedure division using by value sender as object e as type "System.EventArgs".
end method "Form1_Load".
method-id. "toolTip1_Draw" final private.
procedure division using by value sender as object e as type "System.Windows.Forms.DrawToolTipEventArgs".
* e.DrawBackground()
* e.DrawBorder()
* e.DrawText()
* e.Graphics.DrawImage(img, 0, 0)
invoke e::"DrawBackground"()
invoke e::"DrawBorder"()
invoke e::"DrawText"()
invoke e::"Graphics"::"DrawImage"(ws-cImage, 0, 0)
end method "toolTip1_Draw".
method-id. "toolTip1_Popup" final private.
procedure division using by value sender as object e as type "System.Windows.Forms.PopupEventArgs".
* e.ToolTipSize = New Size(img.Width, img.Height)
end method "toolTip1_Popup".
end object.
end class Form1.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi!
I have not really done any winform stuff for the last couple of years (I lead the language evolution team working on JVM COBOL). However, under Visual COBOL R3 (the current GA product) this all compiles:
class-id WindowsFormsApplication2.Form1 is partial
inherits type System.Windows.Forms.Form.
working-storage section.
01 img type System.Drawing.Image value new System.Drawing.Bitmap(50 50).
method-id. new.
procedure division.
invoke self::InitializeComponent
goback.
end method.
method-id. Form1_Load final private.
procedure division using by value sender as object e as type System.EventArgs.
end method.
method-id. "toolTip1_Draw" final private.
01 img type System.Drawing.Image.
procedure division using by value sender as object e as type System.Windows.Forms.DrawToolTipEventArgs.
invoke e::DrawBackground()
invoke e::DrawBorder()
invoke e::DrawText()
invoke e::Graphics::DrawImage(img 0 0)
end method.
method-id. toolTip1_Popup final private.
procedure division using by value sender as object e as type "System.Windows.Forms.PopupEventArgs".
set e::ToolTipSize to New Size(img::Width img::Height)
end method.
end class.I have reformatted the code to me more inline with current MF recommended format.
Hope that helps :)
Best wishes - AJ
Dr Alexander J Turner
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi!
I have not really done any winform stuff for the last couple of years (I lead the language evolution team working on JVM COBOL). However, under Visual COBOL R3 (the current GA product) this all compiles:
class-id WindowsFormsApplication2.Form1 is partial
inherits type System.Windows.Forms.Form.
working-storage section.
01 img type System.Drawing.Image value new System.Drawing.Bitmap(50 50).
method-id. new.
procedure division.
invoke self::InitializeComponent
goback.
end method.
method-id. Form1_Load final private.
procedure division using by value sender as object e as type System.EventArgs.
end method.
method-id. "toolTip1_Draw" final private.
01 img type System.Drawing.Image.
procedure division using by value sender as object e as type System.Windows.Forms.DrawToolTipEventArgs.
invoke e::DrawBackground()
invoke e::DrawBorder()
invoke e::DrawText()
invoke e::Graphics::DrawImage(img 0 0)
end method.
method-id. toolTip1_Popup final private.
procedure division using by value sender as object e as type "System.Windows.Forms.PopupEventArgs".
set e::ToolTipSize to New Size(img::Width img::Height)
end method.
end class.I have reformatted the code to me more inline with current MF recommended format.
Hope that helps :)
Best wishes - AJ
Dr Alexander J Turner
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Many thanks for that but I dont see how I can "load" an image "on the fly" into the tooltip so when it hovers over a feature an image appears instead of some text.
Could you pls advise.
Many thanks for your help
Kind regards
Neil.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
I have created a working sample of OwnerDrawn Tooltips which will show various methods of creating tooltips including loading an image.
If you give me your e-mail address then I will send you the demo...
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi Chris,
Many thanks for info my email address is
neil@eurorealm.co.uk
Kind regards
Neil.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Here you go Neil.
Example sent by e-mail.
The attachment is actually a zip file but my Outlook won’t let me send a zip file.
Please rename it to .zip after downloading it.
I think that this is self-explanatory but if you do have questions please let me know.
Thanks.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi Chris,
Many thanks for that, it works great and I have changed it so I can change the image on the fly for different buttons.
One more thing, say I have 5 items in the data grid and I wanted to display a different image for each line as I hovered over it, is that possible?
Kind regards
Neil.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi Chris,
I have also noticed that the images sizes on the screen are some times very large and vary quite a lot in pixel size and hide some controls required not to be hidden.
My images vary in sizes from say 200x200 to 1024x768.
So is it possible to some how create the "image" as a thumbnail of the original image or set the tooltip image size to say 400 x 400 and then make the image autofit?
I know you can autofit when using the pictureBox control so just need to do the same sort of thing with the tooltip images.
Many thanks
Neil.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
For the image sizing, this can be done using the Graphics.Drawing class and adding the size parameters of height and width in pixels after the location parameters.
In the following it will resize the image to 50 x 50 pixels:
if e::AssociatedControl = button3
invoke e::DrawBackground
invoke e::DrawBorder
invoke e::DrawText
invoke e::Graphics::DrawImage(wsImage, 0, 0, 50, 50)
In the code for the PopupEventHandler you would also have to change the size of the tooltip itself.
In the example I sent I was setting it to the size of the image.
Change this as follows:
if e::AssociatedControl = button3
*> set e::ToolTipSize to New Size(wsImage::Width, wsImage::Height)
set e::ToolTipSize to New Size(50, 50)
end-if
For the dataGridView control you can easily set the ToolTip by row by handling the event DataGridViewCellToolTipTextNeeded as follows and setting the property VirtualMode to True:
method-id CellToolTipNeeded final private.
procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellToolTipTextNeededEventArgs.
if e::RowIndex = 0
set e::ToolTipText to "Grid Row 1"
else
if e::RowIndex = 1
set e::ToolTipText to "Grid Row 2"
else
if e::RowIndex = 2
set e::ToolTipText to "Grid Row 3"
end-if
end-if
end-if
end method.
This will allow you to change Tooltip text only.
I could not find a method of displaying an image for a dataGridView Tooltip as it does not appear that owner drawn Tooltips are supported directly for this control.
Perhaps someone else has a suggestion for doing this?
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
I did a little more digging and I was able to come up with a sample that demonstrates how to change the image in a tooltip based on the row in a dataGridView over which you are hovering.
Basically you do not attach the tooltip directly to the dataGridView control but you display the tooltip using the Show method based on what row the mouse is over.
I will e-mail you the full working demo and I will also post the code here:
$set ilusing"System.Windows.Forms"
$set ilusing"System"
$set ilusing"System.Drawing"
$set ilusing"System.Windows.Forms.VisualStyles"
$set SQL(DBMAN=ADO)
class-id GridTooltip.Form1 is partial
inherits type System.Windows.Forms.Form.
working-storage section.
EXEC SQL include sqlca END-EXEC.
EXEC ADO declare customers datatable
(
CustName string(30) not null,
CustCompany string(30) not null,
CustPhone string(15) not null
)
END-EXEC
EXEC ADO declare cust_info dataset for customers
save schema to "cust_info.xsd"
END-EXEC.
01 CustomerDataset type System.Data.DataSet.
01 tmpDataset object reference.
01 wsImage type Image.
01 cellColumnIndex binary-long value -1.
01 cellRowIndex binary-long value -1.
01 ImageName.
05 pic x(30) value "c:\\GridTooltip\\GridTooltip\\Num".
05 ImageNum pic 9 value 1.
05 pic x(4) value ".jpg".
method-id NEW.
procedure division.
invoke self::InitializeComponent
invoke self::fillGrid()
set dataGridView1::DataSource to CustomerDataset::Tables::Item("Customers")
set dataGridView1::ShowCellToolTips to false
set toolTip1::AutomaticDelay to 0
set toolTip1::OwnerDraw to true
set toolTip1::ShowAlways to true
set toolTip1::ToolTipTitle to "Custom Tooltip: "
set toolTip1::UseAnimation to false
set toolTip1::UseFading to false
goback.
end method.
method-id fillGrid.
local-storage section.
01 lsCustName pic x(30).
01 lsCustCompany pic x(30).
01 lsCustPhone pic x(15).
procedure division.
EXEC ADO Initialize dataset
returning :tmpDataset
END-EXEC
set CustomerDataset to tmpDataset as type System.Data.DataSet.
move "Chris Glazier" to lsCustName
move "Micro Focus" to lsCustCompany
move "(800) 555-1212" to lsCustPhone
EXEC ADO
insert into customers
values (:lsCustName,
:lsCustCompany,
:lsCustPhone)
END-EXEC
move "John Smith" to lsCustName
move "Smith Plumbing" to lsCustCompany
move "(603) 555-9999" to lsCustPhone
EXEC ADO
insert into customers
values (:lsCustName,
:lsCustCompany,
:lsCustPhone)
END-EXEC
move "Sue Jackson" to lsCustName
move "Jackson Software" to lsCustCompany
move "(203) 555-7777" to lsCustPhone
EXEC ADO
insert into customers
values (:lsCustName,
:lsCustCompany,
:lsCustPhone)
END-EXEC
move "Steve Johnson" to lsCustName
move "IBM" to lsCustCompany
move "(203) 555-3434" to lsCustPhone
EXEC ADO
insert into customers
values (:lsCustName,
:lsCustCompany,
:lsCustPhone)
END-EXEC
move "Susan Snow" to lsCustName
move "Wedoitright Software" to lsCustCompany
move "(800) 555-6666" to lsCustPhone
EXEC ADO
insert into customers
values (:lsCustName,
:lsCustCompany,
:lsCustPhone)
END-EXEC
EXEC ADO
Accept changes for all datatables
END-EXEC
EXEC ADO
unbind
END-EXEC
exit method.
end method.
method-id DrawToolTipEventHandler final private.
procedure division using by value sender as object e as type System.Windows.Forms.DrawToolTipEventArgs.
invoke e::DrawBackground
invoke e::DrawBorder
invoke e::DrawText
invoke e::Graphics::DrawImage(wsImage, 0, 0, 50, 50)
end method.
method-id PopupEventHandler final private.
procedure division using by value sender as object e as type System.Windows.Forms.PopupEventArgs.
set e::ToolTipSize to New Size(50, 50)
end method.
method-id CellMouseMoved final private.
01 mousePos type Point.
procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellMouseEventArgs.
if e::ColumnIndex <> cellColumnIndex or e::RowIndex <> cellRowIndex
invoke toolTip1::Hide(self::dataGridView1)
set cellColumnIndex to e::ColumnIndex
set cellRowIndex to e::RowIndex
if cellColumnIndex >= 0 and cellRowIndex >= 0
compute ImageNum = cellRowIndex 1
set wsImage to type Image::FromFile(ImageName)
set mousePos to self::PointToClient(self::MousePosition)
invoke self::toolTip1::Show(" ", self::dataGridView1, mousePos)
end-if
end-if
end method.
method-id MouseLeft final private.
procedure division using by value sender as object e as type System.EventArgs.
invoke self::toolTip1::Hide(self::dataGridView1)
end method.
method-id button1_Click final private.
procedure division using by value sender as object e as type System.EventArgs.
invoke self::Close()
end method.
end class.
[Migrated content. Thread originally posted on 08 March 2011]
Hi All,
Im trying to add an image to a tooltip and have found the following VB code and was just wondering if any one knows have to convert to Visual Cobol Code?
Code :-
ToolTip1.SetToolTip(dgv, " ")
1. Private Sub ToolTip1_Draw(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawToolTipEventArgs) Handles ToolTip1.Draw
2. e.DrawBackground()
3. e.DrawBorder()
4. e.DrawText()
5. e.Graphics.DrawImage(img, 0, 0)
6. End Sub
7.
8. Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs) Handles ToolTip1.Popup
9. e.ToolTipSize = New Size(img.Width, img.Height)
10. End Sub
Link to site:-
www.vbforums.com/showthread.phpAny help would be gratefully received.
Many thanks
neil.
Hi Chris,
Many thanks for all your help in this matter, it all works really well.
Kind regards
Neil.